Log In  
Follow
Ehkber

Cartoonist and gamedev


Hey all, I managed to hack together a (sort of) storylet system today.

Here's a super pared-down example of how my storylet tables look right now:

goldcheck = {
 text="wow you sure have a lot of gold!",
 failtext="wow you sure are poor",
 condition = function() return gold > 50 end
}

But I would PREFER to have something like this:

goldcheck = {
 text="wow you sure have a lot of gold!",
 failtext="wow you sure are poor",
 condition = gold > 50
}

In the first one I can find out if the condition returns true using 'if goldcheck:condition()' but I feel like having to type all those functions annd returns and ends is going to bloat the token count pretty quickly and it's not too nice to look at.

But the problem with the comndition NOT being explicitly defined as a function is, as I'm sure you've guessed, that 'gold > 50' gets evaluated once when the table is created then 'goldcheck.condition' always returns true no matter what the 'gold' variable changes to.

Is there any way to achieve what I want?

2 comments