Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Polraudio

[REQ]Item Sharing/Storage Script

Recommended Posts

Im wondering if anyone could spare some time to make me a neat script. It doesnt have to be private just for me but for everyone to enjoy and use :D

 

This script needs 2 parts.

 

Part 1: I need a private item storage script that will allow a person to store things like they would in real life and be able to have multiple containers. EX: a pot will be able to store lets say 5 items and a chest will be able to store 25 items but those storage containers are not shared.

If i put items in the pot they wont show up in the chest when i open them and vice versa.

 

Syntax EX: $scene = Scene_Storage[num, size].new

num = the storage id. EX: 1 would be the pot, 2 would be the chest,3 would be whatever, etc....

size = how many items can fit in the container

 

Full syntax in use: $scene = Scene_Storage[1, 5].new

That would mean when the callscript is used it will open container #1 with whatever items the player put in them and the player can put a max of 5 items in it.

 

Part 2: Part 2 might be a little tricky. It needs to be the same as the top one but every item put in these containers is shared across save files.

 

EX: Save 1 puts potions in container 1. When save 2, 3, or 4 access that same container on their save the potions will be in there. when they take the potions out it will no longer be in there for other saves. This is shared storage.

 

Syntax EX: $scene = Scene_SharedStorage[num, size].new

 

Finally the reason for this. The reason for this is because my game is going to be random loot heavy and you will have an item limit so you cant carry 10000lbs worth stuff like other games.

 

The reason for sharing between saves is simple. If you find a rare item and want to give it to a friend on another save file you have the ability to. You dont want to be an assassin and have a weapon you cant use. just give it to another save then :D.

 

If you need more info please feel free to ask :D.

Share this post


Link to post
Share on other sites

Containers that don't teleport their contents trough time and space instantaneously, what blasphemy is this? You are breaking the very foundations of video game physics!

Share this post


Link to post
Share on other sites

1. for the item storage script:

http://forum.chaos-project.com/index.php?topic=3444.0

as for number 2 im thinking it would be pretty simple, simply creating a new save file with a set name and dedicated to storing the stored item info, then getting the script to load and save data to that source, thus creating shared items across saves, i cant look into it now as im pretty busy over the next few days but if no one beats me to it ill give it a crack in a few days :)

Share this post


Link to post
Share on other sites

That one is perfect for number 1.

I would have no clue how to even make that into number 2.

 

Containers that don't teleport their contents trough time and space instantaneously, what blasphemy is this? You are breaking the very foundations of video game physics!

 

Its not really teleporting through time and space. well maybe space but not time well also might be time so yea but not teleportation. More like a multiverse box that can bring items between parallel universes. I will try to figure out a way to explain it in game.

Share this post


Link to post
Share on other sites

one question, as the script sets up chests with id's would you want to configure set id's to be saved that are accessible across other saves or would you want them all to be accessible other the saves, i ask this as you may only want a couple of chests that are accessable over saves, e.g. a home chest, and have other chests in the game that are unique to that save

Share this post


Link to post
Share on other sites

ok i had some free time so here i have it:

SAVE_IDS = [1, 2, 4]
class Scene_Save
 alias decision_items on_decision
 def on_decision(filename)
   decision_items(filename)
   item_file = File.open("item_data", "wb")
   save_items(item_file)
   item_file.close
 end
 def save_items(file)
   chests = []
   (SAVE_IDS).each {|i|
   chests[i] = $game_system.chests(i)
   }
   Marshal.dump(chests, file)
 end
end
class Scene_Title
 alias new_game_items command_new_game
 def command_new_game
   new_game_items
   if FileTest.exist?("item_data")
  item_file = File.open("item_data", "rb")
  chest_data = Marshal.load(item_file)
  (SAVE_IDS).each {|i|
  $game_system.chests[i] = chest_data(i)
  }
  item_file.close
   end
 end
end
class Scene_Load
 alias read_items read_save_data
 def read_save_data(file)
   read_items(file)
   if FileTest.exist?("item_data")
  item_file = File.open("item_data", "rb")
  chest_data = Marshal.load(item_file)
  (SAVE_IDS).each {|i|
  $game_system.chests[i] = chest_data(i)
  }
  item_file.close
   end
 end
end

put this above main and below all defaults,

just add the id's of the chests that are to be saved into the top array, this will create a new file that contains all the relevant data and that file is used to cross over all the data, enjoy :)

ps. let me know if you have any errors, i think i ironed it out but never know

Edited by diagostimo

Share this post


Link to post
Share on other sites

When i try to start a new game after placing things in a shared chest i get this error.

SCoeG.png

SWvIG.png

 

When i try to load after placing things in the shared chest i get this error.

RfCpD.png

Sb9JF.png

 

My testing setup is chest #1 with id 1 no limit and its shared. chest #2 with id 2 no limit and its not shared.

The only id in the shares array is 1.

 

Im also using nothing but the default scripts. This is a brand new project started to test/learn the script before i put it in the actual game.

lPG1P.png

Share this post


Link to post
Share on other sites

hmm strange im sure i got that to work yestarday and its giving me nothing but trouble today, i changed the code slightly, this should work now:

SAVE_IDS = [1, 2, 4]
class Game_Chest
 attr_accessor :items, :weapons, :armors
end
class Scene_Save
 alias decision_items on_decision
 def on_decision(filename)
   decision_items(filename)
   item_file = File.open("item_data", "wb")
   save_items(item_file)
   item_file.close
 end
 def save_items(file)
   chests = []
   (SAVE_IDS).each {|i|
   chests[i] = []
   chests[i].push($game_system.chests(i).items)
   chests[i].push($game_system.chests(i).weapons)
   chests[i].push($game_system.chests(i).armors)
   }
   Marshal.dump(chests, file)
 end
end
class Scene_Title
 alias new_game_items command_new_game
 def command_new_game
   new_game_items
   if FileTest.exist?("item_data")
  item_file = File.open("item_data", "rb")
  chest_data = Marshal.load(item_file)
  (SAVE_IDS).each {|i|
  chest = $game_system.chests(i)
  chest.items = chest_data[i][0]
  chest.weapons = chest_data[i][1]
  chest.armors = chest_data[i][2]
  }
  item_file.close
   end
 end
end
class Scene_Load
 alias read_items read_save_data
 def read_save_data(file)
   read_items(file)
   if FileTest.exist?("item_data")
  item_file = File.open("item_data", "rb")
  chest_data = Marshal.load(item_file)
  (SAVE_IDS).each {|i|
  chest = $game_system.chests(i)
  chest.items = chest_data[i][0]
  chest.weapons = chest_data[i][1]
  chest.armors = chest_data[i][2]
  }
  item_file.close
   end
 end
end

Share this post


Link to post
Share on other sites

Works perfectly :D

Thank you very very much :D

I will be sure to add you to the credits :D

And i cant forget this Rep + 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By troyr
      hello, I came to ask a way or script to center the texts without having to use spaces to center them
      I was for a while looking for a script or something to help me focus the texts in rpg maker vx ace, without success
      So I come to ask directly if anyone has any way to focus the texts, thank you very much. :)
    • By avarisclari
      Is there a simple way to create a script for a cutscene that requires you to have all items in your inventory like id's 001-010 for example?
    • By theneonheart
      I'm looking for help figuring out how to change Ryex's custom menu script to use custom background images for each of the menus. I think this is built into the script, but I am not the greatest at figuring out what to change to get scripts to do what I want them to do.
       
      If you know this script and can help me out I'd appreciate it.
    • By BiddyAuthor
      So I've been hearing about a script for xp. It is supposed enable XP to use VX sprites without editing. I was wondering if anyone had any idea what the script was? I have famitsu sprites that I want to use and for my game and I would rather use the script than edit it. :)
    • Guest
      By Guest
      Lately i started making a dungeon for my game but it doesn't seem you can die outside a battle o.O
      My health stays on 1 (that is displayed yellow)...
       
      So could someone make a script that made possible to die outside a battle?
      or does this already exist? I couldn't find one myself.
       
      (it must be compatible for rmxp)
       
      Thanks,
      mxmmix
×
×
  • Create New...