I am trying to get a better feel for coding so I thought the best way to do so would be trying to script out all of my events instead of using the "event command" buttons, however I am running into a few issues that I haven't been able to figure out and would love feed back on what I am doing wrong.
in short, I am trying to show text and give choices.
The show image code is the one I am having the most problem with, it shows the image but doesn't exit the loop leaving me unable to move, and when I try to show the image outside of a loop the image disappears on its own after a few seconds, and while its up the player can walk around, open their menu and all of the other normal functions.
Give Magikarp works fine and so does giving the Rare Candy
Change gender works, but if I remove the message "You are now *gender*" it wont break the loop and I can not move.
Exit and just pressing "B" to close the choice box without preforming an action will also leave me stuck in the loop, despite having the break command.
I am not asking for you to just give me the answer, but rather if anyone here could help me understand why this isn't working as I expected.
Thank you :t192:
Code:
def gtChoice
Kernel.pbMessage(_INTL("Select an option."))
loop do
command=Kernel.pbShowCommandsWithHelp(nil,
[_INTL("Show a Picture"),
_INTL("Give a Magikarp"),
_INTL("Give a Rare Candy"),
_INTL("Change Gender"),
_INTL("Exit")],
[_INTL("Select an option."),
_INTL("Select an option."),
_INTL("Select an option."),
_INTL("Select an option."),
_INTL("Select an option.")],-1
)
if command==0 # Show a Picture
viewport=Viewport.new(0,0,512,384)
sprite=Sprite.new(viewport)
sprite.bitmap=Bitmap.new("Graphics/Pictures/Test.png")
break
elsif command==1 # Give a Magikarp
pbAddToParty(:MAGIKARP,5)
break
elsif command==2 # Give a Rare Candy
Kernel.pbReceiveItem(:RARECANDY)
break
elsif command==3 # Change Gender
if $Trainer.gender == 0
pbChangePlayer(1)
Kernel.pbMessage(_INTL("You are now Female"))
else
pbChangePlayer(0)
Kernel.pbMessage(_INTL("You are now Male"))
end
break
elsif command==4 # Exit
break
end
break
end
end
in short, I am trying to show text and give choices.
The show image code is the one I am having the most problem with, it shows the image but doesn't exit the loop leaving me unable to move, and when I try to show the image outside of a loop the image disappears on its own after a few seconds, and while its up the player can walk around, open their menu and all of the other normal functions.
Give Magikarp works fine and so does giving the Rare Candy
Change gender works, but if I remove the message "You are now *gender*" it wont break the loop and I can not move.
Exit and just pressing "B" to close the choice box without preforming an action will also leave me stuck in the loop, despite having the break command.
I am not asking for you to just give me the answer, but rather if anyone here could help me understand why this isn't working as I expected.
Thank you :t192:
Last edited: