Have a problem with message to .gui_script (SOLVED)

#1

I can pass table with some values to any .script with msg.post but if i pass it to .gui_script i have no values at table! And i am shure that it pass the msg, cose i can trace it by debugger and message_id has “disable”.
Code of post:

msg.post(MENU,"disable",{what="main"})

Code of receave:

function on_message(self, message_id, message, sender)
	if message_id == hash("enable") then
		local what = message["what"]
		local l = gui.get_node(what)
		gui.set_enabled(l, true)
	else if message_id == hash("disable") then
		local what = message["what"]
		pprint(message)  <----------- this print under code
		local l = gui.get_node(what)
		gui.set_enabled(l, false)
		end
	end
end

image

0 Likes

#2

The strings “enable” and “disable” have specific uses in Defold - see here.

I just tested it myself by sending a “disable” message to a component, and for some reason it just doesn’t include the message table like a normal message. I would recommend that if you want a custom enabling/disabling function then just use something other than “enable” and “disable” in your message.

0 Likes

#3

Sorry, i solved it by a luck. I just need to put “init” to menu.gui_script

0 Likes

#4

th, but all works, i missed init function.

1 Like