ID:139326
 
Code:
mob
verb
UpdateSalt()
src.SaltValue=winget(src,"Salt.Saltbar","value")
winset(src,"Salt.SaltPercent","text='[src.SaltValue]'")



mob
verb
Cook()
if(usr.SaltValue>=20)
usr<<"WATER!!WATER!!...Too"
//There is more stuff here,but its useless for this post its like a copy paste for other Ingredients.


Problem description:
This is for One Piece Pirates Galore,i'm working on Cooking and this Slider is supposed to set in % how much salt i want for ex.

now i keep geting this Runtime error,i don't want the "SaltValue" Var to be considered as a Text i need to calculate stuff....

Runtime Error:
runtime error: type mismatch: cannot compare "42.207794" to 20
proc name: Cook (/mob/verb/Cook)
usr: Kidpaddle45 (/mob/Player)
src: Kidpaddle45 (/mob/Player)
call stack:
Kidpaddle45 (/mob/Player): Cook()



The reason this isn't working is because "usr.SaltValue" is a string (or a text), not an actual integer that can be used in calculations. What you want to do is use text2num(), or just prevent usr.SaltValue from becoming a text value in the first place?
In response to Duelmaster409
I Heard about Text2 num but never knew how to use it,mind please leaving me with a small example of how it works?
Thanks.
In response to Kidpaddle45
Instead of this:
if(usr.SaltValue>=20)



Do this:


if(text2num(usr.SaltValue)>=20)

In response to Duelmaster409
Thanks,went reading it on BYOND help thingy.
Thank you for the fast replies.
In response to Duelmaster409
It would be better to put it on the line with winget:
src.SaltValue=text2num(winget(src,"Salt.Saltbar","value"))

instead of
src.SaltValue=winget(src,"Salt.Saltbar","value")

That way, src.SaltValue is always a number, and you don't need to write text2num(src.SaltValue) every time you want to use it.