need help

Posted by Crea3644 on Sun 04 Jun 2006 03:48 PM — 6 posts, 27,738 views.

#0
Hi, Making a char roller script for Realms of Despair
Here is what I got so far but cannot get it completed and am getting flustered
If anyone could help me out it would be appreciated, thanks

<triggers>
<trigger
enabled="y"
group="Stats"
match="Charisma * *"
name="Cha"
send_to="9"
sequence="100"
variable="Cha"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Constitution * *"
name="Con"
send_to="9"
sequence="100"
variable="Con"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Dexterity * *"
name="Dex"
send_to="9"
sequence="100"
variable="Dex"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Intelligence * *"
name="Int"
send_to="9"
sequence="100"
variable="Int"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Luck * *"
name="Lck"
send_to="9"
sequence="100"
variable="Lck"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Strength * *"
name="Str"
send_to="9"
sequence="100"
variable="Str"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Wisdom * *"
name="Wis"
send_to="9"
sequence="100"
variable="Wis"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
group="Stats"
match="Your character's base stats have been rerolled..."
name="Start"
sequence="100"
>
</trigger>
</triggers>

<aliases>
<alias
name="Wanted_Cha"
match="SetCha *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZCha"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Con"
match="SetCon *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZCon"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Dex"
match="SetDex *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZDex"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Int"
match="SetInt *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZInt"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Lck"
match="SetLck *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZLck"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Str"
match="SetStr *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZStr"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
<alias
name="Wanted_Wis"
match="SetWis *"
enabled="y"
echo_alias="y"
group="Stats"
variable="ZWis"
omit_from_command_history="y"
send_to="9"
ignore_case="y"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>

<variables>
<variable name="Cha">11</variable>
<variable name="Con">14</variable>
<variable name="Dex">12</variable>
<variable name="Int">15</variable>
<variable name="Lck">13</variable>
<variable name="Str">15</variable>
<variable name="Wis">15</variable>
<variable name="ZCha">9</variable>
<variable name="ZCon"></variable>
<variable name="ZDex">9</variable>
<variable name="ZInt"></variable>
<variable name="ZLck"></variable>
<variable name="ZStr">9</variable>
<variable name="ZWis"></variable>
</variables>
#1
CONT..


--- Varibles not all set right yet, No problem seems to be there
The Triggers automaticaly grab the stats fine and store them to the vars
The Z Vars are the minimum number for wanted for each stat rolled

The Output I get from the mud is:

vv Command prompt
<Type HELP START>reroll
-- Me Typing Reroll command and output from mud below

Your character's base stats have been rerolled...
New Previous
Strength 15 13
Dexterity 12 14
Intelligence 15 15
Wisdom 15 15
Charisma 11 13
Constitution 14 14
Luck 13 11

The script I have got together so far is--

sub ReRoll_Check (thename, theoutput, thewildcards)

dim Str
dim ZStr
dim Dex
dim ZDex
dim Int
dim ZInt
dim Wis
dim ZWis
dim Cha
dim ZCha
dim Con
dim ZCon
dim Lck
dim ZLck

Str = world.GetVariable ("Str")
ZStr = world.GetVariable ("ZStr")
Dex = world.GetVariable ("Dex")
ZDex = world.GetVariable ("ZDex")
Int = world.GetVariable ("Int")
ZInt = world.GetVariable ("ZInt")
Wis = world.GetVariable ("Wis")
ZWis = world.GetVariable ("ZWis")
Cha = world.GetVariable ("Cha")
ZCha = world.GetVariable ("ZCha")
Con = world.GetVariable ("Con")
ZCon = world.GetVariable ("ZCon")
Lck = world.GetVariable ("Lck")
ZLck = world.GetVariable ("ZLck")

If Str => ZStr then
world.note "Strength is Good"
Else
world.note "Strength No Good"
world.send "ReRoll"
Exit Sub
End If

If Dex => ZDex then
world.note "Dexterity is Good"
Else
world.note "Dexterity No Good"
world.send "ReRoll"
Exit Sub
End If

If Int => ZInt then
world.note "Intelligence is Good"
Else
world.note "Intelligence No Good"
world.send "ReRoll"
Exit Sub
End If

If Wis => ZWis then
world.note "Wisdom is Good"
Else
world.note "Wisdom No Good"
world.send "ReRoll"
Exit Sub
End If

If Cha => ZCha then
world.note "Charisma is Good"
Else
world.note "Charisma No Good"
world.send "ReRoll"
Exit Sub
End If

If Con => ZCon then
world.note "Constitution is Good"
Else
world.note "Constitution No Good"
world.send "ReRoll"
Exit Sub
End If

If Lck => ZLck then
world.note "Luck is Good"
Else
world.note "Luck No Good"
world.send "ReRoll"
Exit Sub
End If

end sub

any help or suggestions on this would be helpful, any questions please ask
Thank you
Bill
#2
Hmm Just noticed a couple posts that said Lua is better for scripting nowadays, Is it similar to VBScript? It's been quite awhile since I have done any scripts, Lua hard to learn? would I be better off starting out with out for this script rather than VBScript? before I get too far in and have to change 3 or 4 scripts over to it?
Russia #3
Anything is better than Vbscript, and Lua is definitely more usable. It's not hard to learn at all, especially since it is actually better documented: lua.org/docs.html has plenty of documentation, plus there is a score of general and Mushclient-specific examples posted here by Nick.
Australia Forum Administrator #4
Just to show a part of your script in Lua:


if Cha >= ZCha then
  Note "Charisma is Good"
else
  Note "Charisma No Good"
  Send "ReRoll"
  return
end --If


It really is very similar to what you had (the world.xxx part is optional in both languages).

However capitalization is important in Lua. Thus "If" becomes "if" and "note" becomes "Note".

"Exit Sub" becomes "return".
The comparison "=>" should be ">=".

You could fix up those things with a quick find-and-replace.

I did a post here that shows how you can use the Global Replace dialog to fix up the capitalization of all function names very easily:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6211

#5
Thanks, This thread can be closed :) any more to follow I will move to Lua Section.