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

Workspace doesn't render when stopped and started again #649

Closed
mindbound opened this issue Dec 2, 2024 · 2 comments
Closed

Workspace doesn't render when stopped and started again #649

mindbound opened this issue Dec 2, 2024 · 2 comments

Comments

@mindbound
Copy link

mindbound commented Dec 2, 2024

I used the Braille canvas example from the wiki, with the following added event handler function:

workspace.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
    if e1 == "key_down" then
        workspace:stop()
    end

    workspace:draw()
end

On a key press, the code terminates normally. When I run the script for the second time, nothing is rendered on the screen, even though the event handler itself seems to work normally and there are no errors. When I reboot the computer, the workspace is rendered correctly when I run the script for the first time (after which it fails to render again). This behaviour is not exclusive to the Braille canvas example and seems to affect any workspace regardless of its child contents.

I'm running the code on MC 1.7.10, OC 1.10.27-GTNH.

What could I be doing wrong? TIA!

@IgorTimofeev
Copy link
Owner

Hmm, what do you do after calling workspace:stop()? Do you drawing something directly to screen buffer? If so, yo should call workspace:draw() before calling workspace:start(). Otherwise give pls full code example, it's hard to determine problem

local GUI = require("GUI")
local event = require("Event")
local screen = require("Screen")

--------------------------------------------------------------------------------

local workspace = GUI.workspace()
workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))

workspace:addChild(GUI.button(3, 2, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x0, "Button"))

workspace.eventHandler = function(workspace, object, e1, e2, e3, e4)
	if e1 ~= "key_down" then
		return
	end

	-- Stopping workspace
	workspace:stop()

	-- Drawing something directly into screen buffer
	screen.drawRectangle(10, 10, 30, 4, 0xFF4940, 0x0, " ")
	screen.update()

	GUI.alert("Done")

	-- Restarting workspace
	workspace:draw()
	workspace:start()
end


--------------------------------------------------------------------------------

workspace:draw()
workspace:start()

@Smok1e Smok1e assigned Smok1e and unassigned Smok1e Dec 2, 2024
@mindbound
Copy link
Author

If so, yo should call workspace:draw() before calling workspace:start()

That seems to have helped, thanks!

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

3 participants