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

triggering on table formatted lines

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



Joined: 11 May 2011
Posts: 5

PostPosted: Thu Oct 13, 2011 12:13 pm    Post subject: triggering on table formatted lines Reply with quote

I am trying to assign a table of results from mud to different variables and do something with them. This is for healing the group. When I type group, I want all the group members to be automatically assign to aliases, and their status all saved to some list. So if there are only 2 group members, 2 sets of aliases are created. If there are 10, then 10 sets are created.

Here is a sample output from the mud when "group" is entered.
Code:

Member Hits Move Position
-------------------------------
Bob      perfect  rested  standing
Tom      v.good  exhausted sitting

400H 120V 1001X 10C Exits:N>


What I need is to start trigger when group is entered, and it picks each group member's info into variables or list, and assign aliases to each of the members.

The problem I have is I don't have a fix pattern to trigger the lines (since it is a table like info and all of the words are/might be different).

I would like to be able to assign the results to variables like the following
#var player1 Bob
#var player1_status perfect
#var player2_move rested
#var player2 Tom
#var player2_status v.good
#var player2_move exhausted

Once I have the infos I need, I can set aliases to keys based on their status and do whatever I need to them.

As for the code itself, I've tried a few things but it didn't work out. I know I need to set #class triggers when group is pressed, and do the matching on the table and #class kill when the prompt kicks back in. I'm having problem detecting the table correctly and splitting them into individual variables. Also the empty line before the prompt also causes a problem.

Thanks.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3274

PostPosted: Thu Oct 13, 2011 7:01 pm    Post subject: Reply with quote

Try something like:

Code:

#var groupinfo 0

#act {Member Hits Move Position}
{
  #var groupinfo 1;
}

#act {%1 %2 %3 %4}
{
  #if {$groupinfo}
  {
    #var player[%1][hits] %2;
    #var player[%1][move] %3;
    #var player[%1][pos] %4;
  }
}

#act {^$}
{
  #var groupinfo 0
}


To see Bob's health use: #showme $player[Bob][hits]

You can load and unload it using a class if you don't want to keep it in memory.
Back to top
View user's profile Send private message Send e-mail
gulca



Joined: 11 May 2011
Posts: 5

PostPosted: Thu Oct 13, 2011 11:47 pm    Post subject: Reply with quote

Hi Scandum,

Thank you for the code. I have a problem with the code.

The #action {%1 %2 %3 %4}seems to take the spaces in between literally. What if the spaces in between varies? It seems more of a tab between the words.

So the $player have the following values
player={{}{{hits}{}{move}{Bob}}}

The player's name have 2 space at the front. Bob is actually %3 instead of %1. The question now is how do I ignore white spaces/tabs in between words in my action trigger?

Thanks again for fast reply.

Edit
I found the answer using the search button on spaces and tabs.

{ +}%1 works very well.
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