Creations Favorites Medals Posts ID:162896
 ID:162896   Nov 10 2007, 9:49 am when players go to sell the ore it takes 50 ore to get 1 credit how can i make it so there is no 1.4256646 credits? rounding off?
I think there is a round proc, like

 ```mob/var credits = 0 ores = 50mob/Ore_Buyer/verb/Sell_Ores(/mob/Ore_Buyer in oview(1)) if(ores == 50) credits = round([ores]/[credits]) ```

I don't really know what you're doing, so it would help a lot if you could give a code snippet. Or if you want to just look up "round" when you press "F1" in the Dream Maker.
In response to Jman9901 (#1)
sorry,

 ``` verb/Sell_ore() set src in oview(1) if(usr.ore<=49) usr<<"You need to mine some ore first!, The smallest amount they will buy is 50" return switch(input("Would you like to sell all your ore?") in list ("Yes","No")) if("Yes") var/X = usr.ore / 50 var/Y = X * 50 usr.credit = X + usr.credit usr.ore -= Y if("No") return ```

see, user can have more then 50 ore so if he has 75 ore he would get 1.5 credits i dont want it to cash the other 25 in??? is that possible??
In response to Kylemark (#2)
 ``` verb/Sell_ore() set src in oview(1) if(usr.ore<=49) usr<<"You need to mine some ore first!, The smallest amount they will buy is 50" return switch(input("Would you like to sell all your ore?") in list ("Yes","No")) if("Yes") var/X = usr.ore / 50 var/Y = X * 50 usr.credit = round(X + usr.credit) // I think that'll work... usr.ore -= Y if("No") return ```
In response to Jman9901 (#3)
 ``` verb Sell_ore() set src in oview(1) if(usr.ore<=49) usr<<"You need to mine some ore first!, The smallest amount they will buy is 50" return switch(input("Would you like to sell 50 ore for 1 credit??") in list ("Yes","No")) if("Yes") ++usr.credit// adds one credit to the user usr.ore=max(0,usr.ore-50) // subtracts 50 ore from the user ```

There you go
In response to Axerob (#4)
Except he wants to sell as many units of 50 ore for 1 credit each, all at once. Which means two lines of code:

 ```usr.credit += round(ore/50) //add one credit per 50 units of ore, rounded downusr.ore = usr.ore%50 //set ore equal to the remainder of ore/50 ```

The % (modulo) operator is, essentially, the remainder operator. So, 75%50 = 25, 120%50 = 20, etc.