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

Monarch appears to be reloading popup scene instead of re-using it #85

Closed
greay opened this issue Mar 8, 2022 · 1 comment
Closed

Comments

@greay
Copy link

greay commented Mar 8, 2022

I'm in the middle of refactoring my GUI code, and I'm a bit confused about how Monarch handles re-showing the same screen
the way I have it set up currently, I call monarch.show(hash("dialogue"), nil, beat)
but my dialogue code throws an error:

ERROR:SCRIPT: /richtext/richtext.lua:678: Node used in the wrong scene

it seems like it's reloading the screen, instead of just re-using it? I think? and all of my existing code assumes that the GUI nodes are going to remain loaded

It might take some amount of work to extract a small reproducable sample, but the setup & intention is this:

  1. I call monarch.show(hash("dialogue"), nil, beat) where beat is a small table with a line of dialogue & some other info.
  2. the dialogue window (monarch scene) uses the richtext component to type out the dialogue. It's set up so that if it's already shown, it will reset & reuse everything.
M.reset = function()
	if current_timer ~= nil then
		timer.cancel(current_timer)
	end
	if name_timer ~= nil then
		timer.cancel(name_timer)
	end
	
	if words ~= nil then
		richtext.remove(words) -- commenting out this line prevents (or hides) the error
	end
	current_timer, name_timer, current_string, current_name, words, metrics = nil
end

(by default, it resets every time, but the 1st time it's pretty much a no-op)

  1. repeat until the player has exhausted the dialogue

I've been able to work around it, as noted, by commenting out the part that resets & reuses the richtext nodes.

@britzl
Copy link
Owner

britzl commented Mar 14, 2022

This is by design. Monarch follows a pattern of always loading and unloading screens, even when the screen in question is already at the top of the stack.

@britzl britzl closed this as completed Mar 14, 2022
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

2 participants