Jump to content

MessageBox what am I doing wrong?


Recommended Posts

Hi guys I'm working on a script for a miscItem and I need a MessageBox with multiple options but it doesnt work for some reason.

 

 

ScriptName sqaEquilibriumItemScript

Begin OnAdd player
MessageBox "Picked up Equilibrium" "Ok"; Placeholder
End

Begin OnEquip
MessageBox "Choose Class" "Mage" "Warrior" "Rogue" "Merchant"

if (GetButtonPressed == -1)
return
elseif (GetButtonPressed == 0)
<addspell for MageClass>
<remove other spells>
elseif (GetButtonPressed == 1)
<addspell for WarriorClass>
<remove other spells>
elseif (GetButtonPressed == 2)
<addspell for RogueClass>
<remove other spells>
elseif (GetButtonsPressed == 3)
<addspell for MerchantClass>
<remove other spells>
endif
End

 

Can someone tell me what I'm doing wrong?

 

Thanks
Darkyne

 

 

Edit:

 

It does display the MessageBox at the start of the OnEquip Block but the GetButtonPressed doesnt work

Edited by Darkyne
Link to comment
Share on other sites

"OnEquip" is the wrong block type for "catching" the button presses. Triggering the messagebox popup inside there is alright, but afterwards the block is never again executed, unless you re-equip the item another time. OnEquip, like OnAdd, always runs "once".
GetButtonPressed, however, must "regularly" check for the button press, as you never know when it will occur.

Additionally, GetButtonPressed will only return the right value the first time it's called within the same frame. So using it the way you do above (If... ElseIf... ElseIf... EndIf) won't really work. You must store its return value inside a variable instead, so it's only called once inside the run.

You're equipping the misc item from inside your inventory, am I right? If so, then that'd mean that after the messagebox was clicked away you'd still be inside the inventory, correct?
In that case, I'd move the button press catching into a MenuMode block instead. But previously take care to only check for button presses, once the messagebox was actually shown.

Let's rewrite your above script quickly and see if this works better:

ScriptName sqaEquilibriumItemScript
 
short choosing
short choice
 
Begin OnAdd player
  MessageBox "Picked up Equilibrium" "Ok"; Placeholder
End
 
Begin OnEquip
  MessageBox "Choose Class" "Mage" "Warrior" "Rogue" "Merchant"
  set choosing to 1
End
 
Begin MenuMode
  if choosing == 1
    set choice to GetButtonPressed
    if (choice == -1)
      return
    elseif (choice == 0)
      <addspell for MageClass>
      <remove other spells>
      set choosing to 0
    elseif (choice == 1)
      <addspell for WarriorClass>
      <remove other spells>
      set choosing to 0
    elseif (choice == 2)
      <addspell for RogueClass>
      <remove other spells>
      set choosing to 0
    elseif (choice == 3)
      <addspell for MerchantClass>
      <remove other spells>
      set choosing to 0
    endif
  endif
End

Let me know if it works now or if there's any questions still.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...