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