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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  compare 2 tables?

compare 2 tables?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by TruckDriver22   Denmark  (22 posts)  [Biography] bio
Date Thu 12 Feb 2009 06:52 PM (UTC)
Message
i have 2 triggers and i want the first trigger to capture targets for the 2nd trigger.
why dont it work?


trigger one!
rebash = rebash or {}
rebash ["%1"] = {"%1"}

trigger two!
stands = stands or {}
stands ["%1"] = "%1"
rebash = rebash {}
for sequence, priority in ipairs (rebash) do
for i, v in pairs (stands) do
if v == priority then
Send ("bash " .. v)
end
end
break
end
rebash = {}
stands = {}

Click bang... GAME OVER!
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #1 on Thu 12 Feb 2009 08:02 PM (UTC)

Amended on Thu 12 Feb 2009 10:05 PM (UTC) by WillFa

Message
ipairs works on contiguously numbered indices, not keys. ipairs { 1,2,3, [5]= false, foo=true} loops thru [1]=1,[2]=2,[3]=3; but doesn't touch foo or [5] (since there's no 4 to keep the sequence intact).

So your ipairs(rebash) never iterates over anything.

You can fix that with

rebash = rebash or {}
rebash[#rebash+1] = "%1"

then 1=orc, 2=rat, 3=foo, which is probably what you want.

[Go to top] top

Posted by TruckDriver22   Denmark  (22 posts)  [Biography] bio
Date Reply #2 on Wed 18 Feb 2009 01:29 AM (UTC)
Message
Thanks i found a much easier way to do what i needed it to do

Click bang... GAME OVER!
[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.


13,791 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]