Lua Script Questions

by Unknown

Back to Mechanic's Corner.

Unknown2008-05-14 10:49:19
I've just started studying a few of the systems that have been posted in these forums trying to teach myself to script in MUSHclient. Anyways, I was looking at Ethelon's scripts and am just wondering a few things.

Example:

Sub herbcall (aff, herb)
setvariable "affliction_" & aff & "", "1"
if (getvariable("herbbalance") = 0 AND getvariable("affliction_aeon") = 0 AND getvariable("affliction_anorexia") = 0) then
setvariable "herbbalance", "1"
send "outr " & herb
send "eat " & herb
end if
end sub

Example:

Sub herbhealing (a, b, c)
set variable "herbbalance", "0"
if getvariable ("affliction_anorexia") = "1" then

1. Can someone explain to me what the purpose and effect of (aff, herb) is? Also, in the second example (a, b, c)?

2. When I load this into the system and try to access the clipboard with all the scripts, I receive this error message...

Error number: 0
Event: Compile error
Description: :1: '=' expected near 'herbcall'
Called by: Immediate execution

Say I put the first example at the very top of the clipboard, in front of all the other script. It'll say that 'herbcall' has that error. If I put the second example at the top, in front of all the other script, it'll say that 'herbhealing' has the error.


I've been experimenting with making some scripts just to learn how it works, so I tried making a trigger, alias and variable that keep track of rebounding and switch the alias that is used to attack to raze when aura is up and attack when aura is down.

ALIAS: PT

SEND: if getvariable ("enemy_aura") = "1" then
send "raze @target"
end if
if getvariable ("enemy_aura") = "0" then
send "attack @target"
end if

SEND TO: SCRIPT
REGULAR EXPRESSION: Y
EXPAND VARIABLES: N

Then my variable is, of course, "enemy_aura" with a value of "0"

Trigger is "You see an aura of rebounding yada yada..."

Send:

setvariable "enemy_aura", "1"
note "*** REBOUNDING IS UP ***"

SEND TO: SCRIPT
REGULAR EXPRESSION: Y
EXPAND VARIABLES: N

When I receive the trigger message it tells me this...

"Send-to-script cannot execute because scripting is not enabled."
Except that when I go to the script options, Enable Script is checked.

Can anyone help me out?

Thanks.
Unknown2008-05-14 10:56:20
You want the 'Expand Variables' option enabled, for one. Secondly, you want to use == when comparing two things. Just using = will try to assign what's on the right to what's on the left, and you obviously cannot assign a value to a function return...

Are you absolutely sure scripting is enabled? I assume you're going with the default of Lua, also.

P.S. Posting in the other thread and then asking the same thing here. Tsk tsk. Anyway, I responded to the first two points in the other thread already. tongue.gif
Unknown2008-05-14 10:59:46
Ok, thank you. I'll try that.

Posted this new thread because I was not sure anyone would see the other. Then right when I posted it, I saw that you responded. Heh. Thanks for the help.