Hello, everybody! So I have this widget, which helps an NPC decide what to do.
<<widget "npcdecision">>
<<set _d100 to random (1,100)>>
<<if _d100 gte 66>>
<<set $npcDecision to "npc_attack">>
<<elseif _d100 gte 33>>
<<set $npcDecision to "npc_defend">>
<<else>>
<<set $npcDecision to "npc_surrender">>
<</widget>>
I'd now like to run another widget, named either npc_attack, npc_defend, or npc_surrender as appropriate.
I know I could achieve this using <<if>> statements like so:
<<if $npcDecision eq "npc_attack">>
<<npc_attack>>
<<elseif $npcDecision eq "npc_defend">>
<<npc_defend>>
<<elseif $npcDecision eq "npc_surrender">>
<<npc_surrender>>
<</if>>
However, this seems inelegant. It would be really good if I could just make the game run the widget with the same name as $npcDecision. However, when I tried:
<<$npcDecision>>
It just prints the value of $npcDecision enclosed in << >>s.
Is it possible to do what I want, or should I just stick to the <<if>> statements?