ID:177548
 
How would I make it so when you build an object it adds 5 gold every 30 secs but cannot pass the maxgold??? When it reaches the limit it just stops until there is enough room again or the maxgold is higher...
mob
proc
gold_mine()
usr.gold += 20
usr.goldcheck()
sleep(200)
usr.gold_mine()
goldcheck()
if(usr.gold >= usr.maxgold)
usr.gold = usr.maxgold
else
..()
verb
make_mine()
new/obj/mine(usr.loc)
spawn() usr.gold_mine()
Ok, i see a problem here, you never actaully think up much code, you are always on the forums asking for a way to do something, you say you have created games but you are always asking for code, its really starting to bug me... Think before you post.
In response to Siientx
Siientx wrote:
mob
proc
gold_mine()
usr.gold += 20
usr.goldcheck()
sleep(200)
usr.gold_mine()
goldcheck()
if(usr.gold >= usr.maxgold)
usr.gold = usr.maxgold
else
..()

Bad form: These procs belong to the mob, so use src, not usr. usr will cease to be valid after the sleep.

Further bad form: Your gold_mine() proc is in an infinite recursion. The last two lines should read:
spawn(200) gold_mine()

Lummox JR
Bah, try something for yourself for once...

usr.gold = min(usr.gold+5, usr.maxgold)
In response to Garthor
Garthor wrote:
Bah, try something for yourself for once...

usr.gold = min(usr.gold+5, usr.maxgold)

Right, but remember, usr is only valid for the life of the verb. The mine needs to keep track of who created it, and give gold to them.

Lummox JR
In response to Lummox JR
I know that, but I would assume he could at least change it to fit his needs.
In response to Garthor
I always try before I ask...