The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Colbex
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Conversation Between Colbex and Maruno
Showing Visitor Messages 1 to 8 of 8
  1. Maruno
    July 1st, 2010 02:01 PM
    Maruno
    That's... I didn't follow any of that. I'm just glad I found the answer before having to wade through all that thinking it might help.

    I've also extensively modified the scripts too to incorporate a different control style (sorry, no spoilers, but it's good!), so it may have been that any answers wouldn't have helped me in my situation anyway.

  2. Colbex
    June 30th, 2010 03:38 PM
    Colbex
    well you see good sir... o.o;;
    @Maruno: I copied your piece of code into my scripts and commented mine out. I tested giving, taking, canceling out of giving an item, and giving/taking mail. All of it worked fine. Then I tried giving it straight from the bag screen which is where I found your error. It's this one, correct?
    Spoiler:
    Exception: NameError
    Message: undefined local variable or method `ret' for #<PokemonScreen:0x999df68>
    PokemonScreen++:998:in `pbPokemonGiveScreen'
    PokemonBag++:1038:in `pbStartScreen'
    PokemonBag++:1035:in `pbFadeOutIn'
    PokemonBag++:1035:in `pbStartScreen'
    PokemonBag++:961:in `loop'
    PokemonBag++:1053:in `pbStartScreen'
    PokemonMenu+++:172:in `pbStartPokemonMenu'
    PokemonMenu+++:171:in `pbFadeOutIn'
    PokemonMenu+++:171:in `pbStartPokemonMenu'
    PokemonMenu+++:140:in `loop'

    I'm not sure if you noticed, but it's not just giving mail that will give you that error. I can't really tell you how to fix it, but I think it has something to do with how items/mail are given from PokemonBag and the cmdGive function that's used. yours may be a bit different, but here's where I think the hang up is at.
    def pbStartScreen
    Spoiler:
    @scene.pbStartScene(@bag)
    item=0
    loop do
    item=@scene.pbChooseItem
    break if item==0
    pocket=$ItemData[item][ITEMPOCKET]
    cmdUse=-1
    cmdTag=-1
    cmdRegister=-1
    cmdGive=-1
    cmdToss=-1
    cmdCheck=-1
    commands=[]
    ---Skips a few lines talking about pockets---
    Spoiler:
    itemname=PBItems.getName(item) # Get item name
    command=@scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
    if cmdUse>=0 && command==cmdUse
    ret=pbUseItem(@bag,item)
    # ret==0: Item wasn't used; ret==1: Item was used
    if ret==2 # End screen
    break
    end
    @scene.pbRefresh
    next
    elsif cmdCheck>=0 && command==cmdCheck
    pbFadeOutIn(99999){
    pbDisplayMail(PokemonMail.new(item,"",""))
    }
    elsif cmdTag>=0 && command==cmdTag # Berry tag
    elsif cmdRegister>=0 && command==cmdRegister # Register key item
    @bag.pbRegisterKeyItem(item)
    @scene.pbRefresh
    elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
    if $Trainer.pokemonCount==0
    @scene.pbDisplay(_INTL("There is no Pokémon."))
    elsif pbIsImportantItem?(item)
    @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
    else
    # Give item to a Pokémon
    pbFadeOutIn(99999){
    sscene=PokemonScreen_Scene.new
    sscreen=PokemonScreen.new(sscene,$Trainer.party)
    sscreen.pbPokemonGiveScreen(item)
    @scene.pbRefresh
    }
    end
    elsif cmdToss>=0 && command==cmdToss
    qty=@bag.pbQuantity(item)
    helptext=_INTL("Toss out how many {1}(s)?",itemname)
    qty=@scene.pbChooseNumber(helptext,qty)
    if qty>0
    if pbConfirm(_INTL("Is it OK to throw away {1} {2}(s)?",qty,itemname))
    pbDisplay(_INTL("Threw away {1} {2}(s).",qty,itemname))
    qty.times { @bag.pbDeleteItem(item) }
    end
    end
    end
    end
    @scene.pbEndScene
    return item
    end
    end
    I can't actually script in RGSS but my intuition tells me that since ret is handled differently in the bag screen yet the function in the bag calls your edited version of it. The ret's clash or something and causes the problem. I'm 100% not sure if this is correct but hopefully it helped you a litte. =\

    After this deduction it soon occurred to me that the original version did the exact same thing. At this point I was saying crap repeatedly as I had already pressed submit. (your part was beneath the other two folks). Luckily it didn't go through, so I didn't look like an idiot. o-o; I mean... I guess I could just edit the post out but then it looks suspicious... Anyway, after further deduction I realized a lot of things are handled with the aforementioned cmd thingies and their ret thingies and my intuition is severely flawed.........or I'm just a little stupid. o-o On a side note however, reading my submission in a sherlock holmes accent makes it that much funnier.

  3. Maruno
    June 29th, 2010 09:45 AM
    Maruno
    Humour me...

  4. Colbex
    June 28th, 2010 12:18 PM
    Colbex
    actually my work is something more along the lines of comedy... o-o;;

  5. Maruno
    June 28th, 2010 09:50 AM
    Maruno
    I solved it just now, actually, while replying to you. Turns out Ruby is weird, and if a variable is defined within a block (e.g. a "do" loop), then it becomes undefined again once you exit that block. The solution is to define the variable before the "do" loop begins (i.e. copy the line "ret=false" to before the "do" loop), and then it'll be usable after the loop finishes.

    It's not a bug as such, because sometimes programmers will want to use that property of blocks (e.g. use the same name for two different variables, one of which is in-loop only and the other is out-of-loop only), but in those cases I think it's just bad programming style.

    I considered this possibility before, but I dismissed it because it was a stupid thing for Ruby to do. Turns out that's how it works.

    So yeah, it's fine now. Thanks for the offer of help anyway. Might be interested to see what you came up with, though, if you want to PM me your working.

  6. Colbex
    June 27th, 2010 09:14 PM
    Colbex
    hey, did you ever figure out that problem you were having with your "give" or w/e? The one you posted in general game making help? o.o bc... I tried to pay you back by attempting to solve the mystery using my lackluster detective skills and making a big post, only to realize a few seconds afterwards im an idiot. anywho... the point is even though more than likely im way off your free to read my theory. just tell me. XD I save large posts to my notepad, which is good in this case as it didn't go through, therefore i didnt look like a dumbass over the entire game development thread. o.o; im sorry, at late night I get awfully talkative rather than tired...

  7. Maruno
    May 27th, 2010 07:02 AM
    Maruno
    No problem. Just pass on the good deed, if you can.

  8. Colbex
    May 26th, 2010 07:24 PM
    Colbex
    Hey, just thought I'd drop by and say, "You are the man, and thanks for the help with the battle scene." You literally just saved me loads of time and from frustration... a lot of frustration... like... the "Go curse people out on Youtube for making stupid/racist comments just because you're already mad yourself frustration". No lie.


All times are UTC -8. The time now is 10:10 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.