SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 03-21-2015   #1
Zwip-Zwap Zapony
 
Zwip-Zwap Zapony's Avatar
Default 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.
Zwip-Zwap Zapony is offline   Reply With Quote
Old 03-21-2015   #2
fickleheart
ms reflec beat stan
 
fickleheart's Avatar
Default

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.
__________________
Quote:
Originally Posted by Arf View Post
Stop trying to make slopes, guys.
fickleheart is offline   Reply With Quote
Old 03-21-2015   #3
Zwip-Zwap Zapony
 
Zwip-Zwap Zapony's Avatar
Default

Quote:
Originally Posted by RedEnchilada View Post
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.

Quote:
Originally Posted by RedEnchilada View Post
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.
Spoiler: Image


wat



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

Last edited by Zwip-Zwap Zapony; 03-21-2015 at 06:36 PM.
Zwip-Zwap Zapony is offline   Reply With Quote
Old 05-26-2020   #4
carlrev
The living revolution
 
carlrev's Avatar
Default

Can you make an example of a lua string to not execute a command in a specific map?
__________________
Greetings from 2391!
carlrev is offline   Reply With Quote
Old 05-26-2020   #5
Zwip-Zwap Zapony
 
Zwip-Zwap Zapony's Avatar
Default

Quote:
Originally Posted by carlrev View Post
Can you make an example of a lua string to not execute a command in a specific map?
Yes... but fickleheart already helped me solve this more than 5 years ago.
Zwip-Zwap Zapony is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.