The Dink Network

Reply to Re: Dink with Lua scripting

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
January 27th 2014, 09:55 AM
peasantm.gif
shevek
Peasant They/Them Netherlands
Never be afraid to ask, but don't demand an answer 
Good to hear there's still progress.

I greatly prefer the second method

+1

I'm guessing you can input any condition in the add:choice method as a second parameter? And combinations of AND, OR, NOT?

Yes, BUT... it's a bit more confusing than it seems.

What you see there is a Lua function call. The expression with the and and or parts is evaluated by Lua and therefore can be as complex as Lua allows. It is evaluated before the function is run, and the function only sees you pass in true or false.

Now here's the confusing part: if you move that statement away, the conditionals will be evaluated when it is defined, not when it is shown. So if you define your choice menu in main(), it will only show those choices if the condition was true at that point, not if it has become true since then.

In fact, I don't really see a reason for supporting that argument. Having conditionals is useful in DinkC, because it is so limited. But in Lua, you can just use if cow > 1 then choice2 = choice_menu:add_choice("Choice 2") end, which is more clear, because it doesn't suggest that the the condition is evaluated later. What you may want to support, however, is giving it a special color.

would it be possible to (on game save) also save the variables usd in LUA

Sounds like a nice feature, but I wouldn't do it yet; first make the thing work.

There is a workaround though. You can request the character codes of a string from lua. You can store these in things that are in the save file, such as a series of editor_frames in a dedicated screen.

encrypted file

Why? If you're trying to prevent cheating, give it up. Players will cheat anyway. Besides, the engine must be able to decrypt the file, which means that the player, who has the engine, has everything they need to decrypt it as well. It's a lost battle. IMO if texts are saved, it should be done in a file that is as readable as possible. That makes debugging vastly easier.