Converting TinyFugue scripts to MushClient

Posted by Winddancer on Tue 25 Oct 2022 03:32 PM — 7 posts, 20,469 views.

#0
After years of absence I wanted to play muds again and wanted to move from TF to MushClient. As I had a good set of scripts for TF I got stuck converting some of the stuff. Maybe someone can help me here.

The original TF script looks like this:

/alias delay3 \
	/repeat -3 1 %*

/alias delay3.5 \
	/repeat -3.5 1 %*

/alias tw throw $[myweapon] at enemy%;get $[myweapon]%;\
	/if ({twohandedmode} = 0) \
		delay3 wield $[myweapon] in both hands%; \
	/elseif ({twohandedmode} = 1) \
		delay3.5 wield $[myweapon]%; \
	/endif%;


Depending on wether or not the weapon I plan to throw is twohanded or not, I need to wait a different amount of time.
I got triggers set up that
a) catch the name of the weapon I use and store it in variable myweapon
b) depending on the message the mud produces, a trigger determines wether or not the weapon is twohanded and then sets the variable twohandedmode accordingly.

How would I do all this in MUSHclient?
USA Global Moderator #1
The time delay would probably be the DoAfterSpecial script function ( https://www.mushclient.com/scripts/doc.php?function=DoAfterSpecial ).

For the variable setting and retrieval, I think you want to watch the demo Nick put together for making a targeting alias. https://www.mushclient.com/forum/?id=9616
Amended on Tue 25 Oct 2022 07:34 PM by Fiendish
#2
Hmm, seems I got most of it working, thanks...
However, not getting the call for the DoAfterSpecial right yet.
Probably a question of the sendto,

So far the alias looks like this:

 <alias
   match="tw"
   enabled="y"
   expand_variables="y"
   group="throwing"
   send_to="12"
   sequence="100"
  >
  <send>throw @myweapon at enemy
get @myweapon
DoAfterSpecial (4, wield @myweapon, sendto.world)</send>
  </alias>
#3
Winddancer said:

Hmm, seems I got most of it working, thanks...
However, not getting the call for the DoAfterSpecial right yet.
Probably a question of the sendto,

So far the alias looks like this:

 <alias
   match="tw"
   enabled="y"
   expand_variables="y"
   group="throwing"
   send_to="12"
   sequence="100"
  >
  <send>throw @myweapon at enemy
get @myweapon
DoAfterSpecial (4, wield @myweapon, sendto.world)</send>
  </alias>



You're mixing up syntaxes here. You have literal commands that you would send, mixed in with Lua code. You have send_to="12", which means all the code in 'send' tags needs to be in Lua code. Also, commands in DoAfterSpecial must be encased in quotes.

Change what's in the send tags to this:


local myweap = GetVariable("myweapon")
Send("throw " .. myweap .. " at enemy")
Send("get " .. myweap)
DoAfterSpecial(4, "wield " .. myweap, sendto.world)
Amended on Wed 26 Oct 2022 03:06 PM by Fiendish
USA Global Moderator #4
This part:
send_to="12"

means that everything between
<send>
and
</send>
is going through the script engine. That's good, because it's needed for DoAfterSpecial to work.
However...


throw @myweapon at enemy
get @myweapon

Because we're in the script engine now and not just dumping commands at the game, this stuff needs the Send() function to be sent to the game, like:

Send("throw @myweapon at enemy")
Send("get @myweapon")


Note also that I put quotation marks around what's being sent, because now it's some text being given to the Send function to do something with.

We also need to do the same for the next line, like this:

DoAfterSpecial (4, "wield @myweapon", sendto.world)



AdInfinitum's use of GetVariable, the local script variable myweap, and string concatenation with .. is another way to do the same thing.
Amended on Wed 26 Oct 2022 03:06 PM by Fiendish
#5
Fiendish said:

AdInfinitum's use of GetVariable, the local script variable myweap, and string concatenation with .. is another way to do the same thing.


It's funny, because I absolutely missed the expand_variables option. I don't use it much, so I tend to overlook that.

Fiendish's way is much more cleaner. Use his.
#6
Thanks a bunch...