Script Help

Jack_Gram

Veteran
Veteran
Joined
May 16, 2017
Messages
53
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hello Everyone!
Hope you all had a great holiday :)

So I realize to take away a party's inventory i could use variables to take it all away with giving it back eventually
(standard prison escape affair here)

I saw there was an easy script for VX, is there an easy one for MV?

To take away and store
$game_variables[99] = {}
($data_items + $data_weapons + $data_armors).each{|i|
$game_variables[99] = $game_party.item_number(i)
$game_party.lose_item(i, $game_party.item_number(i)) }


To get back
$game_variables[99].each{|i,a| $game_party.gain_item(i, a)}
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Plug-In Requests. Please be sure to post your threads in the correct forum next time. Thank you.

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Are you sure you've got that entire script correct? I don't think it would work the way you've got it. Looks like some of the code was converted to formatting.

You would need to link back to the original post you took it from, or copy it from the original and paste it into CODE tags so the text isn't converted.
 

Jack_Gram

Veteran
Veteran
Joined
May 16, 2017
Messages
53
Reaction score
5
First Language
English
Primarily Uses
RMMV

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
There's probably a better way, but this will work.

Code:
//Store the items, weapons, armors into variables
$gameVariables.setValue(21, $gameParty._items);
$gameVariables.setValue(22, $gameParty._weapons);
$gameVariables.setValue(23, $gameParty._armors);
//Take away the items, weapons, armors
$gameParty._items = {};
$gameParty._weapons = {};
$gameParty._armors = {};
Code:
//Give back the items, weapons, armors
Object.keys($gameVariables.value(21)).forEach(function(key) {
$gameParty.gainItem($dataItems[key], $gameVariables.value(21)[key]);
});
Object.keys($gameVariables.value(22)).forEach(function(key) {
$gameParty.gainItem($dataWeapons[key], $gameVariables.value(22)[key]);
});
Object.keys($gameVariables.value(23)).forEach(function(key) {
$gameParty.gainItem($dataArmors[key], $gameVariables.value(23)[key]);
});
//Reset the Game Variables
$gameVariables.setValue(21, 0);
$gameVariables.setValue(22, 0);
$gameVariables.setValue(23, 0);
 

Jack_Gram

Veteran
Veteran
Joined
May 16, 2017
Messages
53
Reaction score
5
First Language
English
Primarily Uses
RMMV
Works like a charm! Saved my butt sir!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top