Reply to Re: Dink with Lua scripting
If you don't have an account, just leave the password field blank.
That is correct, Kyle, choice menu conditionals can be any combination of valid boolean expressions, including and, or and not. And shevek is also correct in that conditionals are evaluated upon definition, and not when the choice menu is shown. However, there's another feature of the Lua choice menu conditionals that I forgot to mention: They can be functions which return true or false. What does that mean? If you wanted at-time-of-choice-menu evaluation instead, you could replace my example with this:
Now, you have a functionality that more closely mimics DinkC's behavior. But wait. That there is a full fledged function. You could do almost ANYTHING in there to decide whether a choice menu is shown or not. Shevek is also correct that many of the limitations of DinkC are gone, making some parts of this unnecessary, but I'm going to leave it in for compatibility's sake. I am planning to mention in the documentation that doing conditionals the way you're used to in DinkC will in fact evaluate them then and there, and show the example of the function for getting just-in-time evaluation.
Any features that are additional to existing DinkC features will have to wait until after my initial release. Saving Lua variables is on the list of post-release plans.
local choice_menu = dink.create_choice_menu() local choice1 = choice_menu:add_choice("Choice 1") local choice2 = choice_menu:add_choice("Choice 2", function() return global.cow > 1 and global.sheep < 5 end) local choice3 = choice_menu:add_choice("Choice 3") local choice_result = choice_menu: show() if choice_result == choice1 then -- Do "Choice 1" stuff elseif choice_result == choice2 then -- etc. end
Now, you have a functionality that more closely mimics DinkC's behavior. But wait. That there is a full fledged function. You could do almost ANYTHING in there to decide whether a choice menu is shown or not. Shevek is also correct that many of the limitations of DinkC are gone, making some parts of this unnecessary, but I'm going to leave it in for compatibility's sake. I am planning to mention in the documentation that doing conditionals the way you're used to in DinkC will in fact evaluate them then and there, and show the example of the function for getting just-in-time evaluation.
Any features that are additional to existing DinkC features will have to wait until after my initial release. Saving Lua variables is on the list of post-release plans.