Ok I have made some fields for my game that grow stuff, I'm not sure how to go about setting a timer? Or is it called a Sleeper()? And then after so many cycle the icon state changes to make it look like the fields are growing full of stuff... How would I go about coding something like this?
LJR
ps. Also what is a realistic time frame to put the timer on for each cycle such as a field growing stuff?
ID:150281
![]() Nov 13 2001, 10:14 pm
|
|
This is just because im slightly bored, and it gave me something to do. This is a more expandable way to do it, and allows for a bit more customization than the growing() proc. Here goes....
#define MAX_PSTATE 3 // This makes it easier to change it, incase you use it in multiple places. obj/plant var/pstate = 0 name = "Seed" var/plants[3] world/New() plants[1] = "sprout" plants[2] = "Almost-Fully-Grown-Plant" plants[3] = "Fully grown plant! Woohoo!" Cycle // New Datum var redo_time = 1 // repeats every tenth of a second by default proc Repeat() // Define a new proc called Repeat() New() // When something of the type Cycle is created ..() src.Repeat() // Call its Repeat() proc Plant_Grower redo_time = 50 // every 5 seconds Repeat() for(var/obj/plant/P in world) // for every plant in the world if(P.pstate>=MAX_PSTATE) return // If its already fully grown P.pstate += 1 // Increase its 'pstate' var P.name = plants[P.pstate] // Update its name sleep((redo_time-1)) // sleep redo_time - 1 spawn() Repeat() // now spawn() and Repeat() Note that you cant copy paste from forums, and that this wasnt tested just written off the top of my head. Good Luck, Alathon |
The procs you're looking for are sleep()and spawn(), the code you could use is: