The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

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.


Advertise here

Reply
 
Thread Tools
  #1    
Old August 17th, 2013, 05:38 AM
Kaito123
 
Join Date: Jul 2012
Gender: Male

Advertise here
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 <c3=4f7cc6,354a6d>{2}</c3>!",$Trainer.name,itemname))
     Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der <c3=4f7cc6,354a6d>BASIS-ITEMS</c3>-Tasche.",$Trainer.name,itemname))
   when 4
     pbSEPlay('Item',100,100)
     Kernel.pbMessage(_INTL("{1} erhält <c3=4f7cc6,354a6d>{2}</c3>!",$Trainer.name,itemname))
     Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der <c3=4f7cc6,354a6d>BEEREN</c3>-Tasche.",$Trainer.name,itemname))
   when 3
     pbSEPlay('Item',100,100)
     Kernel.pbMessage(_INTL("{1} erhält <c3=4f7cc6,354a6d>{2}</c3>!",$Trainer.name,itemname))
     Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der <c3=4f7cc6,354a6d>Techn. Maschinen</c3>-Tasche.",$Trainer.name,itemname))
   when 2
     pbSEPlay('Item',100,100)
     Kernel.pbMessage(_INTL("{1} erhält <c3=4f7cc6,354a6d>{2}</c3>!",$Trainer.name,itemname))
     Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der <c3=4f7cc6,354a6d>MEDIZIN</c3>-Tasche.",$Trainer.name,itemname))
   when 1
     pbSEPlay('Item',100,100)
     Kernel.pbMessage(_INTL("{1} erhält <c3=4f7cc6,354a6d>{2}</c3>!",$Trainer.name,itemname))
     Kernel.pbMessage(_INTL("{1} verstaut das Item {2} in der <c3=4f7cc6,354a6d>ITEMS</c3>-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
  #2    
Old August 23rd, 2013, 07:43 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Is this a script within a script?
Or is this it?
Reply With Quote
  #3    
Old August 23rd, 2013, 09:02 AM
Kaito123
 
Join Date: Jul 2012
Gender: Male
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.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
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.
__________________
[STOPPED][DEMO] Pokemon Blue Chrome
[DEVELOPING] S.J.Ware
[DEVELOPING] Tykanite
Reply With Quote
  #5    
Old August 23rd, 2013, 11:59 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
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.
__________________
[STOPPED][DEMO] Pokemon Blue Chrome
[DEVELOPING] S.J.Ware
[DEVELOPING] Tykanite
Reply With Quote
  #7    
Old August 31st, 2013, 12:13 PM
Umbreon's Avatar
Umbreon
Community Supporter
 
Join Date: Aug 2009
Location: Nearby my feet.
Age: 17
Gender: Male
Nature: Calm
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, 06:48 PM
Alexandre's Avatar
Alexandre
 
Join Date: Mar 2005
Age: 19
Nature: Lonely
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

Sponsored Links


Advertise here
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 03:14 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.