Retrieving Level Header Lua?

I would like to use some Lua for something in some levels I plan on making, but not others. Obviously, I'd insert "Lua.SecretStuff = 1" in the Level Header of those, and then check if mapheaderinfo[gamemap].secretstuff is equal to 1. But that's where the problem is...

If I make a Lua hook doing nothing but "print(mapheaderinfo[gamemap].secretstuff", the console is spammed with 1 when in the level, and I assume the hook would be removed if I tried to play a level without Lua.SecretStuff set. But if I check "if mapheaderinfo[gamemap].secretstuff==1"... nothing ever happens, even if the following is just "print("It works!")". The console doesn't say it removed the hook, so I don't think it thinks I did anything wrong...

Can someone please give me a working example (both the Lua and Level Header) of an if check for Level Header Lua stuff? I have tried searching the message boards before posting this, but I didn't really find anything.
 
The additional parameters are always saved as strings, so try using tonumber(mapheaderinfo[gamemap].secretstuff) instead. (Or if you want to be able to evaluate built-in constants, EvalMath(mapheaderinfo[gamemap].secretstuff), but that one can throw errors so you should be careful with it.) The custom parameters might also fall into a similar problem as the rest of the level header parameters of padding the string out with \0s to a fixed length, so you might need to check for that.
 
The additional parameters are always saved as strings, so try using tonumber(mapheaderinfo[gamemap].secretstuff) instead. (Or if you want to be able to evaluate built-in constants, EvalMath(mapheaderinfo[gamemap].secretstuff), but that one can throw errors so you should be careful with it.)
I think I did try tonumber(thing), but I'm not sure. (Maybe I just remember tostring-ifying it or something for the print check thing.) I guess I'll try that again, then.

The custom parameters might also fall into a similar problem as the rest of the level header parameters of padding the string out with \0s to a fixed length, so you might need to check for that.
heavy_is_confused__by_technicallyderped-d5kxr9x.jpg


wat


Edit: Okay, tonumber-ing it seems to work... even though I could've sworn I had tried that before. Thank you.
 
Last edited:

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top