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
➜ Buildship Runtime
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Terry
USA (87 posts) Bio
|
Date
| Mon 01 Sep 2008 05:09 PM (UTC) Amended on Mon 01 Sep 2008 05:20 PM (UTC) by Terry
|
Message
| I made a plugin to automate building ships in LotJ.<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^(Where to begin\? It all looks so complex\.\.\.|You finish modifying the ship\.|You step away from (.*?)\, and realize you've done it all wrong\.\.\.)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>Send("buildship " .. GetVariable("ship") .. " " .. GetVariable("part"))</send>
</trigger>
<trigger
enabled="y"
match="You don't have a component like that."
send_to="12"
sequence="100"
>
<send>Send("get 10 " .. GetVariable("part"))
Send("buildship " .. GetVariable("ship") .. " " .. GetVariable("part"))</send>
</trigger>
<trigger
enabled="y"
match="Your * doesnt need any more of that."
send_to="12"
sequence="100"
>
<send>if GetVariable("counter") == table.getn(parts) then
SetVariable("counter", 0)
SetVariable("part", "weapons")
Send("buildship " .. GetVariable("ship") .. " weapons")
else
SetVariable("counter", GetVariable("counter")+1)
SetVariable("part", parts[GetVariable("counter")])
Send("buildship " .. GetVariable("ship") .. " " .. GetVariable("part"))
end -- if</send>
</trigger>
<trigger
enabled="y"
match="You don't see a ship like that nearby to work on."
sequence="100"
send_to="12"
>
<send>Send("afk")
DeleteVariable("ship")
DeleteVariable("part")
DeleteVariable("counter")</send>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="sbship *"
enabled="y"
send_to="12"
sequence="100"
>
<send>SetVariable("ship", "%1")
SetVariable("counter", 0)
SetVariable("part", "weapons")
Send("buildship %1 weapons")</send>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
parts = { }
parts[0] = "weapons"
parts[1] = "engines"
parts[2] = "circuits"
parts[3] = "hull"
]]>
</script>
However, when the MUD fired "Your Imperial-Class Star Destroyer doesnt need any more of that.", I got the following runtime:
Run-time error
Plugin: BuildShip (called from world: LotJ)
Immediate execution
[string "Trigger: "]:7: bad argument #2 to 'SetVariable' (string expected, got nil)
stack traceback:
[C]: in function 'SetVariable'
[string "Trigger: "]:7: in main chunk
I ran some checks, but they all turned out fine.Note(GetPluginVariable("b30a643ea4eee52bb3d0c7dd", "part")) --> "weapons"
Note(GetPluginVariable("b30a643ea4eee52bb3d0c7dd", "counter")) --> 1
I don't see why it would think there was a nil value anywhere. Could someone help me?
Edit:
In a future release, would there be any chance you could do something like DeleteVariables({"var1", "var2", "var3"}) and DeletePluginVariables("b30a643ea4eee52bb3d0c7dd", {"var1", "var2", "var3"}) ? Also, this would be really nice: SetPluginVariable("b30a643ea4eee52bb3d0c7dd", "var1", "val") . The first two would just make it easier to do manipulate multiple variables at once. The last one would be send from the command box, and would be great for debugging. | Top |
|
Posted by
| Beale
(35 posts) Bio
|
Date
| Reply #1 on Mon 01 Sep 2008 05:21 PM (UTC) |
Message
| I -believe- what's happening here is a slightly pesky type problem.
Try using this instead:
SetVariable("part", parts[tonumber(GetVariable("counter"))])
As far as I know, MUSHClient variables are always converted to strings before they're stored, and aren't converted back when they're retrieved. | Top |
|
Posted by
| Terry
USA (87 posts) Bio
|
Date
| Reply #2 on Mon 01 Sep 2008 05:33 PM (UTC) |
Message
| Thanks, it works now! :) I really appreciate your help. But my other question still stands. Is there any chance that those functions could be added in a later release? | Top |
|
Posted by
| Beale
(35 posts) Bio
|
Date
| Reply #3 on Mon 01 Sep 2008 06:11 PM (UTC) |
Message
| IANACoder in general, but when I'm debugging plugins and need the sort of access that you seem to want, I tend to just make an alias like:
<aliases>
<alias
name="DebugExec"
match="plugin-exec *"
enabled="y"
send_to="12"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>
That way you can execute arbitrary code in the Plugin's namespace. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #4 on Tue 02 Sep 2008 12:52 AM (UTC) |
Message
| |
Posted by
| Terry
USA (87 posts) Bio
|
Date
| Reply #5 on Tue 02 Sep 2008 12:57 AM (UTC) |
Message
| That link sent me to DeleteVariable() , which isn't what I was suggesting. :) I was suggesting DeleteVariables(string *vars); . It would just let you delete multiple variables at once, instead of having to use the same function multiple times in a row. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #6 on Tue 02 Sep 2008 01:38 AM (UTC) |
Message
| Just write a tiny function to do that - I don't want to add things that could easily be replicated in scripting. Plus you would have the issue of the return codes - what if one can be deleted and one not? What would the return code be? |
- 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.
21,963 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top