ID:169766
 
mob
proc
Daytime()
if(global.host == "Strawgate")
spawn()Food()
sleep(15)
global.Minute += 1
global.Hour += round(global.Minute /60)
global.Minute -= round(global.Minute/60)*59
global.Hour -= round(global.Day /12)*11
global.Day += round(global.Hour/24)
global.Month += round(global.Day/30)
global.Day -= round(global.Hour/25)*24
global.Month -= round(global.Day/30)*29
if(global.Hour >= 11)
if(global.AP == "PM")
global.AP = "AM"
global.Hour = 1
spawn()EndofDay()
else
global.AP = "PM"
global.Hour = 1
if(global.host == "Strawgate")
spawn()Daytime()
if(global.host == 0)
spawn()Food()

Can anyone help me figure out if any part of that should be changed to help fix it?


My old code used many if suquences, which caused great lag...
This doesn't strike me so much as optimizing as a matter of making it work in the first place. As far as optimization is concerned, though, a constantly running proc is obviously a poor substitute for simply checking world.time as needed.

I'm not really sure what statements like this are supposed to do:
global.Minute -= round(global.Minute/60)*59


This crap is all over that code, with round(a/b)*(b-1), which makes absolutely no sense. It strikes me that the % operator is called for here.

In any case it's all moot, since as I said you're a lot better off checking world.time as needed and just outputting the offset time based on that. A loop constantly running for a clock is really not a good idea.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
This doesn't strike me so much as optimizing as a matter of making it work in the first place. As far as optimization is concerned, though, a constantly running proc is obviously a poor substitute for simply checking world.time as needed.

I'm not really sure what statements like this are supposed to do:
global.Minute -= round(global.Minute/60)*59

This crap is all over that code, with round(a/b)*(b-1), which makes absolutely no sense. It strikes me that the % operator is called for here.

In any case it's all moot, since as I said you're a lot better off checking world.time as needed and just outputting the offset time based on that. A loop constantly running for a clock is really not a good idea.

Lummox JR

I dont want it to use the world time, I want it much faster.


global.Minute -= round(global.Minute/60)*59

The sequence before it, adds 1 hour.

That rounds down, so unless its 60, it rounds to 1 then Multiplys by 59 then subtracts from 60, leaving with 1 minute left.
In response to Strawgate
Strawgate wrote:
I dont want it to use the world time, I want it much faster.

Uh, using a constantly looping proc to constantly update the time of day makes zero sense on those grounds.

global.Minute -= round(global.Minute/60)*59

The sequence before it, adds 1 hour.

That rounds down, so unless its 60, it rounds to 1 then Multiplys by 59 then subtracts from 60, leaving with 1 minute left.

Which is wrong, since it should be resetting to 0. The round(a/b)*(b-1) stuff is totally incorrect; it should all be round(a/b)*b. Or, instead of using -= there with a complicated formula, you should use the % operator which is infinitely better.

Lummox JR