TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Detect just the next line

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
nauta



Joined: 28 Dec 2017
Posts: 3

PostPosted: Thu Dec 28, 2017 11:11 am    Post subject: Detect just the next line Reply with quote

Hi,

I have a small alias that I'd like to implement. What it does:

#alias {mine} {
look north;
#substitute{*%}{North: %0}
look south;
#substitute{%*}{South: %0}
look east;
#subtitute{%*]{East: %0}
look west;
#substitute{%*}{West: %0}
}

So in brief it enters a command to the mud and replaces the FIRST line of output with the same output but the word NORTH|SOUTH|WEST|EAST pre-pended to it. I must be missing something, but I can't figure out how to do this. I tried adding an #unsubstitute right after the substitute, but this didn't work. Any suggestions?
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 346

PostPosted: Thu Dec 28, 2017 4:56 pm    Post subject: Reply with quote

Hi, first of all, the code you posted has many errors (missing semicolons, a square bracket, a wrong parameter), and like this I'd be surprised if it runs at all, so I suppose you just wrote it wrong on the forum.

An example log of what your MUD does normally, and what result you want to achieve could be useful to give you some help.

Anyway, #substitute should be declared before sending the command to the MUD, else there's the risk that it will be initialized after the received lines.
A #sub, once declared, remains active until you do an #unsub , so, maybe you'll need also an #action for that.

Does your MUD show in what direction you looked ?
Or the only way is to know the command you sent ?

Because in the last case, you'll need to do an alias for "look" so to let the script knows what direction you have asked... I also think that you should not use #sub in this case, but better an #action that auto-destroys itself after use.

In this #alias there's also a condition to ignore the action if no arguments are passed to the command.

Code:

#alias look
{
    #if {"%1" != ""}
    {
        #action {%*}
        {
            #line gag;
            #echo {%1 : %%0};
            #unaction {%*}
        }
    };
    #send {look %1}
}


Example:

Code:

look north
north : You can see a room with a round table to the north.

look east
east : There's a locked door.
Back to top
View user's profile Send private message
nauta



Joined: 28 Dec 2017
Posts: 3

PostPosted: Thu Dec 28, 2017 5:30 pm    Post subject: Reply with quote

Thanks! Yes, the code I posted was just typed into the browser as a mock-up.

So, when I run your look alias individually, it works fine. But if I do:

(I rename yours: mylook)

alias lookall {
mylook west;
mylook east;
mylook north;
mylook south;
}

It does not work as expected. The output is to add 'west :' to the first line and then nothing to the subsequent lines.

To answer your question: the mud does not give reliable output from a look command, so I have to go off the look command entered. Sample output is as follows (of lookall) (the first line is the result from look west, the second from look east, and so on; there also might be lines after these).

You see nothing special.

East of here is the Main Bazaar.

To the north is the Main Bazaar.

To the south is Entrance to the Bazaar.
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 346

PostPosted: Thu Dec 28, 2017 6:25 pm    Post subject: Reply with quote

nauta wrote:
It does not work as expected. The output is to add 'west :' to the first line and then nothing to the subsequent lines.


I can understand what happens here, but I suppose that "west" is the "last" you used, not the first...
the issue is that the action is defined for all the calls so fast that the first line of the MUD arrives when the action is already at it's 4th state...

This is actually a complicated thing that can be solved with a more complex script, with flags or a "history list" (or a recursive action) to let the script manage the order of the commands received in the same order of the MUD lines received...

Or if it works maybe even a delay between the commands could do the job...

I'll think about this when I'll find more time
Back to top
View user's profile Send private message
nauta



Joined: 28 Dec 2017
Posts: 3

PostPosted: Thu Dec 28, 2017 7:01 pm    Post subject: Reply with quote

PowerGod wrote:
nauta wrote:
It does not work as expected. The output is to add 'west :' to the first line and then nothing to the subsequent lines.


I can understand what happens here, but I suppose that "west" is the "last" you used, not the first...
the issue is that the action is defined for all the calls so fast that the first line of the MUD arrives when the action is already at it's 4th state...

This is actually a complicated thing that can be solved with a more complex script, with flags or a "history list" (or a recursive action) to let the script manage the order of the commands received in the same order of the MUD lines received...

Or if it works maybe even a delay between the commands could do the job...

I'll think about this when I'll find more time


Yes, I had them switched in my test. And I'd prefer not to do a #delay between the commands.

Thanks for the help, I'll keep digging about - I've tried quite a few things (class then kill class, substitute/unsubstitute, and event) -- but I've yet to hit on success. Glad to know it isn't as simple!
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 346

PostPosted: Fri Dec 29, 2017 6:50 pm    Post subject: Reply with quote

After playing with events and many exotic tricks that came to my mind, I just came to the conclusion that there's no way to know how many lines every description can have... unless you use the prompt, because it comes at the end of every command...

So, this is what I obtained, it's not perfect as you will see in the example below, but seems to do it's job
Code:

#alias mylook
{
    #if {"%1" != ""}
    {
        #action {%*}
        {
            #line gag;
            #echo {%1 : %%0};
            #math JustLooked {$JustLooked + 1};
            #unaction {%*}
        }
    };
    #send {look %1}
}


#alias lookall
{
    #var JustLooked {1};
    #action {YOUR PROMPT HERE}
    {
        #switch {$JustLooked}
        {
            #CASE {2} {mylook east};
            #CASE {3} {mylook west};
            #CASE {4} {mylook south;#unact {YOUR PROMPT HERE}}
        }
    };
    mylook north
}


I'm not sure why, but for some reason with my MUD it does get a blank line everytime after the first exit... so in those lines the direction is on a line before the description, but for the rest seems working
Code:

lookall

north : To the north you can see a room with a round table.
There's some food on it.

east :
A dark room.

west :
Outside there are animals running everywhere.

south :
To the south you can see a little warehouse full of weapons.
The door is closed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group