Page 1 of 1

Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Mon Aug 15, 2016 7:05 pm
by Sambo
I have a sprite override that runs in onDraw (only once). For some reason, if I start a test in SMBX from the PGE editor, it gives me this error:
Image

It works fine if I start the test directly from SMBX.

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 11:03 am
by Kevsoft
Please test if the image is valid. I could only think that Graphics.loadImage somehow fails

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 12:15 pm
by PixelPest
Could you maybe post the code?

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 1:59 pm
by Sambo
Kevsoft wrote:Please test if the image is valid. I could only think that Graphics.loadImage somehow fails
The image is valid. As I said, the override is successful unless I start the test using "Test in SMBX" function of the PGE editor. I just tested to make sure, and no matter where I start the test from, the image loads. Unless a test from PGE makes it load the image in the wrong format somehow, this is not the problem.
PixelPest wrote:Could you maybe post the code?

Code: Select all

function layers.draw()
	if layers.debug then
		for _,v in pairs(nodes) do
			Graphics.drawImageToScene(debugImg, v.x, v.y)
			textblox.printExt(v.id, {x = v.x + 16, y = v.y + 16, font = textblox.FONT_SPRITEDEFAULT3X2, bind = textblox.BIND_LEVEL})
		end
	else
		if not frame then
			Graphics.sprites.background[anchor].img = Graphics.loadImage(Misc.resolveFile("blank.png")) -- Add this file to a folder in luaScriptsLib
			frame = true
		end
	end
end
This function is part of an API, and it is registered to the onDraw event.
debugImg is an image resource, and anchor is the ID of a BGO.

Actually, that's not the only problem I have with this API. What this API does is, it introduces a position-based layer movement system to SMBX. The trouble is, the layers don't want to stop moving once they start moving. It sets the x and y speeds to 0.0001 when I tell them to stop. This slowly but surely messes up the positions of the layers. Sometimes, the layers will just "twitch" like crazy instead of stopping, sending Mario flying to the left or right at high speeds when he touches them. The only thing I can do is continually set the speed to move the layer back to the desired position, but this sometimes causes an overflow crash.
Here is a paste of the whole code:
http://hastebin.com/ekofuqarud.lua

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 6:36 pm
by PixelPest
Ah. Your argument in square brackets for Graphics.sprites is wrong. It should be an ID instead of a Lua Image Resource. You should also just be do local blank = Graphics.loadImage("blank.png"); at the top of your file as well instead of loading it every time. You also don't really need Misc.resolveFile() in that either

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 10:26 pm
by Sambo
PixelPest wrote:Ah. Your argument in square brackets for Graphics.sprites is wrong. It should be an ID instead of a Lua Image Resource.
It is an ID.
I, Sambo, wrote:... anchor is the ID of a BGO.
PixelPest wrote:You should also just be do local blank = Graphics.loadImage("blank.png"); at the top of your file as well instead of loading it every time. You also don't really need Misc.resolveFile() in that either
It only loads the image on the first frame, and if it didn't do that every time, it would work even less than it does now. The reason that it has Misc.resolvefile is so it can load the image from the LuaScriptsLib folder.

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 10:29 pm
by PixelPest
Have you debugged anchor to make sure it isn't nil when it's run through Graphics.sprites?

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Tue Aug 16, 2016 11:14 pm
by HenryRichard
The way PGE does testing is weird; it doesn't copy absolutely everything needed (like images in the episode folder). It's because of PGE and not your code.

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Wed Aug 17, 2016 4:33 am
by Wohlstand
HenryRichard wrote:The way PGE does testing is weird; it doesn't copy absolutely everything needed (like images in the episode folder). It's because of PGE and not your code.
That was in legacy testing implementation. Latest version in the laboratory (you also must load latest dev build of the LunaLUA!) supports direct test launching without copying of the stuff, therefore new testing system (now named as LunaTester) will send level data and will refer episode path that is real, and will don't generate dummy episodes that needed only for vanilla SMBX without LunaLUA. I'll release it with updated PGE Engine which now waiting my new better physical engine implementation

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Wed Aug 17, 2016 4:48 pm
by HenryRichard
Ah, okay. I haven't updated PGE in a while, so I guess that's what my problem is.

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Wed Aug 17, 2016 6:09 pm
by Sambo
I moved the override to onStart and it fixed the problem. I still don't understand what the problem was, though.
Wohlstand wrote:That was in legacy testing implementation. Latest version in the laboratory (you also must load latest dev build of the LunaLUA!) supports direct test launching without copying of the stuff, therefore new testing system (now named as LunaTester) will send level data and will refer episode path that is real, and will don't generate dummy episodes that needed only for vanilla SMBX without LunaLUA. I'll release it with updated PGE Engine which now waiting my new better physical engine implementation
So, to use this, do we need the SMBX Integration config pack? Because with the full config I can't launch a test in SMBX if the editor isn't opened.

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Thu Aug 18, 2016 3:29 am
by Wohlstand
Sambo wrote:So, to use this, do we need the SMBX Integration config pack? Because with the full config I can't launch a test in SMBX if the editor isn't opened.
Yes, you need SMBX Integration pack (take from laboratory because other is incompatible), especially to point your actual SMBX directory. In-Editor test runner is outdated and buggy because SMBX's iternals and lacks of right detection of opened SMBX Editor (on LunaLUA side is required to make extra shared memory to tell that editor is started (for example, keep hwnd of the editor window))

Re: Testing Levels with PGE Causes Problems with Sprite Overrides

Posted: Thu Aug 18, 2016 6:36 pm
by Sambo
The SMBX Integration config is the same as the full SMBX config, except that it uses the previously installed SMBX directory, right?