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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Complicated List/Array Insert and Remove
Complicated List/Array Insert and Remove
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Curious2
(47 posts) Bio
|
Date
| Sat 24 Jan 2009 03:19 AM (UTC) |
Message
| How could I use a table/array to keep a list of two related items. Then pass those two items to function.
Example:
function dostuff(a, b)
doA(a)
doB(b)
end
Is it possible to keep a bunch of "a and b"s in an array then use table.remove and send those two elements to the dostuff function? I also need to add new items as well with table.insert. Once the list is empty I repopulate it again.
I suppose I need to make two tables instead? I think I confused myself trying to figure out the best way to do this.
| Top |
|
Posted by
| Curious2
(47 posts) Bio
|
Date
| Reply #1 on Sat 24 Jan 2009 04:07 AM (UTC) Amended on Sat 24 Jan 2009 04:11 AM (UTC) by Curious2
|
Message
| Haha never mind. It was so easy I confused myself.
list = {
{a = "stuff", b = "morestuff"},
{a = "stuff", b = "morestuff"},
{a = "stuff", b = "morestuff"}
}
function stuff()
local temp = table.remove(list, 1)
dostuff(temp.a, temp.b)
end
function dostuff(a, b)
doA(a)
doB(b)
end | 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.
8,841 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top