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
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
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
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
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.
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()
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).
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.