0 votes
by (2.4k points)
edited by

Hello there. I'm trying to do something that is probably really easy, but strangely enough, I can't manage to have it working. 

I created a widget to which I send the strength I want to be added to my $strength variable. 

 

<<nobr>> <<widget "actualizeStats">>

<<set (_forcePlus) to $args[0]>>
<<set (_forceMinus) to $args[1]>>


<<set $strength += _forcePlus>>


<</widget>> <</nobr>>

 

But when I call it, it doesn't work. It combines both $strength and _forcePlus. It additions their number, but places them side by side...

For instance 

 

<<actualizeStats "1" "0">>

 

Will give me : 

 

strength : 01

(0 + 1), $strength is set at 0 in my StoryInit passage.

Help...


Thanks a lot !!

1 Answer

0 votes
by (23.6k points)
selected by
 
Best answer

I'm not really sure why you need to transfer your arguments into temporary variables or what _forceMinus is supposed to be for. Other than that:

<<nobr>> <<widget "actualizeStats">>

<<set $strength += $args[0]>>

<</widget>> <</nobr>>

Now you can go:

<<actualizeStats 10>>
or
<<actualizeStats -10>>

 

by (2.4k points)
Damn it. So what was wrong were the "". Thanks.

That's not the entirety of the widget, which is why it seems completely pointless haha. But I didn't want to overcharge my question with useless informations.

Have a nice evening !
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...