Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Draconius GO
Reply
 
Thread Tools
  #1    
Old August 17th, 2013 (5:38 AM).
Kaito123 Kaito123 is offline
     
    Join Date: Jul 2012
    Gender: Male
    Posts: 61
    Hello, I have a modified script from help-14, with I can get Items. My script is this:

    Code:
    def Gen5GetItem(item,quantity=1)
     itemname=PBItems.getName(item)
     pocket=pbGetPocket(item)
      if $PokemonBag.pbStoreItem(item,quantity)   # If item can be picked up
      case $ItemData[item][ITEMPOCKET]
       when 5
         pbSEPlay('Basisitem',100,100)
         @bg=Sprite.new
         @bg.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/ReceiveItem1")
         @bg.x=([email protected])/2
         @bg.y=([email protected])/4
         @bg.opacity=200
         @item=Sprite.new
         @item.bitmap=BitmapCache.load_bitmap(sprintf("Graphics/Icons/item%03d.png",$ItemData[item][0]))
         @item.x=Graphics.width/[email protected]
         @item.y=Graphics.height/[email protected]
         @item.zoom_x=2
         @item.zoom_y=2
         2.times do
           5.times do
             @item.x+=1
             pbWait(3)
           end
          10.times do
             @item.x-=1
             pbWait(3)
           end
           5.times do
             @item.x+=1
             pbWait(3)
           end
         end
         pbWait(3)
         @item.dispose
         @bg.dispose
         Kernel.pbMessage(_INTL("{1} erhält {2}!",$Trainer.name,itemname))
         Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der BASIS-ITEMS-Tasche.",$Trainer.name,itemname))
       when 4
         pbSEPlay('Item',100,100)
         Kernel.pbMessage(_INTL("{1} erhält {2}!",$Trainer.name,itemname))
         Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der BEEREN-Tasche.",$Trainer.name,itemname))
       when 3
         pbSEPlay('Item',100,100)
         Kernel.pbMessage(_INTL("{1} erhält {2}!",$Trainer.name,itemname))
         Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der Techn. Maschinen-Tasche.",$Trainer.name,itemname))
       when 2
         pbSEPlay('Item',100,100)
         Kernel.pbMessage(_INTL("{1} erhält {2}!",$Trainer.name,itemname))
         Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der MEDIZIN-Tasche.",$Trainer.name,itemname))
       when 1
         pbSEPlay('Item',100,100)
         Kernel.pbMessage(_INTL("{1} erhält {2}!",$Trainer.name,itemname))
         Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der ITEMS-Tasche.",$Trainer.name,itemname))
      end
      return true
     else
      return false
     end
    end
    but, because of this:

    Code:
         @bg=Sprite.new
         @bg.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/ReceiveItem1")
         @bg.x=([email protected])/2
         @bg.y=([email protected])/4
         @bg.opacity=200
         @item=Sprite.new
         @item.bitmap=BitmapCache.load_bitmap(sprintf("Graphics/Icons/item%03d.png",$ItemData[item][0]))
         @item.x=Graphics.width/[email protected]
         @item.y=Graphics.height/[email protected]
         @item.zoom_x=2
         @item.zoom_y=2
         2.times do
           5.times do
             @item.x+=1
             pbWait(3)
           end
          10.times do
             @item.x-=1
             pbWait(3)
           end
           5.times do
             @item.x+=1
             pbWait(3)
           end
         end
         pbWait(3)
         @item.dispose
         @bg.dispose
    I can't save anymore. It the mistake: Save failed....

    Without this section the script is okay ...
    Reply With Quote

    Relevant Advertising!

      #2    
    Old August 23rd, 2013 (7:43 AM).
    Nickalooose Nickalooose is offline
    --------------------
       
      Join Date: Mar 2008
      Gender: Female
      Posts: 1,309
      Is this a script within a script?
      Or is this it?
      Reply With Quote
        #3    
      Old August 23rd, 2013 (9:02 AM).
      Kaito123 Kaito123 is offline
         
        Join Date: Jul 2012
        Gender: Male
        Posts: 61
        This is the script, it is all :D
        Reply With Quote
          #4    
        Old August 23rd, 2013 (10:19 AM).
        Luka S.J.'s Avatar
        Luka S.J. Luka S.J. is offline
        Jealous Croatian
           
          Join Date: Dec 2008
          Location: Croatia
          Age: 24
          Gender: Male
          Nature: Adamant
          Posts: 1,106
          I had problems like that but with the save failing after the VS animation. Some variables can be dumped incorrectly into the save. Try removing the @ for all of the variables (so just have the object name), and see if that fixes it.
          __________________

          Reply With Quote
            #5    
          Old August 23rd, 2013 (11:59 AM).
          Nickalooose Nickalooose is offline
          --------------------
             
            Join Date: Mar 2008
            Gender: Female
            Posts: 1,309
            I know a fix, but I can't answer why it does it in the first place.
            The script needs to be in a class... It's as if the script doesn't "fully" end, which prevents it from saving... Since your script is adding an item, I don't know how it would work calling classes with it... But you can work it out through that.

            @luka s.j

            That doesn't work either, because it was the exact same problem with my GenderSelection script... It's an odd problem, but a problem nonetheless.
            Reply With Quote
              #6    
            Old August 31st, 2013 (11:42 AM).
            Luka S.J.'s Avatar
            Luka S.J. Luka S.J. is offline
            Jealous Croatian
               
              Join Date: Dec 2008
              Location: Croatia
              Age: 24
              Gender: Male
              Nature: Adamant
              Posts: 1,106
              Quote:
              Originally Posted by Nickalooose View Post
              @luka s.j

              That doesn't work either, because it was the exact same problem with my GenderSelection script... It's an odd problem, but a problem nonetheless.
              I never write classes for things like that. Simple defs with only temporary variables never gave me that error. Don't really know why it happens though. But last time I opened up the save file after such an error, I found that undefined variables got dumped into the Marshall structure.
              __________________

              Reply With Quote
                #7    
              Old August 31st, 2013 (12:13 PM).
              ☆Rei☆'s Avatar
              ☆Rei☆ ☆Rei☆ is offline
              • Platinum Tier
               
              Join Date: Aug 2009
              Location: Nearby my feet.
              Age: 21
              Gender: Female
              Nature: Calm
              Posts: 1,749
              Quote:
              Originally Posted by Nickalooose View Post
              I know a fix, but I can't answer why it does it in the first place.

              A variable whose name begins with '@' is an instance variable of self. An instance variable belongs to an object.
              Reply With Quote
                #8    
              Old September 12th, 2013 (6:48 PM).
              Alexandre's Avatar
              Alexandre Alexandre is offline
                 
                Join Date: Mar 2005
                Age: 23
                Nature: Lonely
                Posts: 401
                This is a very easy one to explain. Instance variables are accessible by the whole instance of the certain class that has been loaded. When you save a game, you are infact invoking the 'Marshal.dump' class. Marshal is responsible for serialisation of Ruby objects. With the serialised data, we can store a class and revive it in its exact state whenever we want. The problem with Marshal is that it doesn't work on many base ruby classes. These include File, Socket and then extends into RGSS's basic classes such as viewport and sprite. (and for good reason, imagine trying to serialise a socket connection) The problem here is that an instance variable was created in what I assume to be a class to do with items. It is likely that this class is being dumped by Marshal and since the instance variables that call Sprite are also part of this class, Marshal attempts to dump them too. Sprite is not dumpable so the dump fails. There are two solutions to a problem such as this one:

                The first and the more obvious approach is to simply change the scope of these variables to local variables (they're not gonna get used outside this method anyway).

                The second method is to define your own marshal_dump and marshal_load classes (as stipulated here: http://www.ruby-doc.org/core-2.0.0/Marshal.html) which exclude the instance variables that you don't want dumping. Obviously this is the more tedious option and very much pointless compared to simply changing the scope of the variable.
                Reply With Quote
                Reply

                Quick Reply

                Join the conversation!

                Create an account to post a reply in this thread, participate in other discussions, and more!

                Create a PokéCommunity Account

                Sponsored Links
                Thread Tools

                Posting Rules
                You may not post new threads
                You may not post replies
                You may not post attachments
                You may not edit your posts

                BB code is On
                Smilies are On
                [IMG] code is On
                HTML code is Off

                Forum Jump


                All times are GMT -8. The time now is 8:56 AM.