ID:158847
 
Are variables global*? Can you make them global*?




*Global(not true meaning but) = for all players, and if a player logs on it is immeditely synced to them.
Global variables are variables not defined under anything. They always exist.

var
something //these are global variables.
something_else
another_thing
wowafourth_thing
In response to Kaiochao
Variables belonging to a type can also be made global:

mob
var/global/futzes = 0
In response to Garthor
Okay, but just to clarify, these vars exist on the server and not the client, right?
In response to Neos300
All variables already exist on the server, with the exception of interface settings (if you consider them "variables"). What do you mean?

If you mean "do all mobs share that same variable", then yes. IE:

mob
var/global/population = 0
New()
..()
population++
Del()
population--
..()
verb/friends()
set name = "Do I have any friends?"
if(population > 1)
usr << "You have [population-1] friends"
else
usr << "You have no friends."


Note that all subtypes of /mob will also share the same variable. So /mob/monsters will contribute to the /mob population, for example.
In response to Garthor
Ok thanks.