Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Lua ➜ compare 2 tables?

compare 2 tables?

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


Posted by TruckDriver22   Denmark  (22 posts)  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!
Top

Posted by WillFa   USA  (525 posts)  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.

Top

Posted by TruckDriver22   Denmark  (22 posts)  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!
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.


14,879 views.

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

Go to topic:           Search the forum


[Go to top] top

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