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
➜ VBscript
➜ Rewritten Accelerator example script with triggers
Rewritten Accelerator example script with triggers
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Fri 05 Jun 2009 09:34 PM (UTC) Amended on Fri 05 Jun 2009 09:35 PM (UTC) by Rodriguez
|
Message
| Hi!
I wanted to merge your TargetSwitch plugin with the accelerator example but the first one was written in VBScript and the later in Lua
I got so far but now he started complaining:
<script>
<![CDATA[
function OnPluginInstall ()
Accelerator "F1", "backstab @target"
Accelerator "Ctrl+F1", "world.addtrigger "armBackstab", "@target has arrived.|(?<=@target).+ is here.", "backstab @target", eEnabled or eTemporary or eTriggerOneShot, 14, 0, "", ""
-- list them
for _, v in ipairs (AcceleratorList ()) do Note (v) end
end -- function OnPluginInstall
]]>
</script>
He cant find the end of the "Ctrl+F1" line. I tried to surround it with another "" pair but it didnt change anything.
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 06 Jun 2009 12:33 AM (UTC) |
Message
| You have quotes within quotes here. In VBscript you have to double the quotes for a single set to go into the string, for example to note:
... you would have to write:
Note "say ""hello"" to someone"
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sat 06 Jun 2009 12:34 AM (UTC) |
Message
| You might be better off converting the VBscript one to Lua, rather than the Lua one to VBscript. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #3 on Sat 06 Jun 2009 09:12 AM (UTC) |
Message
| Ok I think I converted it (at least he doesnt complain in the targeting script anymore...) but I still have a problem with the AddTrigger part:
Accelerator ("Ctrl+F1", "AddTrigger ("armBackstab", "(@target has arrived.|(?<=@target).+ is here.)", "backstab @target", eEnabled or eTemporary or eTriggerOneShot, 14, 0, "", "")")
He says:
[string "Plugin"]:24: ')' expected near 'armBackstab'
Error context in script:
20 : Accelerator ("F1", "backstab @target")
21 :
22 :
23 :
24*: Accelerator ("Ctrl+F1", "AddTrigger ("armBackstab", "(@target has arrived.|(?<=@target).+ is here.)", "backstab @target", eEnabled or eTemporary or eTriggerOneShot, 14, 0, "", "")")
25 :
26 :
27 :
28 : -- list them
But I see no reason why a bracket would be missing there
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #4 on Sat 06 Jun 2009 11:24 AM (UTC) |
Message
| Which language are you using now? You still have a quoted string within a quoted string, you need to use different quotes, or double the quotes, like I said. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sat 06 Jun 2009 11:26 AM (UTC) |
Message
| If it's Lua now, use single quotes at the start and end, like this:
Accelerator ("Ctrl+F1", 'AddTrigger ("armBackstab", "(@target has arrived.|(?<=@target).+ is here.)", "backstab @target", eEnabled or eTemporary or eTriggerOneShot, 14, 0, "", "")')
The single quotes in the "main" string lets you use double quotes inside the string. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #6 on Sat 06 Jun 2009 12:26 PM (UTC) |
Message
| Ah, yes its Lua now and the quotes solved that problem.
Now the part I converted from VBScript to Lua makes problems :/
Guess the bigger problem is that I never did much with script languages and am somewhat confused of all these String concatenation.
There are probably still VBScript parts in there that I missed...
Function/Sub: SetTarget called by alias
Reason: processing alias ""
[string "Plugin"]:2: attempt to call local 'wildcards' (a table value)
stack traceback:
[string "Plugin"]:2: in function <[string "Plugin"]:1>
Error context in script:
1 : function SetTarget (sName, sLine, wildcards)
2*: which = wildcards (1)
3 : to_whom = wildcards (2)
<script>
<![CDATA[
function SetTarget (sName, sLine, wildcards)
which = wildcards (1)
to_whom = wildcards (2)
world.SetVariable ("target" .. which, to_whom)
world.ColourNote ("moccasin", "darkgreen", "Target " .. CStr (which) .. " now '" .. to_whom .. "'")
end
function ChooseTarget (sName, sLine, wildcards)
world.SetVariable ("target", world.GetVariable ("target" .. wildcards (1)))
world.ColourNote ("moccasin", "darkgreen", "Target now '" .. world.GetVariable ("target") .. "'")
end
]]>
</script> | Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #7 on Sat 06 Jun 2009 03:44 PM (UTC) |
Message
| Ok, I think it works for the most part now
<script>
<![CDATA[
function SetTarget (sName, sLine, wildcards)
which = wildcards [1]
to_whom = wildcards [2]
SetVariable ("target"..which, to_whom)
ColourNote ("moccasin", "darkgreen", "Target now " .. to_whom )
end
function ChooseTarget (sName, sLine, wildcards)
SetVariable ("target", GetVariable ("target" .. wildcards [1]))
ColourNote ("moccasin", "darkgreen", "Target now " .. GetVariable ("target"))
end
]]>
</script>
But now I have a problem with the variable @target
Accelerator ("F2", "backstab @target")
now sends "backstab @target" to the mud instead of the target i set.
Even replacing it with GetVariable ('target') doesnt work, not even if I use the scripting prefix...
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #8 on Sat 06 Jun 2009 10:09 PM (UTC) Amended on Sat 06 Jun 2009 10:10 PM (UTC) by Nick Gammon
|
Message
| You need to get the target at runtime, whereas the Accelerator establishes a fixed string. This will do it:
AcceleratorTo ("F2", "Send ('backstab ' .. GetVariable ('target'))", sendto.script)
What this does is make F2 call a small script, which does a Send appending the current value of the variable 'target' to your message.
http://www.gammon.com.au/scripts/doc.php?function=AcceleratorTo |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #9 on Sun 07 Jun 2009 07:05 AM (UTC) |
Message
| I tried that but I received a Runtime-Error
Immediate execution
[string "Accelerator: Ctrl+F2"]:1: attempt to concatenate a nil value
stack traceback:
[string "Accelerator: Ctrl+F2"]:1: in main chunk
even adding a SetVariable ("target", "test") right before it doesn't change that.
How confusing :/ | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #10 on Sun 07 Jun 2009 07:52 AM (UTC) |
Message
| |
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #11 on Sun 07 Jun 2009 08:31 AM (UTC) |
Message
| Ah, yes its a plugin, sorry for not mentioning it earlier...
The problem with the runtime error is still there for some reason.
I guess I better post it in full to avoid further confusion.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, November 06, 2002, 9:25 AM -->
<!-- MuClient version 3.30 -->
<!-- Plugin "TargetSwitch" generated by Plugin Wizard -->
<!--
See: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1947
-->
<muclient>
<plugin
name="TargetSwitch"
author="Nick Gammon"
id="2adec0ac37689537f9e3daf2"
language="Lua"
purpose="Demonstrates switching targets"
save_state="y"
date_written="2002-11-06 09:20:06"
requires="3.23"
version="1.0"
>
<description trim="y">
<![CDATA[
Demonstrates how you can switch targets with a couple of aliases.
Usage
-----
t1 = person (set target 1)
t2 = person (set target 2)
t3 = person (set target 3) ... and so on up to 9 ...
t1 (choose target 1)
t2 (choose target 2)
t3 (choose target 3) ... and so on up to 9 ...
punch (punch target)
kick (kick target)
eg.
t1=Bill (target 1 is Bill)
t2=Benjamin (target 2 is Benjamin)
t1 (choose Bill)
kick (kick Bill)
t2 (choose Benjamin)
kick (kick Benjamin)
t1 (choose Bill again)
punch (punch Bill)
kick (kick Bill)
t2 (choose Benjamin again)
punch (punch Benjamin)
kick (kick Benjamin)
TargetSwitch:help <-- this help
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="SetTarget"
match="^t([1-9])\s*\=\s*(.+)$"
enabled="y"
regexp="y"
>
</alias>
<alias
script="ChooseTarget"
match="^t([1-9])$"
enabled="y"
regexp="y"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
function SetTarget (sName, sLine, wildcards)
which = wildcards [1]
to_whom = wildcards [2]
SetVariable ("target"..which, to_whom)
ColourNote ("moccasin", "darkgreen", "Target now " .. to_whom )
end
function ChooseTarget (sName, sLine, wildcards)
SetVariable ("target", GetVariable ("target" .. wildcards [1]))
ColourNote ("moccasin", "darkgreen", "Target now " .. GetVariable ("target"))
end
]]>
</script>
<script>
<![CDATA[
function OnPluginInstall ()
AcceleratorTo ("F2", "Send ('backstab ' .. GetPluginVariable ('', 'target'))", sendto.script)
AcceleratorTo ("Ctrl+F2","Send (AddTrigger ('armBackstab',(GetPluginVariable ('', 'target') ..' has arrived.'|(?<=(GetPluginVariable ('', 'target')).+ is here.), 'backstab '.. GetPluginVariable ('', 'target') , eEnabled or eTemporary or eTriggerOneShot, 14, 0, '', ''))",sendto.script)
-- list them
for _, v in ipairs (AcceleratorList ()) do Note (v) end
end -- function OnPluginInstall
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="TargetSwitch:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
World.Note (World.GetPluginInfo (World.GetPluginID, 3))
end
]]>
</script>
</muclient>
| Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #12 on Sun 07 Jun 2009 11:25 AM (UTC) |
Message
| F2 started working when I entered the script ID but Ctrl+F2 does nothing even after removing the OR. I tried to use a hardcoded mob name but even using the examples on the trigger page nothing happens.
AcceleratorTo (
"F2",
"Send ('backstab ' .. GetPluginVariable ('2adec0ac37689537f9e3daf2', 'target'))",
sendto.script
)
AcceleratorTo (
"Ctrl+F2",
"Send (AddTrigger ('armBackstab','* Militiaman *','backstab '.. GetPluginVariable ('2adec0ac37689537f9e3daf2', 'target') ,trigger_flag.Enabled or trigger_flag.Temporary or trigger_flag.OneShot or trigger_flag.Replace ,custom_colour.Custom14,0, '', ''))",
sendto.script
)
| Top |
|
Posted by
| Rodriguez
(22 posts) Bio
|
Date
| Reply #13 on Sun 07 Jun 2009 01:19 PM (UTC) |
Message
|
AcceleratorTo (
"Ctrl+F2",
"Send (AddTrigger ('armBackstab','^(.*?)'..GetPluginVariable ('2adec0ac37689537f9e3daf2', 'target')..'(.*?)$','backstab '.. GetPluginVariable ('2adec0ac37689537f9e3daf2', 'target') ,50229,custom_colour.Custom14,0, '', ''))",
sendto.script
)
Seems to work but still sends a "0" or "30006" return codes to the mud. Is there a way of telling MUSHClient to just send them to my output window? | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #14 on Sun 07 Jun 2009 09:49 PM (UTC) |
Message
| Why are you doing a Send ( AddTrigger ?
That is sending the results of the AddTrigger to the MUD (which will be a number).
Perhaps you mean to omit the Send altogether? |
- 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.
48,740 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top