Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Twine 1.4.x][Sugarcube 1.x] Math.clamp not accepting $var?

ok so in my story this is one of my widgets:
<<widget modDollars>>
<<set $player.dollars to Math.clamp($player.dollars + $args[0], 0, 100000)>>
<</widget>>
with that:
<<modDollars +5>>
or
<<modDollars -15>>
works as intended, however:
<<modDollars -$item.cost>>
fails and seems to 0 out the $player.dollars $var.

am i missing something?
i have tried a few different ways to insert the $var into the widget with no luck so far.(several widgets like this and all fail when using a $var not a #)

Comments

  • The problem is that you're trying to use a parsed argument slot, but you're using an expression.

    Try something like the following:
    <<widget modDollars>>\
    <<set $player.dollars to Math.clamp($player.dollars + eval($args.full), 0, 100000)>>\
    <</widget>>
    
  • @TheMadExile thanks that fixed the problem completely.. and revealed a couple bugs that were my fault lol
Sign In or Register to comment.