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
➜ Plugins
➜ Help debugging this plugin?
Help debugging this plugin?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| forral
USA (79 posts) Bio
|
Date
| Sun 02 Dec 2012 12:51 AM (UTC) |
Message
| Greetings,
I'm having issues trying to figure out where in this plugin my issues are arising. The issue is that when I press "2" on my keypad (which corresponds to south), the plugin sends the "up" command, and tries to open a non-existent door in the "up" direction. This spams repeatedly until I manually enter the direction.
The only workaround I've seen is for me to manually type (using letters) the directions I want, and the script will sometimes kick in.
To clarify, the plugin I'm using is a simple auto door-opening plugin. I've looked over the code from top to bottom and can see the section that is causing me issues, but can't find fault in any of the code.
Can anybody help?
As the code for the plugin isn't that long, I'll just post it below:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, January 26, 2012, 5:34 PM -->
<!-- MuClient version 4.79 -->
<!-- Plugin "MM_Auto_Open_Doors" generated by Plugin Wizard -->
<muclient>
<plugin
name="MM_Auto_Open_Doors"
author="Forral"
id="130ffba77eaf284e58979da5"
language="Lua"
purpose="Automatically opens doors"
save_state="y"
date_written="2012-01-26 17:33:26"
requires="4.00"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="\MUSHClient\worlds\plugins\constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
group="script-autodoor"
keep_evaluating="y"
match="^(.+)\: It\'s locked\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if GetVariable("lock") then
Note("Unlocking: " .. lastdir)
Send("cast 'knock'" .. lastdir)
end
</send>
</trigger>
<trigger
enabled="y"
group="script-autodoor"
keep_evaluating="y"
match="^(?:The)? (.*?) (is|are) closed\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if GetInfo(87) ~= nil then
local lastcommand = string.lower(GetInfo(87))
--local lastdir = "NONE" -- need this available elsewhere to bash
lastdir = "NONE"
local directions = {"n", "s", "e", "w", "u", "d", "nw", "ne", "sw", "se"}
local fulldirections = {
n = "NORTH",
s = "SOUTH",
e = "EAST",
w = "WEST",
ne = "NORTHEAST",
se = "SOUTHEAST",
nw = "NORTHWEST",
sw = "SOUTHWEST",
u = "UP",
d = "DOWN"
}
for k, v in pairs(directions) do
if string.match(lastcommand, v) then
lastdir = fulldirections[v]
end
end
Note("Auto-opening: " .. lastdir)
Send("OPEN " .. lastdir)
Send(lastdir)
else
Note("Autodoor: Could not retrieve the last command sent to the MUD!")
end
</send>
</trigger>
</triggers>
<!-- Variables -->
<variables>
<variable name="lock">y</variable>
</variables>
</muclient>
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 02 Dec 2012 05:18 AM (UTC) |
Message
| That's pretty confusing stuff. Can't you send "open n" to the MUD? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #2 on Sun 02 Dec 2012 08:11 PM (UTC) Amended on Sun 02 Dec 2012 08:22 PM (UTC) by Fiendish
|
Message
| fyi:
lastdir = "NONE"
for k, v in pairs(directions) do
if string.match(lastcommand, v) then
lastdir = fulldirections[v]
end
end
is roughly equivalent to
lastdir = fulldirections[lastcommand] or "NONE"
but your way is less safe, because a command could be "now" and it would string.match "n" and "w".
Quote: the plugin sends the "up" command
I think you have a problem with some other setting somewhere. If GetInfo(87) is "up" then you sent "up". You should print the value of GetInfo(87) before you do anything with it. And enable the "Echo My Input in:" setting under the Alt+0 config screen. And/or enable your game's command echo feature if it has one. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| forral
USA (79 posts) Bio
|
Date
| Reply #3 on Tue 04 Dec 2012 09:20 PM (UTC) |
Message
| I should note I didn't write this plugin, I just put in my character name when I used the plugin wizard after pulling it from a website. Credits due to the author, but I've long forgotten who it was/where I got it.
That being said, I have no idea why the code is so convoluted, and if Nick Gammon is confused then all hope is lost :P
I don't know how to get the value of GetInfo(87) Fiendish, but will look into it.
Here's a bit of the output from my screen when I encounter a locked door to my south. Note, the 1st line of my prompt is just a persistent sextant, so ignore it.
<3475hp 3065sp 2245st> [ 0 * -40 * 0 ]
south
The door is closed.
Auto-opening: UP
OPEN UP
UP
[801, 545]
<3475hp 3065sp 2245st>
There is no obvious exit up here.
[801, 545]
<3475hp 3065sp 2245st>
You cannot move in that direction.
[801, 545]
<3475hp 3065sp 2245st>
| Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #4 on Tue 04 Dec 2012 11:19 PM (UTC) |
Message
|
forral said: I don't know how to get the value of GetInfo(87) Fiendish, but will look into it.
Erm, it will help to read the code you posted, then. It happens a couple times in there. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 05 Dec 2012 03:53 AM (UTC) |
Message
|
forral said:
That being said, I have no idea why the code is so convoluted, and if Nick Gammon is confused then all hope is lost :P
What happens is, people take snippets of code and blend them together without fully understanding what each piece does. I can read the code, but am confused about why someone would do that (what this code does) in the first place.
For example, why have two tables of directions?
local directions = {"n", "s", "e", "w", "u", "d", "nw", "ne", "sw", "se"}
local fulldirections = {
n = "NORTH",
s = "SOUTH",
e = "EAST",
w = "WEST",
ne = "NORTHEAST",
se = "SOUTHEAST",
nw = "NORTHWEST",
sw = "SOUTHWEST",
u = "UP",
d = "DOWN"
}
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #6 on Wed 05 Dec 2012 05:11 AM (UTC) |
Message
| Anyway, the problem is that when you use Numpad-2 it sends the full word "south", not "s", and string.match("south","u") returns a positive result.
This points to both Nick's and my comments. Your problem is that this plugin is going in so many circles that you can't follow what it's doing.
I think maybe Nick wonders why you aren't just doing
local last_command = GetInfo(87)
Send("open " .. last_command)
Send(last_command)
|
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| forral
USA (79 posts) Bio
|
Date
| Reply #7 on Wed 05 Dec 2012 10:51 PM (UTC) |
Message
| Thank you guys for the insight.
Like I said, I didn't write this code so I really don't understand the logic behind it. I'm actually learning to code (through CodeAcademy and others) in Python and Javascript, with Ruby to come soon, so I will more likely than not re-write some of these scripts to my own liking in the future.
That said, I think I may have inadvertently modified something in that script because I loaded an original version from back in July of this year and it worked fine, so I'll experiment with that.
I think I may also have a conflict as I have another plugin that acts on my keypad, so that may be an issue.
Thanks again. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #8 on Thu 06 Dec 2012 01:15 PM (UTC) |
Message
| Eh, all you have to do is change your numpad macros to send short forms of directions instead of full words and it would work as originally posted. |
https://github.com/fiendish/aardwolfclientpackage | 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,532 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top