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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ create tables automatically for each character

create tables automatically for each character

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


Posted by Oriol   (31 posts)  Bio
Date Fri 10 Jul 2009 10:04 AM (UTC)
Message
Hello,
I'm tyring to do something here.
Say I am in a group inside the mud and want to store different information for each of the characters in a group.
For example, Say the characters Smith and Dragon are grouped.
The mud would show something like dragon 540/540hp 404/404 mana 400/400mv
Say I want to store and then retrieve the information with something like Dragon.hp, Smith.mana etc, from inside a script.

Also to find certain information in a table I.e: I have a history plugin that save all the messages you received in a channel and I want to see all the messages with a certain word in them.
How would I go about doing that?
Thanks
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 10 Jul 2009 10:01 PM (UTC)
Message
Have you read this post?

http://www.gammon.com.au/forum/?id=4903

That shows a similar idea - storing different things like hp and mana for different mobs.


As for finding messages which match a string, let's say you put them all into a simple table (ie. keyed by number). Then you "walk" the table with a for statement, and then you can do a string.match, for example:




match_string = "kobold"

for i, msg in ipairs (messages_table) do
  
  -- print if line matches
  if string.match (msg, match_string) then
     print (msg)
  end -- if

end -- for each line


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Oriol   (31 posts)  Bio
Date Reply #2 on Sat 11 Jul 2009 07:14 AM (UTC)
Message
I keep getting this frustrating error when I try to reinstall the plugin.
AS far as I know, I'm doing this right.
Compile error
Plugin: channel_history (called from world: alter aeon)
Immediate execution
[string "Plugin"]:188: '=' expected near 'var'
Error context in script:
function SearchHistory()
string= utils.inputbox ("Enter a word or a player's name to search inside your history buffer:", "Search")
list={}
for i, msg in ipairs (messages) do
if string.match (msg, string) then
--Put the stuff into a table so we can list it later.
table.insert(list, i .. " " .. msg)
end -- if
end --for string match
if (#list == 0) then
utils.msgbox("No matches found.", "Error")
Else
utils.listbox("Messages list", "Found "..#list .." matches", list)
list={}
end
end
Top

Posted by Oriol   (31 posts)  Bio
Date Reply #3 on Sat 11 Jul 2009 09:46 PM (UTC)
Message
Hrm, expected near var is expected near utils. Seems like I used an old error but it still gives me the error if I take the var=out
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 11 Jul 2009 10:34 PM (UTC)
Message
To find line 188 you really need to find line 188 in the script, not from the start of the plugin itself.

The simplest way is to make sure the plugin doesn't have an "include" line which will throw out the line numbers, and then add 188 to the first line of the <script> section. (eg. if <script> is at line 50 in the plugin, then line 188 of the script is 188 + 50).

To solve the error I would need to see the lines around line 188, especially where it has something to do with "var" in it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Oriol   (31 posts)  Bio
Date Reply #5 on Sun 12 Jul 2009 05:24 AM (UTC)
Message
Xml import warnings channel_history.xml
Line 83: Error parsing script (problem in this file)

Compile error
Plugin: channel_history (called from world: alter aeon)
Immediate execution
[string "Plugin"]:188: '=' expected near 'utils'
Error context in script:
184 : end --for string match
185 : if (#list == 0) then
186 : utils.msgbox("No matches found.", "Error")
187 : Else
188*: utils.listbox("Messages list", "Found "..#list .." matches", list)
189 : lisst={}
190 : end
191 : end
192 : function OnPluginInstall()
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 12 Jul 2009 05:33 AM (UTC)
Message
Did you copy and paste that? Else has to be lower-case (ie. "else" not "Else").

Also I am a bit worried about:

lisst = {}

when previously you are referring to list (with one s).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Oriol   (31 posts)  Bio
Date Reply #7 on Sun 12 Jul 2009 05:42 AM (UTC)
Message
Eh? That list={} shouldn't have had a double s, yes I did copy and paste that. anyway, the else had an uppercase e, how weird, talk about newbie coding, let's see if its fixed.
Oh god its fixed I can't believe I didn't see this before, well, blame me for typing Else and my reader for not telling me I capped that e...
I can't believe I started a post just because i had an upper E in an else, someone should quote that.
Thanks Nick.
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.


23,434 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.