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).
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 ...)
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)
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)
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;
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.
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.
@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.
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.
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.
@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
...
@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 ?
Lua is compatible with any C or C++ compiler that supports standard C. The normal g++ compiler is one such.
Hopefully it goes without saying you need Lua installed. It sounds like it might not have found the lua header files (like lua.h).