ID:162896   Nov 10 2007, 6: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?
 <-> Nov 10 2007, 7:15 am 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.
 <-> Nov 10 2007, 8:12 am In response to Jman9901 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??
 <-> Nov 10 2007, 8:28 am In response to Kylemark ``` 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 ```
 <-> Nov 10 2007, 8:57 am In response to Jman9901 ``` 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
 <-> Nov 11 2007, 12:45 am In response to Axerob 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.