Not getting Gui input (SOLVED)

I’m doing a level select, and when a certain node is clicked on it should load the level selected, however, I’m not getting any type of input recognition from the gui scene.

function init(self)
	msg.post(".", "acquire_input_focus")
	
	end
	
	
function final(self)
	msg.post(".", "release_input_focus")	
end

    
    function on_input(self, action_id, action)
    if action.pressed and gui.pick_node(gui.get_node("level1"), action.x, action.y) then
    msg.post("controller:/controller", "show_levelone")
    elseif action.pressed and gui.pick_node(gui.get_node("level2"), action.x, action.y) then
    msg.post("controller:/controller", "show_leveltwo")
    end
    
end`

Is there something I wrote incorrectly? I Cant seem to find it.

Also, is there any idea as to what this error means;

WARNING:DLIB: Failed to send announce message (-2)
ERROR:DLIB: Failed to retrieve address family (-22): NOTSOCK
ERROR:DLIB: Failed to retrieve address family (-22): NOTSOCK
ERROR:DLIB: Failed to send to remote host, unsupported address family!
WARNING:DLIB: Failed to send announce message (-2)
Doesn’t really seem like it messes with the game at all, but just wondering.

Thanks

What happens if you add a print to on_input? Do you get any output in the log? Is the level select loaded via a collection proxy? If that is the case the collection loading your level select also need to acquire input focus. Read more here: http://www.defold.com/manuals/input/#_the_input_stack

No output in the log. The Collection proxy works for the most part. I have a start screen, which sends you to the instructions, and after instructions comes the level select. It’s just that when I get to the level select, it’s not responding to any input. However I can go from the instructions screen straight into loading the level with no problem. So the collection proxies gaining input is up until this certain gui screen.


number 1 is the node level1 here;
if action.pressed and gui.pick_node(gui.get_node("level1"), action.x, action.y) then
Same thing with number two. they’re images that get clicked and send a message to the loader script

Could you perhaps post a screenshot of your hierarchy of the collection proxy?

Share the project with me (bjorn.ritzl@king.com) and I’ll take a look.

1 Like

Hello @Hakim_A! I’m looking into the NOTSOCK problem, and if you could help me out by running the command wmic nic get NetConnectionID from an administrative command prompt that would be great! :slight_smile:

Edit/Add
If my theory is correct, the NOTSOCK error you’re receiving is because of a stray interface where neither an IPv4 nor an IPv6 address is available. This should have no negative effects other than the worrisome error messages.

3 Likes

Seemed to have fixed it accidentally-ish. I’ll post what I remember so far;

The original code I used was this

`function init(self)
	msg.post(".", "acquire_input_focus")
	
	end
	
	
function final(self)
	msg.post(".", "release_input_focus")	
end

    
    function print_on_input(self, action_id, action)
	if action.pressed and gui.pick_node(gui.get_node("level1"), action.x, action.y) then
    msg.post("controller:/controller", "show_levelone")
 
    end
    
end`

I wasnt sure why this wasn’t working, so I copied the code I wrote for the instructions collection proxy that loaded the level select and edited it to work for selecting levels;

function init(self)
	msg.post(".", "acquire_input_focus")
		msg.post("intro#sound", "play_sound", {delay = 0, gain = 1})
	
	end
	
	
function final(self)
	msg.post(".", "release_input_focus")	
end

function on_input(self, action_id, action)
	if action.pressed and gui.pick_node(gui.get_node("level1"), action.x, action.y) then
		msg.post("controller:/controller", "show_levelone")
		elseif action.pressed and gui.pick_node(gui.get_node("level2"), action.x, action.y) then
		msg.post("controller:/controller", "show_leveltwo")
	end
end

I dont think much changed however but the addiction of a sound message. Additionally, I noticed that in my proxy loader script, I had a reaction message for for the first level, but not the second. So when I added a reaction message for the second level the input seemed to start working. Although I did think that if there was a problem sending a message I’d get some type of error, but maybe not if the message went through but there was nothing for to react to? Thanks @britzl for helping out, glad to have this step fixed.

And yeah I havent had any negative effects from it, just was wondering why it started showing up all of a sudden. Thanks!

1 Like

The NOTSOCK problem has been resolved now and should make it to the 1.2.87 release.

The problem occurs when there is a network interface available that neither has an IPv4 address or an IPv6 address associated with it (such as a disconnected interface). The only effect of the bug has been the NOTSOCK error messages and no functionality has been negatively impacted, though these error messages has caused some unnecessary confusion.

Regards,
Jakob

I had the same problem: I used a loader script to implement level selection in a menu, but the collections that were loaded from the script did not receive any input. The solution was to add

msg.post(".", "acquire_input_focus")

and

msg.post(".", "release_input_focus")

not only to the init and final functions of the collections, but to those functions in the loader script as well.

1 Like

Exactly! And why this is required is described in detail in the Input manual.