I hope you might know... How to put a pause in this loop....
Posted by Kingsmill
on Wed 28 Jun 2006 06:17 PM
— 22 posts, 89,946 views.
(This is my code don't pay attention to the first line, it's a reminder for me....)
say Remember to put a pause in every new room....
look at $n
if name($n) == Terra
south
look at $n
if name($n) != Sam
west
look at $n
if name($n) != Sam
northwest
look at $n
if name($n) != Sam
south
look at $n
if name($n) == Chris
east
look at $n
endif
endif
endif
endif
endif
I think there is an mpsleep command that will pause a script for a given number of seconds. You use it like this: "mpsleep 3" where 3 means 3 seconds, I think.
Thank you for answering me, I will try your suggestion!
The editor says it's not a valid command...
Mpsleep is not part of stock Smaug.
Building pauses into scripts suffers from the same problem at the server end as doing it in the client. It isn't that easy. You can't just do "sleep (3 secs)" because that would hang everyone on the server.
You could need to have some system whereby the server remembers where it is in the script, and when the time is up keep executing it. This is not a trivial task.
Also you have the problem of what happens if the player leaves the room. Say they enter the room and it does "west" ... wait 3 seconds ... "northwest", but in the meantime (during the 3 seconds) the player has walked east. The whole thing won't work.
Say Nick, Do you have any suggested code of some sort in some ressorce ?
Or is having a mobile be mobile just a lost cuase ?
Would mpdelay work ???
What do you mean, have "a mobile be a mobile"?
You can try using SmaugFUSS, which has this command, I believe.
If mpdelay is a command in your codebase, try it out and see what happens. But keep in mind what Nick warned about; if you depend on $n being present and in the meantime the player leaves, $n will no longer refer to the right person.
When I said a mobile being "mobile" I meant "mobile" like able to move...
Would there be a way to use rooms instead of mobile's for my code ??
I know that mobile means able to move, I just am wondering what you mean in a bigger sense, because mobiles can all already move...
And what do you mean by using rooms instead of mobiles? Sure, you can put programs onto rooms, just use rpedit instead of mpedit.
He hadn't said "mobile being a mobile", he'd said "mobile being mobile".. subtle difference, but.. anyway, I think he's trying to give a mob a specific set 'route' based on a flowchart style set of choices/presences, and he might want to take a look at the way the mayor spec_func was done for that and make one of his own for this mob instead of trying to do it via mobprog, or add in the mpsleep snippet to do what he's after. But yeah, overall, I agree, in general mobs are already quite mobile enough on their own unless you throw the sentinel flag on them.
Quote:
Say Nick, Do you have any suggested code of some sort in some ressorce ?
Well, since someone mentioned mpsleep, I did what I normally do in this situation and did a Google on that word. There are quite a few hits, the first one on this site (!) so the subject has come up before on this forum. Try that, and see what you find. There will be links to the snippet.
However I repeat my warnings about attempting this. I gather that if the player's name is not Sam you want them to go:
west
northwest
south
I can see a number of problems with this ...
- During the delay they may move, making them not go where you intended.
- Once they have moved one room (west) they are no longer in the room with the room program which makes them move, or the mob program, and thus they are out of range anyway of the script.
- Personally I would find it very annoying if a script started slowly moving me around. For example, I enter the room and it moves me west, so I think "hang on, I am looking around!" - so I got back east. Then it moves me northwest, and I start getting really annoyed. So I move back again. Then it moves me south and I start getting ready to complain to the admins that their game has a bug.
*L* While those are rather humurous scenarios, Nick, what he originally posted was that the mob that the prog is on enters the room, looks at target (how it finds this target is beyond me, perhaps it should use $r rather than $n...) and if that person is named "Sam" or "Terry" or whatever other name for that stage of the trigger, the mob then moves the direction listed below, repeat ad nausem.
Quote:
While those are rather humurous scenarios, Nick ...
Glad you like them. :)
If that is what he is trying to do, how about simply using the "on time interval" mob prog (whatever its name is, I'm not at my PC right now), and if it is in appropriate room, and sees an appropriate player, moves?
It may not be where things are leading in this thread now, but the mpsleep code is available from http://www.mudbytes.net/index.php?a=files&s=viewfile&fid=509 which includes the bugfix for it as well. I've never used it on a mob that is supposed to wander around, so the results might not be desirable, but this will provide the ability to delay commands in a prog.
I think I'm going to use if inroom($i) == room#
instead of the mobiles....
I am thinking about the following code:
look
if inroom($i) == 9902
mpdelay 3
south
look
if inroom($i) == 9904
mpdelay 3
west
look
if inroom($i) == 9903
mpdelay 3
northwest
look
if inroom($i) == 9901
mpdelay 3
south
look
if inroom($i) == 9900
mpdelay 3
east
look at $n
endif
endif
endif
endif
endif
:would it work ? If not how can I change it ?
I might need to use mpsleep instead of mpdelay, and/or put the current code in a loop....
But I'm not sure....
Would I need to mark an option that keeps her from wandering off her designated path, if so how would I do that ?
The sentinel flag prevents a mob from moving unless a program moves it around, so it sounds like that's what you want.