Howdy, Stranger!

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

A Little Trouble With SugarCube Widgets

So here is a little bit of code I'm using in my Widget.

<<if $Player.Thirst gte 0 and $Player.Thirst lt 25>>
<<set $Player.Health = Math.clamp($Player.Health + random(5, 10), 0, 100)>>
<<elseif $Player.Thirst gte 25 and $Player.Thirst lt 50>>
<<set $Player.Health = Math.clamp($Player.Health + 5, 0, 100)>>

I get the "error set: unexpected token" when running it.

I think it's quite obvious that the error has to do with the random(0,10) within the Math.clamp. So my question is, what is the proper syntax to use, if it is even possible?

Thanks In Advance.

Comments

  • It's not the utility function random(), as you're using it correctly.  And if it was, the error message wouldn't be about an "unexpected token".

    The unexpected token error is essentially a syntax error.  You have something within one of the &lt;&lt;set&gt;&gt; macros that shouldn't be there.  I don't see any obvious problems in what you've posted.  What does the rest of the widget look like?

    PS: The little icon on the post editing bar that looks like a hash/pound symbol (#) is the code block.  Please use it when posting chunks of code.
Sign In or Register to comment.