Piece of code -> Could use a little help debugging..

Posted by Gore on Tue 10 Feb 2004 05:51 AM — 4 posts, 17,206 views.

#0
Alright, I'm having a little trouble with this subroutine. Here's the Sub:


Quote:

Sub bow_toggle (a,b,wildcard)
  If bowon = "1" then
    World.Note "NO SHOOTING"
    bowon = "0"
    World.Send "unwield " & bow
    World.Send "wear "& bow
    if weapon = "whip" then 
     World.Send "get " & whip & " from bag"
     World.Send "wield " & whip
    Elseif weapon = "dirk" then
      World.Send "get " & whip & " from bag"
      World.Send "wield " & whip
    End If
    If armor = "blunt" then
      World.Send "get " & bshield & "  from bag"
      World.Send "wield " & bshield
    Elseif armor = "cut" then
      World.Send "get " & cshield & "  from bag"
      World.Send "wield " & cshield
    End If
  Elseif bowon = "0" then
    World.Note "SHOOTING"
    bowon = "1"
    If weapon = "whip" then
      World.Send "unwield " & whip
      World.Send "put " & whip & " in bag"
    Elseif weapon = "dirk" then
      World.Send "unwield " & dirk
    End If
    If armor = "blunt" then
      World.Send "unwield " & bshield
      World.Send "put " & bshield & " in bag"
    Elseif armor = "cut" then
      World.Send "unwield " & cshield
      World.Send "put " & cshield & " in bag"
    End if
    World.Send "remove " & bow
    World.Send "wield " & bow
  End if
End Sub



What it's supposed to do is: If the toggle is set to shoot, i'll set the toggle to "not shoot", unwield my bow, then wield a shield, blunt or cut, depending on the variable, and wield a dirk or whip, depending on the variable.

If the toggle is set to not shoot, it'll unwield the dirk or whip depending on the variable, unwield my shield, and wield my bow, Simple enough.

Here's what it actually does -

If the variable bowon = 1, then it'll do

Quote:
NO SHOOTING
unwield darkbow59678
wear darkbow59678
get whip244566 from bag
wield whip244566
get shield186377 from bag
wield shield186377


but if the variable bowon = 0, then it'll do

Quote:
SHOOTING
unwield dirk261597
unwield shield186377
put shield186377 in bag
remove darkbow59678
wield darkbow59678


Meaning, it tries to wield my whip each time when I turn shooting off, and it'll unwield my dirk each time when I turn shooting on, regardless of whether I'm supposed to wield/unwield the dirk or wield/unwield the bow.

Could anyone help me debug this?
#1
Ah, just in case, here's what is in all of the variables:

dirk = dirk261597
whip = whip244566
bshield = shield186377
cshield = shield92797
bow = darkbow59678

Sorry about that.
Australia Forum Administrator #2
For one thing, this looks wrong:

Elseif weapon = "dirk" then
World.Send "get " & whip & " from bag"
World.Send "wield " & whip
End If

You are saying if the weapon is a dirk you are getting the whip.

#3
Alright, thanks again. I knew it was something simple that I kept overlooking.