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
➜ Bug reports
➜ ColourNote bug
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rollanz
(26 posts) Bio
|
Date
| Fri 26 Apr 2019 07:09 PM (UTC) Amended on Fri 26 Apr 2019 07:12 PM (UTC) by Rollanz
|
Message
| I encountered some strange ColourNote() behaviour which sometimes (but not always) gives me a Run-time error. I have narrowed down the problem to interaction with a trigger.
The alias that is calling ColourNote:
<aliases>
<alias
name="targetting"
match="^t (.+)$"
enabled="y"
regexp="y"
send_to="12"
keep_evaluating="y"
sequence="100"
>
<send>require "tprint"
target="%1"
--print(target)
args={"red","blue", "Target changed to: ", "blue","red", target}
--tprint(args)
ColourNote("red","blue", "Target changed to: ", "blue","red", target)
if attacking==true then
attack()
end</send>
</alias>
</aliases>
When I use the alias, I sometimes get this error:
Run-time error
World: Achaea
Immediate execution
[string "Alias: targetting"]:8: bad argument #6 to 'ColourNote' (string expected, got no value)
stack traceback:
[C]: in function 'ColourNote'
[string "Alias: targetting"]:8: in main chunk
Further experimentation shows that the error only shows up the first time I use the alias after receiving a message (any message) from the server.
Further experiment showed that disabling a new trigger for capturing prompts, which I just introduced, prevents the message. The trigger is:
<triggers>
<trigger
enabled="y"
group="prompt"
keep_evaluating="y"
match="^(.+)$"
name="prompt"
regexp="y"
send_to="12"
sequence="100"
>
<send>if GetLineCount() == GetInfo(289) then
prompt_curr="%1"
end</send>
</trigger>
</triggers>
Furthermore, the error does not happen if I call either print() or tprint() before the ColourNote in the alias (see commented out portions).
I suspect the issue is due to a race condition, but adjusting the sequence of the trigger up or down does not seem to resolve the issue.
Thanks in advance for your help.
Edit: I should add that I'm using Mushclient v5.06. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 27 Apr 2019 08:44 AM (UTC) |
Message
| Strange. Can you change the first line of your alias to read:
Then report what happens. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rollanz
(26 posts) Bio
|
Date
| Reply #2 on Sat 27 Apr 2019 10:04 AM (UTC) |
Message
|
Nick Gammon said:
Strange. Can you change the first line of your alias to read:
Then report what happens.
I have done so and it made no difference. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sun 28 Apr 2019 12:14 AM (UTC) |
Message
| There is more going on here than meets the eye. For one thing, scripts are always run to completion (unless you use coroutines) so race conditions should not apply. For another thing, if "target" was somehow nil, you would get a different error. For example:
require "tprint"
target="%1"
target = nil
ColourNote("red","blue", "Target changed to: ", "blue","red", target)
if attacking==true then
attack()
end
Gives the error:
Run-time error
World: smaug2
Immediate execution
[string "Alias: targetting"]:6: bad argument #6 to ColourNote' (string expected, got nil)
stack traceback:
[C]: in function 'ColourNote'
[string "Alias: targetting"]:6: in main chunk
Notice the different error message. Have you replaced the Lua DLL with something else, like LuaJIT? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Sun 28 Apr 2019 12:16 AM (UTC) |
Message
| The only way the error reads "got no value" is if you omit the argument altogether, like this:
ColourNote("red","blue", "Target changed to: ", "blue","red")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rollanz
(26 posts) Bio
|
Date
| Reply #5 on Sun 28 Apr 2019 03:07 AM (UTC) |
Message
|
Nick Gammon said:
There is more going on here than meets the eye. For one thing, scripts are always run to completion (unless you use coroutines) so race conditions should not apply. For another thing, if "target" was somehow nil, you would get a different error. For example:
require "tprint"
target="%1"
target = nil
ColourNote("red","blue", "Target changed to: ", "blue","red", target)
if attacking==true then
attack()
end
Gives the error:
Run-time error
World: smaug2
Immediate execution
[string "Alias: targetting"]:6: bad argument #6 to ColourNote' (string expected, got nil)
stack traceback:
[C]: in function 'ColourNote'
[string "Alias: targetting"]:6: in main chunk
Notice the different error message. Have you replaced the Lua DLL with something else, like LuaJIT?
I have not made changes to any Lua DLLs since I installed MushClient. The printout on world load says it's using Lua 5.1.4. I do have a paths variable pointing to Lua 5.3.5, if that's relevant.
Additional troubleshooting steps I've taken since the last post:
-uninstalling all plugins did not resolve the issue
-reinstalling MushClient did not resolve the issue
-the issue continued when I created a new world with only the trigger and alias
-commenting out all of the code in the trigger did not resolve the issue
I hadn't paid attention to this before, but the first part of the colour note ("Target changed to: ") printed fine in red on blue. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sun 28 Apr 2019 06:11 AM (UTC) Amended on Sun 28 Apr 2019 06:16 AM (UTC) by Nick Gammon
|
Message
| The good news is I can reproduce this. Also I think you are right about the race condition. So far what I have is:
You have a prompt line which is not terminated by a newline
Your trigger matches any text (therefore it matches the prompt)
Your alias does a ColourNote which outputs to the output window
When it attempts to do so it notices that there is an unfinished line from the MUD, being the prompt
It terminates the line from the MUD, which then causes triggers to be evaluated, including the prompt trigger
Since the trigger is “send to script” it calls the Lua script engine (you can comment out what the script does, and the same thing happens - as you noted)
Calling the script engine, in the middle of evaluating the call to ColourNote somehow corrupts the internal Lua state - this is the race condition. Probably because the first 3 arguments to ColourNote triggers the problem, and the problem is noticed when you process the next 3 arguments.
As you have noted, a workaround is to print something, anything (including just a blank line). That terminates the previous prompt line from the MUD and causes the trigger to be evaluated, but not in the middle of doing a ColourNote. Another thing you could possibly do is make the MUD terminate its prompts with a newline.
However I agree it is a bug, but I’m not sure how to totally stop this, since it rears its head while already doing a ColourNote. Probably forcing the checking for a previous unterminated line earlier would help.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Sun 28 Apr 2019 06:26 AM (UTC) |
Message
| |
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #8 on Sun 28 Apr 2019 08:58 PM (UTC) Amended on Sun 28 Apr 2019 08:59 PM (UTC) by Nick Gammon
|
Message
| |
Posted by
| Death
(55 posts) Bio
|
Date
| Reply #9 on Fri 10 May 2019 11:55 AM (UTC) |
Message
| I noticed a problem in this as well, and ended up having to use other means to do what I wanted to do. I'm glad its getting fixed!
On another note: I've experienced a weird issue of a similar note:
When using control+I, I can simulate a colourtell that works perfectly, but when I put the actual code into my plugins, they don't work.
I found out I needed to separate the one large colourtell into many more smaller colourtells instead of one big one.
Is this supposed to be how it works?
Why would it work in the Control+I IMMEDIATE window, but not in code in my plugin?
Let me know if you need an example. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #10 on Fri 10 May 2019 08:22 PM (UTC) Amended on Sat 11 May 2019 01:11 AM (UTC) by Nick Gammon
|
Message
| I would need to see the code to comment. It should work.
when I put the actual code into my plugins, they don’t work
You also need to define what you mean by “don’t work”. You see nothing? It is the wrong colour? The wrong place? Some appears but not all?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
27,817 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top