Twine Version: 2.3.16
SugarCube Version: 2.36.1
Hi Guys,
I hope one of you might be able to help out, because I’ve hit a little speed bump: I am working on a number of assets for a game, among them a few widgets to handle things like experience points, skill- and attribute- increases, and weekly accumulated work-hours. The first couple works like a charm. I can increase the protagonist’s skills and attributes, and my widgets tracks the progression perfectly. The one I designed to track the protagonist’s dayjob and accumulated hours, however, is causing me some grief. I have designed it in exactly the same manner as they previous ones, but with other story variables of course. All my variables are defined in the StoryInit passage, and I call the widget normally with it’s name but then I get an error saying that Twine can’t find a closing tag for the macro.
My first version of this widget looked like this:
<<widget "work">><<silently>>
<<set $Wage += ($CharismaTotal + $PhysiqueBase) * $Bartend>><<set $Bartend to 0>>
<<set $Wage += ($PhysiqueTotal + $IntelligenceBase) * $Restock>><<set $Restock to 0>>
<<set $Wage += ($WillpowerTotal + $CharismaBase) * $OpenClose>><<set $OpenClose to 0>>
<<set $Cash to $Wage + 50>><<set $Wage to 0>>
<</silently>><</widget>>
It was simple and straight forward, or so I thought. Track a variety of work-related tasks, calculate wage based on composite attributes and attribute components, and adding wage to cash before resetting everything for the coming week. It has since gone through a couple of iterations in an attempt to solve the issue myself. The current state looks like this:
<<widget "work">><<silently>>
<<if $Bartend gte 1>><<set $Wage += $Bartend * ($CharismaTotal + $PhysiqueBase)>><<set $Bartend to 0>><</if>>
<<if $Restock gte 1>><<set $Wage += $Restock * ($PhysiqueTotal + $IntelligenceBase)>><<set $Restock to 0>><</if>>
<<if $OpenClose gte 1>><<set $Wage += $OpenClose * ($WillpowerTotal + $CharismaBase)>><<set $OpenClose to 0>><</if>>
<<if $Wage gte 1>><<set $Cash to $Cash + ($Wage + 50)>><<set $Wage to 0>><</if>>
<</silently>><</widget>>
I have now included a lot of if-statements to ensure that it only calculates what it needs to before resetting my parameters, and I have switched around in the math a little. But, still, no cigar. Including a closing tag for my widget macro in the passage where I call it can silence the error message, but that hasn’t been necessary for my other widgets, and it still doesn’t add any money. Any help is greatly appreciated…