[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Using trigger to make table and sub tables

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Using trigger to make table and sub tables
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Hoplo   (16 posts)  [Biography] bio
Date Sun 12 Aug 2012 03:53 AM (UTC)  quote  ]
Message
Thank you :) I have seen those, still working around them.

I remembered something someone mentioned in some other post where %0 is the whole string captured, and this is what i was looking for.

Thanks for the quick reply, and all the help from the forums.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 12 Aug 2012 03:19 AM (UTC)  quote  ]
Message
See here: http://www.gammon.com.au/mushclient/mw_text.htm

Near the bottom are examples of displaying lines of text with small helper functions.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Sat 11 Aug 2012 10:41 PM (UTC)  quote  ]

Amended on Sun 12 Aug 2012 03:18 AM (UTC) by Nick Gammon

Message
Hello. I have been using one of the examples Fiendish gave:
groupArr["%1"] = {"%2","%3","%4","%5","%6","%7","%8","%9","%10","%11"}

It works great for all the stuff I wanted this table to do. However, I was wondering if there was a way send this table information to a mini-window. I am not looking for anything too fancy. I have watched and read the examples like http://gammon.com.au/forum/bbshowpost.php?id=9965, but all of these examples use a wait to capture the information as a single line. I am not really sure how to insert something like the above table into the windowtext.

Something simple like,

WindowCreate (win, 0, 0, 105, 15, 8, 0, ColourNameToRGB("yellow"));
WindowFont (win, "f", "Lucida Console", 9, true, false, false, false, 1, 0);
WindowText (win, font, groupArr, 5, 2, 0, 0, ColourNameToRGB ("black"), false);
WindowShow (win, true);
[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Tue 24 Jul 2012 05:09 PM (UTC)  quote  ]
Message
for k,v in pairs(groupArr) do
if v.here == "Y" and v.mv == "fatigue" then
if k == "%1" then
print(k)
end
end
end

this is a test alias to see if this all did what I wanted to do. The goal is to eventually make a trigger that checks the group and then casts spells like fly if someone needs it. In this case I am checking both their movement and if they are in the room so i can refresh their movement. It seems to work. If anyone has a better suggestion i would love to hear it because I am still fairly new at this.
Thanks for all the help so far, these forums have helped a ton
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 24 Jul 2012 12:35 PM (UTC)  quote  ]
Message
Hoplo said:

Ok I think I am starting to get it. I tried this:

print (table.foreach (groupArr,
function (k, v)
if v.here == "Y" then
return k
end -- if
end -- function
))

and with the information pasted from the last message I got a return of:

Bob

Which is correct, as he was the only one "here".

BUT, if i have both groupies in the same room and both are "here" it only returns the top one.


table.foreach is deprecated anyway. Use

for k,v in pairs(groupArr) do
   if v.here == "Y" then
       print(k)
   end
end

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 24 Jul 2012 12:29 PM (UTC)  quote  ]

Amended on Tue 24 Jul 2012 12:36 PM (UTC) by Fiendish

Message
Hoplo said:
the "mem" and "light" entries in each are not correct, as the mud shows this:
Ahhh... Oops.
That's because %10 and %11 are getting parsed as "%1" and 1. and "%1" and 0. My mistake.
Use %<10> and %<11> instead.

Scroll down to 'Using the wildcard in the "send" box ...' on http://www.gammon.com.au/scripts/doc.php?general=triggers


Quote:

Also, just to make sure... I can access these new variables globally by something like: groupArr.rob.hit ??
Globally? No. Inside that script, yes. If you want to access them globally you'll need to read about serializing lua tables to mushclient variables.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Tue 24 Jul 2012 05:19 AM (UTC)  quote  ]

Amended on Tue 24 Jul 2012 05:23 AM (UTC) by Hoplo

Message
Ok I think I am starting to get it. I tried this:

print (table.foreach (groupArr,
function (k, v)
if v.here == "Y" then
return k
end -- if
end -- function
))

and with the information pasted from the last message I got a return of:

Bob

Which is correct, as he was the only one "here".

BUT, if i have both groupies in the same room and both are "here" it only returns the top one.
[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Tue 24 Jul 2012 04:48 AM (UTC)  quote  ]

Amended on Tue 24 Jul 2012 04:55 AM (UTC) by Hoplo

Message
groupArr["%1"] = { hits = "%2", mv = "%3", pos = "%4", fly = "%5", inv = "%6", wb = "%7", imt = "%8", here = "%9", light = "%10", mem = "%11"}

Thanks, this is what I was thinking of, and so much simpler then I thought it would be.

to test the information in the new groupArr table I used:
require "tprint"
tprint (groupArr)

this gave a slight problem and I am not sure why.

*not sure why this is not spacing correctly...
"Silbo":
"mem"="Silbo1"
"light"="Silbo0"
"inv"="N"
"here"="N"
"wb"="N"
"imt"="Y"
"fly"="N"
"pos"="sitting"
"mv"="rested"
"hits"="perfect"
"Bob":
"mem"="Bob1"
"light"="Bob0"
"inv"="N"
"here"="Y"
"wb"="N"
"imt"="Y"
"fly"="Y"
"pos"="resting"
"mv"="rested"
"hits"="perfect"

the "mem" and "light" entries in each are not correct, as the mud shows this:

Rob perfect rested resting Y N N Y Y 1 1
Bob perfect rested standing N N N Y Y 0 0

Also, just to make sure... I can access these new variables globally by something like: groupArr.rob.hit ??
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 24 Jul 2012 02:48 AM (UTC)  quote  ]
Message
try

table.insert(groupArr, {"%1","%2","%3","%4","%5","%6","%7","%8","%9","%10","%11"})

or even

groupArr["%1"] = {"%2","%3","%4","%5","%6","%7","%8","%9","%10","%11"}

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Mon 23 Jul 2012 06:57 PM (UTC)  quote  ]
Message
I have used this trigger to capture information, but I am not exactly sure what to do with it.

<triggers>
<trigger
enabled="y"
group="autoheal"
match="^ ([A-Za-z]+)\b\s+([A-Za-z\.]+)\b\s+([A-Za-z]+)\b\s+([A-Za-z]+)\s+([YN])\s+([YN])\s+([YN])\s+([YN])\s+([YN])\s+(\d+)\s+(\d+)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>table.insert(groupArr, ("%0"))</send>
</trigger>
</triggers>

This trigger works well for capturing the information and storing into a table (groupArr) as a single string. But, ultimately what I would like to do is form sub-tables for each character name with the information so that i can access each given information provided individually.

Example: make a trigger to check to see if Bob is flying, or sitting, or in bad condition so that i can fly whoever needs flying or heal someone who is at bad health.

[Go to top] top

Posted by Hoplo   (16 posts)  [Biography] bio
Date Mon 23 Jul 2012 06:53 PM (UTC)  quote  ]
Message
Hi, I have read through many different posts on the forums trying to figure out how to do what I want to do. This includes the nice tutorial/help on lua tables, as well as other posts asking about tables, and I still can not quite grasp all the components I need.

What I would like to do is capture a bunch if information after typing : group

example text after command:
Your group of 10 members consists of:
Member Hits Move Position Fly Inv Water iMT Here Light Mem
---------------------------------------------------------------------------------
Bob perfect rested standing Y N N N Y 0 0
Rob good rested standing Y N Y Y Y 0 0
Lob bad rested sitting Y N Y Y Y 2 0
[Go to top] 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.


1,146 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]