Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling monarch.top() is returning nil #76

Closed
britzl opened this issue Jun 26, 2021 · 2 comments
Closed

Calling monarch.top() is returning nil #76

britzl opened this issue Jun 26, 2021 · 2 comments

Comments

@britzl
Copy link
Owner

britzl commented Jun 26, 2021

From forum post: https://forum.defold.com/t/monarch-simple-screen-manager/14138/30?u=britzl

"my game fails in the init of a screen’s scripts, because “monarch.top()” returns nil."

function init(self)
	msg.post(".", "acquire_input_focus")
	msg.post("#", "start")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("start") then
		monarch.show(hash("musicSpace"),{no_stack=true})
		--monarch.show(hash("gameSpace"),{no_stack=true})
		
		--monarch.show(hash("Mousechief"))
		--monarch.show(hash("Introduction"))
		--monarch.show(hash("BattleOne"))
		monarch.show(hash("combat"), {}, {"battle01"})
		--monarch.show(hash("testScreen"), {}, {"testScript"})
				
	end 
end
@britzl
Copy link
Owner Author

britzl commented Jun 26, 2021

Unable to reproduce. I modified the basic example. In basic.script I did:

local monarch = require "monarch.monarch"

function init(self)
	msg.post(".", "acquire_input_focus")
	msg.post("#", "show_screens")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("show_screens") then
		monarch.show("screen1",{no_stack=true})
		monarch.show("screen2")
	end
end

And in screen2.gui__script I have this:

local monarch = require "monarch.monarch"

function init(self)
	msg.post(".", "acquire_input_focus")
	print("TOP", monarch.top())
end

With the log showing DEBUG:SCRIPT: TOP hash: [screen2]

@britzl
Copy link
Owner Author

britzl commented Jun 26, 2021

Ah, nvm, tested the wrong branch. I am able to reproduce 👍

@britzl britzl closed this as completed in 4927d6e Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant