|
Trigger gives error message "attempting to concatenate nil value". Why?
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Agarwain
(3 posts) bio
|
| Date |
Tue 15 Nov 2011 04:27 AM (UTC) [ quote
] |
| Message |
Hello,
I'm trying to do something nifty in Lua, and failing quite miserably. Essentially, I want to create a table of values from a trigger that will examine something called waxlist, and store the wax number, the name of the person who it's of, and the form of the wax. The regexp seems to be fine, because when I finally do type 'waxlist', all hell breaks loose. The trigger:
<triggers>
<trigger
enabled="y"
expand_variables="y"
ignore_case="y"
keep_evaluating="y"
match="^[\d+]?x?\s?"wax(\d+)".*Image: (.*) \((\d+) bondings/?(.*)?\)\.$"
name="waxlist"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>waxlist [item] = { wax_id = "wax" .. tonumber( %2 ), name = "%3", bondings = tonumber( %4 ), form = "%5"}
waxlisted = 1
item = item + 1</send>
</trigger>
</triggers>
And the error:
Run-time error
World: Legends2
Immediate execution
[string "Trigger: waxlist"]:1: attempt to concatenate a nil value
stack traceback:
[string "Trigger: waxlist"]:1: in main chunk
I am thoroughly confused as to why this is. Any help would be greatly appreciated. | top |
|
| Posted by |
Daniel P
USA (77 posts) bio
|
| Date |
Reply #1 on Tue 15 Nov 2011 05:24 AM (UTC) [ quote
] Amended on Tue 15 Nov 2011 05:25 AM (UTC) by Daniel P
|
| Message |
If it has this error message, then there's a place where one of your variables or wildcards has just what it says, a nil value, and can't be concatenated with string.
It's just the rule: you can't concatenate a string (this is using the ..) with nothing.
Based on the error line, it looks like this is an issue with something in your waxlist table, specifically with the wax_id = "wax" .. tonumber( %2 ) entry. For some reason or another your wildcard %2 does not have a value and therefore cannot be converted to a number and therefore cannot be concatenated with the string "wax".
This could happen if it was an optional wildcard that wasn't used every time you used the command.
Might want to do some checking such as:
wax_id_num = %2
if wax_id_num == nil
wax_id_num = 0
end -- if
wax_id = "wax" .. tonumber(wax_id_num)
| top |
|
| Posted by |
Agarwain
(3 posts) bio
|
| Date |
Reply #2 on Tue 15 Nov 2011 05:52 AM (UTC) [ quote
] |
| Message |
It happens every time the command shows up. A normal iteration looks like:
"wax12345" Image: Agarwain (20 bonds/human).
Am I capturing the %2 (which should be '12345' in the example above) incorrectly then? | top |
|
| Posted by |
Fiendish
USA (848 posts) bio
Global Moderator |
| Date |
Reply #3 on Tue 15 Nov 2011 02:13 PM (UTC) [ quote
] |
| Message |
| What makes you think that 12345 is in %2 instead of %1? |
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Agarwain
(3 posts) bio
|
| Date |
Reply #4 on Tue 15 Nov 2011 07:34 PM (UTC) [ quote
] |
| Message |
| Hmm! i thought [\d+]?x?\s? would count as %1. Guess not. | 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.
1,377 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )