Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Delay
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Mon 27 Sep 2010 12:06 PM (UTC) |
Message
| Hi all,
I'm helping a friend with his mud, based on Star Wars and i'm stuck with a simple thing. I've created newbiehelper npc, who give a lot of informations when somebody say help. Problem is : they're just saying a bunch of text in one shot, and i would like to add some pause, in order to allow ppl to read the help little by little (and it's aweful in the android version, where ppl have a small screen)
I don't really understand the whole WAIT_STATE or add_timer I found in the code, I just want that between each do_tell of my npc, they wait few seconds (without making the whole game lagging, of course).
Thanks by advance for your help
(and sorry for my english)
Aiseant | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #1 on Mon 27 Sep 2010 03:37 PM (UTC) |
Message
| Look into mpdelay. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #2 on Mon 27 Sep 2010 06:51 PM (UTC) Amended on Mon 27 Sep 2010 06:53 PM (UTC) by Aiseant
|
Message
| I have absolutely no trace of mpdelay in the code.
I assume this is a command you have to use when you're programming inside the game, isn't it ?
I would rather do something in the code, if possible
(once, i made a wonderful sign, very useful, and few hours after, it just went flushed in the update of the server... was very sad ...) | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Mon 27 Sep 2010 09:05 PM (UTC) |
Message
| Basically you have to send the first line, and then set some sort of flag in the character entry (or descriptor) for that character. Then in the Update loop (called a couple of times a second) you wait for x pulses to pass, then when that happens you send the next line of the message, and so on, until the message has been completely sent.
So you need something like:
- A flag to indicate you are doing this
- A count of pulses per message (eg. it might be 10 for a 5-second pause) which gets decremented each pulse
- A counter indicating which line of your multi-line message to send (each time you send a message you add 1 to this counter)
- The message itself
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #4 on Tue 28 Sep 2010 07:06 AM (UTC) Amended on Tue 28 Sep 2010 08:15 AM (UTC) by Aiseant
|
Message
| Okay. But if I understood well, this is what WAIT_STATE is doing, isn't it ?
I tried with WAIT_STATE(npc,PULSE_TICK), but this seems to work only on character, not on mobs.
I also tried with a send_to_char instead of do_tell, and it seems that it ignores it : the char got the whole things displayed in one shot and is stuck after (stuck for the delay time I wanted between the send_to_char) | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #5 on Tue 28 Sep 2010 02:01 PM (UTC) |
Message
| You may need to get the code for mpdelay from a newer Smaug then.
http://ftp.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6847&page=1
And no, WAIT_STATE only makes a players commands lagged. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #6 on Tue 28 Sep 2010 02:05 PM (UTC) Amended on Tue 28 Sep 2010 02:36 PM (UTC) by Aiseant
|
Message
| Ok, i've found this part of code. But the only things it seems to do is check some things and then WAIT_STATE ... (smaugfuss 1.9)
Anihow, WAIT_STATE is defined with a '->wait' which doesn't exist in mob struct
I'm really surprised not to find what i'm looking for, since it seems that indispensable for me. I mean, at the first connexion of a player, didn't you display lines of introduction with some delay to allow him to read ?
I quote :
void do_mpdelay( CHAR_DATA * ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
int delay;
if( !IS_NPC( ch ) || ch->desc || IS_AFFECTED( ch, AFF_CHARM ) )
{
send_to_char( "Huh?\r\n", ch );
return;
}
argument = one_argument( argument, arg );
if( !*arg )
{
send_to_char( "Delay for how many rounds?n\r", ch );
progbug( "Mpdelay: no duration specified", ch );
return;
}
if( !( victim = get_char_room( ch, arg ) ) )
{
send_to_char( "They aren't here.\r\n", ch );
progbug( "Mpdelay: target not in room", ch );
return;
}
if( IS_IMMORTAL( victim ) )
{
send_to_char( "Not against immortals.\r\n", ch );
progbug( "Mpdelay: target is immortal", ch );
return;
}
argument = one_argument( argument, arg );
if( !*arg || !is_number( arg ) )
{
send_to_char( "Delay them for how many rounds?\r\n", ch );
progbug( "Mpdelay: invalid (nonexistant?) argument", ch );
return;
}
delay = atoi( arg );
if( delay < 1 || delay > 30 )
{
send_to_char( "Argument out of range.\r\n", ch );
progbug( "Mpdelay: argument out of range (1 to 30)", ch );
return;
}
WAIT_STATE( victim, delay * PULSE_VIOLENCE );
send_to_char( "Mpdelay applied.\r\n", ch );
return;
} | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #7 on Tue 28 Sep 2010 02:36 PM (UTC) |
Message
| My bad, mpdelay is WAIT_STATE you're right.
You want mpsleep.
http://www.mudbytes.net/file-509 |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #8 on Tue 28 Sep 2010 09:22 PM (UTC) |
Message
|
Aiseant said:
I'm really surprised not to find what i'm looking for, since it seems that indispensable for me. I mean, at the first connexion of a player, didn't you display lines of introduction with some delay to allow him to read ?
Some MUDs just bang out a lot of text and then let the player read it in their client, and then press <return> to start playing.
You might find this useful:
http://www.gammon.com.au/forum/bbshowpost.php?id=8000
In that I describe adding Lua to Smaug coding - this adds heaps of flexibility. In another nearby post I describe an entire quest system using Lua where you have a quest file with objectives etc.
The problem with delays BTW is that they might to out of context.
For example, if your introductory text says "and now go East to start playing" and if the player *already* has gone East, then this is misleading or wrong.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #9 on Wed 29 Sep 2010 07:32 AM (UTC) |
Message
| Hi,
many thanks to both of you
@zeno : i would try mpsleep, i like the idea of this global watcher
@gammon : thanks for the link. I saw this lua things a lot when i was looking for solutions to my problems, I didn't know what it was. I'll also try this, if my friend owning the mud agrees.
Is there somewhere in the forum i would ask question about it ? The thread of your link for instance ?
About timer and context, I fully agree. This is why I would put checking everywhere. In fact, when you want your mud interacting with players, you spend your life checking that those stupid humans don't do something irrelevant when you don't expect it.
Anyway, I'm still surprised that WAIT_STATE for a ch don't apply to send_to_char. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #10 on Wed 29 Sep 2010 07:43 AM (UTC) |
Message
|
Aiseant said:
Is there somewhere in the forum i would ask question about it ? The thread of your link for instance ?
About timer and context, I fully agree.
You are welcome to ask about it. Probably start a new thread in the Smaug -> Lua part (where that link was). That thread was already 6 pages, and new questions can get lost a bit in the old stuff.
The nice thing about the Lua code was it was interactive (for example the stuff about quests). So for example I had a callback that got called every minute or so (you could obviously change that to more often). Then in that callback you could remember if you were trying to send stuff to the player (keep a flag in the Lua script space), and then see if what you were going to say was still relevant.
It probably takes a bit of wading through to read it all, but I think if you use it you will get a better end result. For example, Aardwolf have converted to scripting with Lua (not using my exact code, but the concept) and they have said they are very pleased with the result.
Once you add in the Lua "hooks" then you just add more stuff in Lua scripting, which means you don't need to recompile the MUD all the time. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #11 on Wed 29 Sep 2010 09:40 AM (UTC) Amended on Wed 29 Sep 2010 12:10 PM (UTC) by Aiseant
|
Message
| Aniway, the mpsleep snippet is for ingame coding ... I will first have to cheat a little to use it in file coding.
And this goes wrong.
If I try to call mprog_driver ( "mpsleep", locut, NULL ,NULL, NULL, 1);
I got a wonderful sigsevg error :
Program received signal SIGSEGV, Segmentation fault.
0x000000000049379a in mprog_driver (com_list=0x597662 "mpsleep",
mob=0x19f0610, actor=0x0, obj=0x0, vo=0x0, single_step=1 '\001')
at mud_prog.c:1475
1475 mpsleep->com_list = STRALLOC(command_list);
Which is logic since mpsleep isn't created, in fact.
If I add just a CREATE(mpsleep etc right before, no more sigsevg, but also no more delay in the game.
| Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #12 on Wed 29 Sep 2010 12:09 PM (UTC) Amended on Wed 29 Sep 2010 12:16 PM (UTC) by Aiseant
|
Message
| @gammon : is lua compatible with all versions of SMAUG ?
I've only got a error: expected specifier-qualifier-list before lua_State
I put the lua_scripting.c and lua_bits.c on the makefile, with the -llua. Anything else ?
(the mud is SWR2.0 based, I think it's smaug1.0)
@zeno :I think I give up. I'll try ingame.
This way, can you help me to do something like :
if ch says help or if (ch->lesson&BV00) !=BV00)
{
tell help1 to ch
WAIT
if ch still here
tell help2 to ch
WAIT
if ch still here
tell help3 to ch
WAIT
...
mob bows and goodbyes
ch->lesson= ch->lesson|BV00;
}
where lesson is a field of the data_char struct ?
| Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #13 on Wed 29 Sep 2010 02:32 PM (UTC) |
Message
| If you are trying to do a delay in the code, look into how the dig command uses a delay. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Aiseant
(33 posts) Bio
|
Date
| Reply #14 on Wed 29 Sep 2010 02:47 PM (UTC) |
Message
| In this case, it's done with add_timer, which works only on char and not on mob. And in char, it doesn't delay the send_to_char | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
54,150 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top