Timer event
lacorp
15 Nov 2006, 01:50I have a small question:
How do I make it so that when you use your pickaxe on an objext called ore that it waits 15 secons before giving you the item? Can I make it have a random wait time?
How do I make it so that when you use your pickaxe on an objext called ore that it waits 15 secons before giving you the item? Can I make it have a random wait time?
davidw
15 Nov 2006, 10:26Why would you want to make the player wait 15 seconds? That would just annoy people.
Alex
15 Nov 2006, 11:02DavidW raises a good point, but I'll tell you how you could do this anyway. You've got a couple of possible ways:
1. Use the "pause" command to create a script like this:
Print "Waiting 15 seconds...";
Pause for "1500" milliseconds;
Give "ore" to the player
("Pause" is in the "Other" category and "Give" is in "Inventory".)
2. Create a timer that has an interval of 15 seconds. In the timer script, give the ore item to the player, and turn off the timer. Set the timer to be initially inactive. Now, in your "use pickaxe on ore" script, activate the timer (using "Turn on a Timer" from the Timers category).
The second approach has the advantage that the player will be able to do other things while the 15 seconds elapses, though I guess the point of what you're doing is that they're supposedly using their axe for this time, so first approach may fit better. But as DavidW says it will probably be annoying.
You can use the $rand$ function to generate a random number. You can use this as the parameter of the pause command if you want to wait a random amount of time.
1. Use the "pause" command to create a script like this:
Print "Waiting 15 seconds...";
Pause for "1500" milliseconds;
Give "ore" to the player
("Pause" is in the "Other" category and "Give" is in "Inventory".)
2. Create a timer that has an interval of 15 seconds. In the timer script, give the ore item to the player, and turn off the timer. Set the timer to be initially inactive. Now, in your "use pickaxe on ore" script, activate the timer (using "Turn on a Timer" from the Timers category).
The second approach has the advantage that the player will be able to do other things while the 15 seconds elapses, though I guess the point of what you're doing is that they're supposedly using their axe for this time, so first approach may fit better. But as DavidW says it will probably be annoying.
You can use the $rand$ function to generate a random number. You can use this as the parameter of the pause command if you want to wait a random amount of time.
Elexxorine
15 Nov 2006, 14:28But you can't use the first one in multiplayer games. You really need a way to do it multiplayer games Alex, but not for players as a whole, rather make it ignore certain player's commands for a set time.
davidw
15 Nov 2006, 15:19Has anyone ever written a multiplayer game?
I think Im Dead
15 Nov 2006, 16:21Everyone's asking why he'd want to do this is catching me off guard, it's called round time and has been used in text games forever.
It's a bit complicated for a single player game, but is the way to go for multiplayer ones though, I'd suggest making a "tick". Just a timer with a length of 1 second, which on every time it's run, checks if the player has a property called RT greather than zero, if it does decrease it by 1, if not do nothing.
This way, if your player falls down and has to struggle to stand up, RT of 2 seconds, or the player mines some ore, mining ain't easy... RT of 15 seconds.
Then before commands like moving or mining any more, you just check if the player has a RT of 0, if so go ahead, if not "You can't do that for another x seconds"
It's a bit complicated for a single player game, but is the way to go for multiplayer ones though, I'd suggest making a "tick". Just a timer with a length of 1 second, which on every time it's run, checks if the player has a property called RT greather than zero, if it does decrease it by 1, if not do nothing.
This way, if your player falls down and has to struggle to stand up, RT of 2 seconds, or the player mines some ore, mining ain't easy... RT of 15 seconds.
Then before commands like moving or mining any more, you just check if the player has a RT of 0, if so go ahead, if not "You can't do that for another x seconds"
davidw
15 Nov 2006, 18:45I think Im Dead wrote:Everyone's asking why he'd want to do this is catching me off guard, it's called round time and has been used in text games forever.
Really? Speaking as someone who has been playing text games for over 20 years, this is the first time I've even heard of the phrase.
Freak
15 Nov 2006, 18:53Alex wrote:The second approach has the advantage that the player will be able to do other things while the 15 seconds elapses, though I guess the point of what you're doing is that they're supposedly using their axe for this time, so first approach may fit better.
Especially since they might use this time to do something like drop the axe and leave the mine.
Elexxorine
16 Nov 2006, 11:07davidw wrote:Has anyone ever written a multiplayer game?
Me? Remeber HavenHold? I know I haven't mentioned it lately but I'm still working on it.
davidw
16 Nov 2006, 13:39By "has anyone ever written a multiplayer game" I meant in the sense of "has anyone ever finished writing a multiplayer game". Yes, I remember Havenhold. I suspect it's got the same chances of being finished as Mystic Hour Of Midnight
Elexxorine
16 Nov 2006, 13:56They're the same game, I renamed MHM to HavenHold when I changed it from fantasy to sci-fi. Though with all the updates to the system of HavenHold and such like you could consider it a different game, but not really. The alpha of HavenHold would have could at at the start of this month if my brother hadn't deleted all the work I'd done on it over my half-term, so it isn't one of those 'slowly fade out of existance and never be talked about' games, I am going to finish it and I'm trying my best to do what I can while I have no computer of my own so that there may be a release in the new year.