Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ Newbie scripting help

Newbie scripting help

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


Posted by Jetpig   (8 posts)  Bio
Date Fri 08 Oct 2004 11:38 PM (UTC)
Message
I'm trying to write a script that changes my title after every mob I kill. I've got 2 triggers set up to retrieve my experience to the next level. The first trigger fires when i kill a mob and sends the word group. This displays the members of my party in a format that looks like:

[ 99 Arc] Synamyn 2459/2459 hp 3400/3796 mana 1940/1940 mv 1685 xp2go


The next trigger fires on seeing that. It sends the Level variable (99 in this case)the xp2go variable (1685 in this) to a script:

sub OnLevel (a, b, c)
cInt exp

SetVariable "level", "%1"
SetVariable "tnl", "%8"


if level = 99
exp = tnl + 5000
end if

if level = 100
exp = tnl + 2500
end if

if leve = 101
exp = tnl
end if

send "title has |i|y" exp "|b exp to |mhero!|n"

End Sub


I get an error bugging about the line if level = 99:

Error number: -2146827271
Event: Execution of line 1158 column 14
Description: Expected 'Then'
Line in error:
if level = 99
Called by: Immediate execution


I'm sure it's some newb error. but as this is really my first script, i'm not surprised
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Sat 09 Oct 2004 01:34 AM (UTC)

Amended on Sat 09 Oct 2004 01:37 AM (UTC) by Flannel

Message
Few problems. Make sure you read my last paragraph, since its the biggest problem youll have.

If (conditional) Then
Stuff
End If

For your 101 youll need to fix "leve" to level.

And then send line:
send "title has |i|y" & exp & "|b exp to |mhero!|n"

And you can simplify that whole thing:
((101-%8) * 2500) + %1) is your exp to go.

You could do:

send "title has |i|y" & ((101-%8) * 2500) + %1) & "|b exp to |mhero!|n"

And do that whole thing.

That eliminates the need to store TNL and level to a variable, unless of course, youre setting variables to use in other scripts.

Now, your BIGGEST problem is. You cant use %X in a script, since it doesnt exist. You need to use your array of variables (in your case 'c').
To use %1 and %8, you need to put your script routine (minus the sub/end sub) in the "send" box of your trigger, and change the "send to:" pulldown menu to script.
The latter (inside the trigger, not the script file) is the preferred method when feasible.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Jetpig   (8 posts)  Bio
Date Reply #2 on Mon 18 Oct 2004 12:19 AM (UTC)
Message
Thank you a ton. *scampers off to try it out*
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.


12,591 views.

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

Go to topic:           Search the forum


[Go to top] top

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