ID:148903
 
how do you create a time system?
i want the entire world's time to be the same,but for some reason,i cant seem to make global vars work,in world procs >_<


if you wanna see what is says,here it is:

global/var
minutes = 0
hours = 0
days = 0
season = 0
years = 0

world/Time()
sleep(20)
global.minutes+=1
if (global.minutes == 60)
global.hours+=1
global.minutes-=1
if (global.hours == 12)
global.night == 1
else if (global.hours == 24)
global.days+=1
global.hours-=1
if (global.days == 16)
global.season+=1
global.days-=1
if (global.season == 4)
global.years+=1
global.season-=1


and the many error messages:


RPG Starter.dm:26:error:global.minutes:undefined var
RPG Starter.dm:27:error:global.minutes:undefined var
RPG Starter.dm:28:error:global.hours:undefined var
RPG Starter.dm:29:error:global.minutes:undefined var
RPG Starter.dm:30:error:global.hours:undefined var
RPG Starter.dm:31:error:global.night:undefined var
RPG Starter.dm:32:error:global.hours:undefined var
RPG Starter.dm:33:error:global.days:undefined var
RPG Starter.dm:34:error:global.hours:undefined var
RPG Starter.dm:35:error:global.days:undefined var
RPG Starter.dm:36:error:global.season:undefined var
RPG Starter.dm:37:error:global.days:undefined var
RPG Starter.dm:38:error:global.season:undefined var
RPG Starter.dm:39:error:global.years:undefined var
RPG Starter.dm:40:error:global.season:undefined var
RPG Starter.dm:24:error:Time :undefined proc
RPG Starter.dm:31:== :warning: statement has no effect
RPG Starter.dm:38:error::invalid expression
RPG Starter.dm:15:error:Time :undefined proc
RPG Starter.dm:15:error::empty type name (indentation error?)
Instead of global.var, just use var, and night == 1 does nothing, it should be night = 1
In response to Nadrew
doesnt help one bit...
when i take away all the global. stuff...
it says they're still undefined! >_<
You can't define procs for world. Try defining it as top-level instead.
In response to WizDragon
oh,i cant?
ohhh... x_x
In response to Roara
well,right now,the error's the variables wont be defined
In response to Roara
What do you mean?
In response to WizDragon
it says all the variables,used in the proc,arent defined
In response to Roara
Can you show the code you currently have?
In response to WizDragon
global/var
minutes = 0
hours = 0
days = 0
season = 0
years = 0
night = 0

proc/Time()
global.sleep(20)
global.minutes+=1
if (global.minutes == 60)
hours+=1
global.minutes-=1
if (global.hours == 16)
global.night = 1
else if (global.hours == 6)
global.night = 1
else if (global.hours == 24)
global.days+=1
global.hours-=1
if (global.days == 16)
global.season+=1
global.days-=1
if (global.season == 4)
global.years+=1
global.season-=1



(and yes,i tried removing all the 'global.'s,but it still failed)
In response to Roara
Remove all the globals. As in:
var
minutes = 0
hours = 0
etc...

proc/Time()
sleep(20)
minutes += 1
etc...

Should work fine.
In response to WizDragon
er,i have a problem,again...
how do i start the proc,once,and only once?
In response to Roara
Engage it in world/New(), like so:
world/New()
..()
spawn()Time()
In response to Roara
var
minutes = 0
hours = 0
days = 0
season = 0
years = 0
night = 0

proc/Time()
sleep(20)
minutes+=0
mincheck()


proc/mincheck()
if(minutes == 60)
hours+=1
minutes-=1
if(days == 16)
season+=1
days-=1
if(season == 4)
years+=1
season-=1
if(hours == 12)
night = 1
else
if(hours == 24)
days+=1
hours-=1

- SX