Ehkber [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=121793 Dynamically evaluated conditions as table entries <p>Hey all, I managed to hack together a (sort of) storylet system today.</p> <p>Here's a super pared-down example of how my storylet tables look right now:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>goldcheck = { text=&quot;wow you sure have a lot of gold!&quot;, failtext=&quot;wow you sure are poor&quot;, condition = function() return gold &gt; 50 end }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>But I would PREFER to have something like this:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>goldcheck = { text=&quot;wow you sure have a lot of gold!&quot;, failtext=&quot;wow you sure are poor&quot;, condition = gold &gt; 50 }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>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.</p> <p>But the problem with the comndition NOT being explicitly defined as a function is, as I'm sure you've guessed, that 'gold &gt; 50' gets evaluated once when the table is created then 'goldcheck.condition' always returns true no matter what the 'gold' variable changes to.</p> <p>Is there any way to achieve what I want?</p> https://www.lexaloffle.com/bbs/?tid=150441 https://www.lexaloffle.com/bbs/?tid=150441 Mon, 21 Jul 2025 11:34:48 UTC