[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  missing sub help please
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

missing sub help please

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Sat 27 Nov 2010 07:33 AM (UTC)
Message
  <alias
   match="spellup"
   enabled="y"
   group="aces"
   script="BuffOut"
   send_to="12"
   sequence="100"
  >
  <send> Sub BuffOut ()
dim setting
setting = world.getvariable ("prompt")
if setting = ("2") then world.execute "prompt;flex" else world.execute "flex"
end if
end sub</send>
  </alias>


This is small chunk of MUCH larger script the variable is valid and does savestate, but on install I receive this.

You have not specified a script file name:
The alias subroutine named "BuffOut" could not be found.

All help is greatly appreciated.

aardwolf player
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #1 on Sat 27 Nov 2010 07:49 AM (UTC)

Amended on Sat 27 Nov 2010 07:50 AM (UTC) by Twisol

Message
That's because the <send> content isn't evaluated until the trigger matches. Further, it's evaluated every time the trigger matches, which means it's likely you'd get an error about redefining a sub after the second time it matches. Use this instead:

  <alias
   match="spellup"
   enabled="y"
   group="aces"
   send_to="12"
   sequence="100"
  >
  <send>dim setting
setting = world.getvariable ("prompt")
if setting = ("2") then world.execute "prompt;flex" else world.execute "flex"
end if</send>
  </alias>


The "script" attribute/field is only used to reference a function/sub defined elsewhere, most often in the script file (or <script> section of a plugin), where it's already been defined. For normal scripts embedded into an alias/trigger/timer, just put the code you want to execute in the send field.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #2 on Sat 27 Nov 2010 08:00 AM (UTC)
Message
ok did that now returns:


Script error
Plugin: aardspellup (called from world: aardwolfmud)
Execution of line 4 column 1
Immediate execution
Expected statement
Line in error:
end if

aardwolf player
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #3 on Sat 27 Nov 2010 08:02 AM (UTC)
Message
Hmm. I'm not really an expert on VBscript, but try fixing the indentation.

  <alias
   match="spellup"
   enabled="y"
   group="aces"
   send_to="12"
   sequence="100"
  >
  <send>dim setting
setting = world.getvariable ("prompt")
if setting = "2" then
  world.execute "prompt;flex"
else
  world.execute "flex"
end if</send>
  </alias>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #4 on Sat 27 Nov 2010 08:07 AM (UTC)
Message
Ah, yeah. If you look here \[1], you can see that there are two syntaxes for if-else-then. It explains that it decides which one you're using by looking at what comes after "then". In this case, it was expecting the single-line version, so the "end if" you added was invalid. I'd stick with the block syntax (what I posted) because it's easier to read and maintain though.

\[1] http://msdn.microsoft.com/en-us/library/5h27x7e9.aspx

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #5 on Sat 27 Nov 2010 08:26 AM (UTC)
Message
Thank you a ton now on to a slightly more complex problem.
I am trying to have a plugin expand itself and not quite sure them problem not receiving an error msg.
Here is the alias in question.

  <alias
   name="asa3"
   match="^(add trigger(s|)|addtrigger(s|))$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>addtriggerex ""&amp;getvariable ("asv1")&amp;"3", ""&amp;getvariable ("asv4")&amp;"", 

"enabletrigger &amp;quot;"&amp;getvariable("asv1")&amp;"1&amp;quot;, 1", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"2", ""&amp;getvariable ("asv3")&amp;"", 

"world.enabletrigger &amp;quot;"&amp;getvariable("asv1")&amp;"1&amp;quot;, 1", 1, -1, 0, "", "", 

12, 100  
addtriggerex ""&amp;getvariable ("asv1")&amp;"1", "^You flex your muscles proudly\!$", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"4", ""&amp;getvariable ("asv5")&amp;"", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100  
enabletrigger "cancel", 0
</send>
  </alias>


aardwolf player
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #6 on Sat 27 Nov 2010 08:40 AM (UTC)

Amended on Sat 27 Nov 2010 08:41 AM (UTC) by Twisol

Message
This is kind of nuts, you have weird XML bits in the code even after importing, like &amp;quot; becomes &quot;. Very odd, but I tried to fix it up.

<aliases>
  <alias
   name="asa3"
   match="^(add trigger(s|)|addtrigger(s|))$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>addtriggerex getvariable ("asv1") &amp; "3", getvariable ("asv4"), "enabletrigger getvariable(""asv1"") &amp; ""1"", 1", 1, -1, 0, "", "", 12, 100
addtriggerex getvariable ("asv1") &amp; "2", getvariable ("asv3"), "world.enabletrigger getvariable(""asv1"") &amp; ""1"", 1", 1, -1, 0, "", "", 12, 100  
addtriggerex getvariable ("asv1") &amp; "1", "^You flex your muscles proudly\!$", "send ""c " &amp; getvariable("asv2") &amp; """", 1, -1, 0, "", "", 12, 100
addtriggerex getvariable ("asv1") &amp; "4", getvariable ("asv5"), "send ""c " &amp; getvariable("asv2") &amp; """", 1, -1, 0, "", "", 12, 100  

enabletrigger "cancel", 0
</send>
  </alias>
</aliases>


[EDIT]: Are you dead set on using VBscript? Lua is way easier to use in my opinion. I only bring it up because this looks insane. :D

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #7 on Sat 27 Nov 2010 09:07 AM (UTC)
Message
Been thinking about it and, reading random forum posts.
Starting to look like i will have to use a exportXML
to save the triggers as variables and importXML them back.
but can't figure out how to export then import a large list

  <alias
   name="asa3"
   match="^(add trigger(s|)|addtrigger(s|))$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>addtriggerex ""&amp;getvariable ("asv1")&amp;"3", ""&amp;getvariable ("asv4")&amp;"", 

"enabletrigger &amp;quot;"&amp;getvariable("asv1")&amp;"1&amp;quot;, 1", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"2", ""&amp;getvariable ("asv3")&amp;"", 
  
addtriggerex ""&amp;getvariable ("asv1")&amp;"1", "^You flex your muscles proudly\!$", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"4", ""&amp;getvariable ("asv5")&amp;"", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100  
exportxml (0, ""&amp;getvariable ("asv1")&amp;"1")
exportxml (0, ""&amp;getvariable ("asv1")&amp;"2")
exportxml (0, ""&amp;getvariable ("asv1")&amp;"3")
exportxml (0, ""&amp;getvariable ("asv1")&amp;"4")

enabletrigger &amp;quot;"&amp;getvariable("asv1")&amp;"1&amp;quot;, 1", 1, -1, 0, "", "", 12, 100
enabletrigger "cancel", 0
</send>
  </alias>

Is my best attempt.

aardwolf player
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #8 on Sat 27 Nov 2010 09:10 AM (UTC)
Message
Did you try what I posted? What error occurred, if any?

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #9 on Sat 27 Nov 2010 09:14 AM (UTC)
Message
no error just no change to script or state

aardwolf player
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #10 on Sat 27 Nov 2010 09:23 AM (UTC)

Amended on Sat 27 Nov 2010 01:43 PM (UTC) by Perrin

Message
&amp;quot: is a special entity for "
and &amp; is a special entity for &
thanks for that catch twisol

<send>addtriggerex ""&amp;getvariable ("asv1")&amp;"3", ""&amp;getvariable ("asv4")&amp;"", 

"enabletrigger &amp;quot;"&amp;getvariable("asv1")&amp;"1&amp;quot;, 1", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"2", ""&amp;getvariable ("asv3")&amp;"", 
  
addtriggerex ""&amp;getvariable ("asv1")&amp;"1", "^You flex your muscles proudly\!$", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100
addtriggerex ""&amp;getvariable ("asv1")&amp;"4", ""&amp;getvariable ("asv5")&amp;"", "send 

&amp;quot;c "&amp;getvariable("asv2")&amp;"&amp;quot;", 1, -1, 0, "", "", 12, 100  


ok asuming the other triggers function correctly
and set values to the variables to

asv1="manna"
asv2="123"
asv3="you feel a surge of power."
asv4="you feel you extra power drain."
asv5="you fail at casting manna."

my code should output

<send>addtriggerex "manna3", "you feel a surge of power.", "enabletrigger "manna1", 1", 1, -1, 0, "", "", 12, 100

addtriggerex "manna1", "^You flex your muscles proudly\!$", "send "c 123"", 1, -1, 0, "", "", 12, 100

addtriggerex "manna4", "you fail at casting manna.", "send "c 123"", 1, -1, 0, "", "", 12, 100

aardwolf player
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #11 on Sat 27 Nov 2010 10:31 AM (UTC)
Message
Your translation is incorrect, unless you repeat on the same character every time. "&amp;quot;" actually translates to "&quot;", otherwise there would be no way to literally write "&quot;".

Did you check the triggers list after running the alias? When I used it, it added them. (Test it in the world aliases, not the plugin aliases, because there's no easy way to look at the list of triggers in a plugin like that.)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Perrin   USA  (31 posts)  [Biography] bio
Date Reply #12 on Sat 27 Nov 2010 11:15 AM (UTC)

Amended on Sat 27 Nov 2010 02:30 PM (UTC) by Perrin

Message
yes tested trigger with world aliases and still cannot find created trigger

"check triggers" returns:
name 'manna' spellnum '123' spellon 'you feel a surge of power.' spelloff 'you feel you extra power drain.' spellfail 'you fail at casting manna.'

which is correct but "add triggers" doesn't seem to do anything

aardwolf player
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Sat 27 Nov 2010 08:48 PM (UTC)
Message
I'm completely confused about what you are trying to do here. First, the regexp:


^(add trigger(s|)|addtrigger(s|))$


For one optional letter, just put a question mark, eg.


^add ?triggers?$


That makes the space optional and the "s" optional.

And then inside the addtrigger alias you do this:


addtriggerex ""&getvariable ("asv1")&"3", ""&getvariable ("asv4")&"", 

"enabletrigger &quot;"&getvariable("asv1")&"1&quot;, 1", 1, -1, 0, "", "", 12, 100
addtriggerex ""&getvariable ("asv1")&"2", ""&getvariable ("asv3")&"", 
  
addtriggerex ""&getvariable ("asv1")&"1", "^You flex your muscles proudly\!$", "send 

&quot;c "&getvariable("asv2")&"&quot;", 1, -1, 0, "", "", 12, 100
addtriggerex ""&getvariable ("asv1")&"4", ""&getvariable ("asv5")&"", "send 

&quot;c "&getvariable("asv2")&"&quot;", 1, -1, 0, "", "", 12, 100  
exportxml (0, ""&getvariable ("asv1")&"1")
exportxml (0, ""&getvariable ("asv1")&"2")
exportxml (0, ""&getvariable ("asv1")&"3")
exportxml (0, ""&getvariable ("asv1")&"4")

enabletrigger &quot;"&getvariable("asv1")&"1&quot;, 1", 1, -1, 0, "", "", 12, 100
enabletrigger "cancel", 0


Whatever it is you are trying to achieve, this is not the way to do it. Honestly.

Perhaps if you explain what the real problem is - not "trying to add a heap of triggers".

Twisol said:

... there's no easy way to look at the list of triggers in a plugin like that ...


Load the "summary" plugin. Type "summary". That shows, amongst other things, your plugins. Next to each plugin is a link like [Tr] which, if you click on it will list that plugin's triggers. Then you can look at individual triggers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #14 on Sat 27 Nov 2010 08:50 PM (UTC)
Message
Nick Gammon said:
Load the "summary" plugin. Type "summary". That shows, amongst other things, your plugins. Next to each plugin is a link like [Tr] which, if you click on it will list that plugin's triggers. Then you can look at individual triggers.

Ack. I keep forgetting about that thing. :S

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] 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.


18,378 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]