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

bad argument #2 to 'loadstring' when using with Playdate SDK #28

Open
alberteddu opened this issue Oct 23, 2022 · 11 comments
Open

bad argument #2 to 'loadstring' when using with Playdate SDK #28

alberteddu opened this issue Oct 23, 2022 · 11 comments

Comments

@alberteddu
Copy link

alberteddu commented Oct 23, 2022

Hello! I'm trying to use tiny-ecs with the Playdate SDK. However every call to tiny.require* fails with:

tiny.lua:126: bad argument #⁠2 to 'loadstring' (number expected, got no value)

This works fine when using the non-playdate version of lua. I imagine that somehow load refers to something else in this environment. Doesn't seem to be a problem with tiny-ecs itself, but since I'm new to lua and I'm having trouble debugging this, I'm posting here with the hope that someone else had the same problem.

Maybe the maintainer of this library has an idea of what to check/debug. Feel free to close if this is obviously not related to tiny-ecs.

@alberteddu alberteddu changed the title bad argument #2 to 'load' when using with Playdate SDK bad argument #2 to 'loadstring' when using with Playdate SDK Oct 23, 2022
@iansharkey
Copy link

I looks like the loadstring function is used to simplify the parsing of filter strings.

I’m looking to use tiny ecs in a playdate game too, I’ll fork and see if I can change the parsing to not need loadstring.

@Rud156
Copy link

Rud156 commented Mar 6, 2023

Maybe replacing the loadstring call to load might help. Seems like loadstring is not available past LUA 5.1 and PlayDate uses LUA 5.3. Maybe the loadstring call in PlayDate is something else and both load and loadstring exists which might be causing the issue.

https://stackoverflow.com/questions/53049668/why-does-lua-loadstring-not-work-on-the-demo-site

@iansharkey
Copy link

The code does a loadstring or load in tiny.lua; I think it’s likely that Panic removed load() to disable runtime code loading

@Rud156
Copy link

Rud156 commented Mar 7, 2023

Yeah that might be the case. Not sure though.

@iansharkey
Copy link

Ok, first cut here: https://github.com/iansharkey/tiny-ecs

I focused on the requireXXX/rejectXXX API functions, as the filter string version would require some more heavy-duty parsing that I don't want to tackle right now, especially given that a workaround exists (ie, write the function in Lua).

I added tests, but they aren't exhaustive.

Kick the tires a bit, and if it works alright, I'll submit a PR.

@Rud156
Copy link

Rud156 commented Mar 11, 2023

It seems like it works mostly fine. I used your version in a project, and it does not seem to have caused any issues. I am mainly using requireAll though. I'll keep using it and see if it causes issues. Thanks a lot!

Also not sure if this repo is still active and accepting PRs though. Seems like this has not been updated in a couple of years

@iansharkey
Copy link

I didn't do any performance comparisons, that's a bit of a concern, but I'll poke around (the ipairs call should likely be changed).

bakpakin has contact details on their GitHub page, and seems to be active, I'll reach out and see what's the status.

@iansharkey
Copy link

#29 PR opened

@Rud156
Copy link

Rud156 commented Mar 15, 2023

Awesome!

@Rud156
Copy link

Rud156 commented Mar 31, 2023

So, I did run a performance test on your version @iansharkey. Seems like the changes don't affect performance in any way. Seemed just about the same as tiny_ecs.

@iansharkey
Copy link

Much appreciated! I’ll take a different tack and do a bytecode comparison between a moderately complex requireXXX structure and my code.

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