ID:758027
 
Keywords: worldvar
(See the best response by Robertbanks2.)
Problem description:
I'm trying to set up a system in my code where it randomly spawns several different ore types on the map, a specific number of each, and once one has been mined another would spawn. My idea for implimentation of this was to make a world var representing each type then setting up a world proc that spawned the ores and repeatedly checked after to see if anyone had mined an ore(which would decriment the number of ores represented by a world var) and replace the ore and incriment the value again, but my problem is I can't figure out how to define a new world var, everytime I try it says "variable declaration not allowed here" I've tried searching all over the place for how to define a new world var but I've come up short, is this possible? If so how?
Best response
http://www.byond.com/docs/ref/info.html#/var/global

You need a global var, not a "world var."

You could always just make it spawn a new ore at a random spot every time someone mines one, like this:

mob/verb/Mine()
minestuffhere
SpawnOre()
ohhhh! -facepalm- thanks a thousand xD
You may want to try something like this.

var
gold_ore_amount = 10

mob/proc
get(item/i)
i.get(src)

obj/gold_ore
var
respawn_delay = 200 // 20 seconds
proc/get(mob/m)
// add it to their inventory or whatever
respawn_ore(src, respawn_delay)

proc
respawn_ore(obj/o, delay)
spawn(delay)
// find the amount of ore in the world and compare it to gold_ore_amount
// create a new ore wherever you want if it needs it


That's just a little example of how you may want to set it up.
more or less was going to have them all under one respawn proc and yatta yatta, I can handle it from here I was just stuck on trying to make them world vars instead of global. doh!