I am having a problem here. The scripts I include here are
supposed to 1) create a trigger 'grabit' that grabs
everything that follows and sends it to the script Mixcount,
then 2) send an 'inventory' command. 3) The Mixcount reads
line input and sorts it into herb types, storing the number
of herbs found until it reads 'Your total load is', then 4)
terminates the trigger and 5) calls the CalcPotions script.
The first time through it works perfectly, however the
second time I use the command to trigger these scripts it
does everything correctly up until the return from the
CalcPotions script, then it page faults and crashes
Mushclient.
The problem did not happen when I was testing 'only'
the Mixcount without the call. However, it still happens
if I copy the code from CalcPotions into Mixcount, instead
of using a call to the sub. I can't figure out what could
be causing it. :p
The following is a sample of the output from the 'inventory' command:
supposed to 1) create a trigger 'grabit' that grabs
everything that follows and sends it to the script Mixcount,
then 2) send an 'inventory' command. 3) The Mixcount reads
line input and sorts it into herb types, storing the number
of herbs found until it reads 'Your total load is', then 4)
terminates the trigger and 5) calls the CalcPotions script.
The first time through it works perfectly, however the
second time I use the command to trigger these scripts it
does everything correctly up until the return from the
CalcPotions script, then it page faults and crashes
Mushclient.
The problem did not happen when I was testing 'only'
the Mixcount without the call. However, it still happens
if I copy the code from CalcPotions into Mixcount, instead
of using a call to the sub. I can't figure out what could
be causing it. :p
The following is a sample of the output from the 'inventory' command:
You have the following items in your inventory:
-----------------------------------------------
[keep] A "legendary defender of loriah" badge [worn]
A bundle of 81 hops herbs
A bundle of 17 eyebright herbs
A bundle of 2 tansy herbs
A bundle of 8 nightshade herbs
A bundle of 8 gentian herbs
[keep] A druid belt
A bundle of 46 echinacea herbs
A single masterwort herb
A bundle of 4 hazel herbs
A bundle of 6 linden herbs
A bundle of 14 narcissus herbs
[keep] A holy circle
A bundle of 11 clubmoss herbs
A bundle of 6 peony herbs
A bundle of 19 cinchona herbs
A bundle of 4 dragonblood herbs
A single carnation herb
[keep] Kagehi's slave title
A bundle of 28 feverfew herbs
A single eucalyptus herb
A bundle of 4 goldenseal herbs
A bundle of 2 rue herbs
A bundle of 38 agrimony herbs
A bundle of 63 lotus herbs
A single mullein herb
A bundle of 20 borage herbs
A bundle of 4 hemlock herbs
-----------------------------------------------
You are carrying 1000 coins.
Your total load is: 40.4 kg, out of 72.2 kg.
My Alias>
match on: potions
Label: PotionCount
Script: Mixit
The Sctipts>
sub Mixit (Aliasname, Output, Wildcards)
dim sTarget
int count
sTarget = Trim (Wildcards (1))
for count = 0 to 23
HerbCount(count) = 0
next
world.addtrigger "Grabit","*","",1,-1,0,"","Mixcount"
world.send "inventory"
end sub
sub Mixcount (Trigname, Output, Wildcards)
dim sTest
dim sLoad
dim sBundle
dim sSingle
dim sValue
int i
int d
int count
int found
int fat
int Best
dim Herbs
dim PotionCount(5)
Herbs = array ("goldenseal","rue","carnation","eucalyptus","masterwort","p
eony","nightshade","hazel","narcissus","linden","tansy","gen
tian","dragonblood","clubmoss","mullein","cinchona","hemlock
","lotus","hops","echinacea","eyebright","borage","agrimony"
,"feverfew")
'Note the above should not have line breaks, but won't
'wrap correctly on this forum.
found = 0
sLoad = "Your total load is"
sBundle = "A bundle of"
sSingle = "A single"
sTest = Wildcards(1)
'world.note "Testing> " & sTest
i = InStr(1, sTest, sLoad, 1)
if i > 0 then
d = world.DeleteTrigger ("Grabit")
call CalcPotions
end if
i = 0
i = InStrRev(sTest, sBundle, -1, 1)
if i > 0 then
found = 1
fat = i
'world.note "Found! " & i
end if
i = 0
i = InStrRev(sTest, sSingle, -1, 1)
if i > 0 then
fat = i
found = 2
'world.note "Found2! " & i
end if
if found then
for count = 0 to 23
i = InStr(1, sTest, Herbs(count), 1)
if i > 0 and found = 1 then
sValue = mid(sTest, fat +11, i-(fat+11))
HerbCount(count) = Cint(sValue)
'world.note "" & i & " " & sValue &; " index " & count
end if
if i > 0 and found = 2 then
HerbCount(count) = 1
'world.note "" & i & " index " & count
end if
next
end if
end sub
sub CalcPotions
dim PotionCount(5)
' Find best potion mixes.
Best = 0
if HerbCount(4) > HerbCount (7) then
Best = HerbCount (4)
else
Best = HerbCount (7)
end if
if HerbCount(20) < Best then
Best = HerbCount(20)
end if
if HerbCount(21) < Best then
Best = HerbCount(21)
end if
if HerbCount(23) < Best then
Best = HerbCount(23)
end if
if Cint(HerbCount(17)/5) < Best then
Best = Cint(HebCount(17)/5)
end if
'Figure out Individual potions.
if HerbCount(17) < HerbCount(4) then
PotionCount(0) = HerbCount(17)
else
PotionCount(0) = HerbCount(4)
end if
if HerbCount(17) < HerbCount(7) then
PotionCount(3) = HerbCount(17)
else
PotionCount(3) = HerbCount(7)
end if
if HerbCount(17) < HerbCount(20) then
PotionCount(4) = HerbCount(17)
else
PotionCount(4) = HerbCount(20)
end if
if HerbCount(17) < HerbCount(21) then
PotionCount(2) = HerbCount(17)
else
PotionCount(2) = HerbCount(21)
end if
if HerbCount(17) < HerbCount(23) then
PotionCount(1) = HerbCount(17)
else
PotionCount(1) = HerbCount(23)
end if
' Display it.
world.note " "
world.note "You can make:"
world.note " "
if HerbCount(0) < HerbCount(5) then
world.note "Focus Potion - " & HerbCount(0)
else
world.note "Focus Potion - " & HerbCount(5)
end if
world.note "Minor Str - " & PotionCount(0) & " " & Best
world.note "Minor Dex - " & PotionCount(1) & " " & Best
world.note "Minor Con - " & PotionCount(2) & " " & Best
world.note "Minor Wis - " & PotionCount(3) & " " & Best
world.note "Minor Int - " & PotionCount(4) & " " & Best
end sub