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

Limited amount of items?

Question

I need something where the player can only pick up a certain number of items at a time, like 10 (doesn't matter how many of each), but has to discard an item to pick up another--which I already evented.

 

I just need a script or a way to event where you can only have a set number of items in inventory or you can't pick up more stuff.

 

Can anyone help me? Thanks!

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I use an item weight script to prevent people from carrying to much and a script made by bigace to allow people to drop items if they are overweight. The weight script makes it so the player cant move till they drop something.

Might want to use a translator for this weight script.

http://pastebin.com/Jk9pFCUe

 

bigaces drop item.

#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# â–  Throw Away Items [RMXP]                                        
# â–  Author: Bigace360   
# â–  Version: 1.00
# â–  Date: April 15, 2013
# â–  Blog: http://bigaceworld.wordpress.com/
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 
#                               VERSION HISTORY                                #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# 04.15.2013 (v1.00) - Started and Finished Script
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                                INTRODUCTION                                  #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# This script allows you to delete items from your inventory.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                                INSTRUCTIONS                                  #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# To install this script, open up your script editor and copy/paste this script
# to an open slot below Scene_Debug, and Warrior_Engine, but above Main.
# 
# Scroll down and edit the module as you see fitting for your game.
# 
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                                  SECTIONS                                    #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#  â–  Game_Objects
# ** ACE_ITEM Module
#
#  â–  Windows
# ** Window_Command_Base
# ** Window_ItemUse
# ** Window_ItemNumber
# ** Window_ItemMessage
# ** Ask_Dispose_Command
#
#  â–  Scenes
# ** Scene_Item
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Credits/Thanks:
#   - Bigace360, for the script.
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                     Script Conflicts and Compatability                       #
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Compatibility
#  Probably will have compatiblity issues with custom Item systems.
#
# â— Alias methods
#   class Scene_Item
#     def main
#
# â— Overwrite methods
#   class Scene_Item
#     def update
#     def update_item
#     def update_target
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Module ACE_ITEM
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module ACE_ITEM
	#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	# â—† Section II. Main Settings â—†
	# -------------------------------------------------------------------------
	# This array adjusts what options appear in the initial item command window
	# before the items are split into separate categories. Add commands, remove
	# commands, or rearrange them. Here's a list of which does what:
	# 
	# -------------------------------------------------------------------------
	# :command         Description
	# -------------------------------------------------------------------------
	# :use             Use selected item if permitted
	# :dispose         disposes selected item if permitted
	# :cancel          Cancels selection
	#
	#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	ITEM_COMMANDS =[
		[:use, 'Use'],
		[:dispose, 'Destroy'],
		[:cancel, 'Cancel']
	]
	
	# Tet alignment of the command window above
	COMMAND_ALIGNMENT = 1
	
	# Items that cannot be disposed of ex. :item => [1,2,8,22....]
	NON_DISPOSABLES ={
		:item => [],
		:weapon => [],
		:armour => []
	}
	
	# The text that goes in the dispose window.
	THROW_TEXT = 'Destroy:'
	
	# A message for those items that cannot be disposed of.
	MESSAGES ={
		:denied => 'You cannot destroy this item!',
		:warning =>	'WARNING! ARE YOU SURE YOU WANT TO DESTROY THIS ITEM!'
	}
	
	#â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—
	# * END OF CUSTOMIZATION SECTION
	#â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—
	
	module_function
	#--------------------------------------------------------------------------
	# convert_integer_array
	#--------------------------------------------------------------------------
	def convert_integer_array(array)
		result = []
		array.each do |i|
			case i
			when Range then result |= i.to_a
			when Integer then result |= [i]
			end 
		end
		return result
	end
	
	#--------------------------------------------------------------------------
	# converted_contants
	#--------------------------------------------------------------------------
	DISPOSE_ITEM   = convert_integer_array(NON_DISPOSABLES[:item])
	DISPOSE_WEAPON = convert_integer_array(NON_DISPOSABLES[:weapon])
	DISPOSE_ARMOUR = convert_integer_array(NON_DISPOSABLES[:armour])
	
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Window_CommandBase
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_CommandBase < Window_Selectable
	attr_reader :commands # command
	def initialize(array, width = 160)
		@data = array[1]
		commands = array[0]
		super(0, 0, width, commands.size * 32 + 32)
		@item_max, @commands = commands.size, commands
		self.contents = Bitmap.new(width - 32, @item_max * 32) 
		refresh
		self.index = 0
	end
	def method; return @data[self.index]; end
	def alignment
		return Menu.main_menu_align 
	end	
	def refresh 
		self.contents = Bitmap.new(width - 32, @item_max * 32) if @item_max > 0
		@item_max.times {|i| draw_item(i)} if @item_max > 0
	end
	def draw_item(index, enabled = true)	
	end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Window_ItemUse
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_ItemUse < Window_CommandBase
	def initialize
		super(make_command_list)
		self.visible = self.active = false
		self.z = 8999
	end	
	def make_command_list
		vocab = []; data = []
		ACE_ITEM::ITEM_COMMANDS.each do |command|
			case command[0]
			when :use, :dispose, :cancel
			else next
			end
			data << command[0]; vocab << command[1]
		end
		return vocab, data		
	end
	def draw_item(index, enable = true)
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    contents.fill_rect(rect, Color.new(0, 0, 0, 0))
		contents.font.color = normal_color
		contents.draw_text(rect, @commands[index], ACE_ITEM::COMMAND_ALIGNMENT)
	end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Window_ItemNumber
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_ItemNumber < Window_ShopNumber
	def initialize
		super
		self.x = (640 - 368) / 2
		self.y = 200
		self.width = 368
		self.height = 96
		self.z = 8999
		@item = nil
		@max = 1
		@number = 1
	end
	def set(item, max)
		@item = item
		@max = max
		@number = 1
		refresh
	end
	def refresh
		contents.clear
		contents.draw_text(0, 0, 200, 32, ACE_ITEM::THROW_TEXT)
		draw_item_name(@item, 4, 24)
    contents.font.color = normal_color
    contents.draw_text(cursor_x - 28, 24, 32, 32, "×")
    contents.draw_text(cursor_x, 24, 28, 32, @number.to_s, 2)
	end
  def cursor_x
    self.width - 12 * 2 - 32 - 4
  end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Window_ItemMessage
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_ItemMessage < Window_Base
	def initialize
		super(0, 0, 480, 96)
		self.contents = Bitmap.new(width - 32, height - 32)
		self.back_opacity = self.opacity = 255
		refresh
	end	
	def refresh
		contents.clear
		contents.font.color = normal_color
		contents.draw_text(0, 0, self.width-32, 32, ACE_ITEM::MESSAGES[:denied], 1)
		contents.draw_text(0, 32, self.width-32, 32, 'Press [Accept] to close', 1)
	end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# â–  Ask_Battle_Command
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Ask_Dispose_Command < Window_Selectable
	def initialize
		commands = ["Yes", "No"]
		super(0, 0, @dw = 480, commands.size * 32 + 80)
		@item_max = commands.size; @commands = commands
		self.contents = Bitmap.new(width - 32, @item_max * 32 + 42)
		refresh
		self.index = 0
		self.z = 9999
		self.back_opacity = self.opacity = 255
	end
	def refresh
		contents.clear
		draw_question
		@item_max.times {|i| draw_item(i)}
	end
	def draw_question
		contents.draw_text(0, 0, @dw-32, 32, ACE_ITEM::MESSAGES[:warning], 1)	
	end
	def dy(i); return (i * 32 + 48); end
	def draw_item(index)
		rect = Rect.new(0, index*32 + 48, contents.width - 8, 32)
		contents.fill_rect(rect, Color.new(0, 0, 0, 0))
		contents.draw_text(rect, @commands[index], 1)
	end
	def update_cursor_rect
		if @index < 0
			self.cursor_rect.clear
		else
			self.cursor_rect.set(0, dy(@index), self.width-32, 32)
		end
	end
end

#==============================================================================
# â–  Scene_Item
#==============================================================================
class Scene_Item
	alias :polraudio_main_dump :main
	def main
		create_command_window
		create_number_window
		create_window_messege
		create_question_window
		polraudio_main_dump
		@command_window.dispose
		@number_window.dispose
		@message_window.dispose
		@window_question.dispose
	end
	def create_command_window
		@command_window = Window_ItemUse.new
		@command_window.x = 320 - @command_window.width / 2
		@command_window.y = 200		
	end
	def create_number_window
		@number_window = Window_ItemNumber.new
		@number_window.contents = Bitmap.new(@number_window.width - 32, 
			@number_window.height - 32)
		@number_window.visible = @number_window.active = false		
	end
	def create_window_messege
		@message_window = Window_ItemMessage.new
		@message_window.visible = false
		@message_window.y = 98
		@message_window.x = 320 - @message_window.width / 2
		@message_window.z = 9999
		@update_text = false
	end
	def create_question_window
		@window_question = Ask_Dispose_Command.new
		@window_question.y = 98
		@window_question.x = 320 - @window_question.width / 2
		@window_question.z = 9999
		@window_question.visible = @window_question.active = false		
	end
	def update
#		@help_window.update
		@item_window.update
		@target_window.update
		@command_window.update
		@number_window.update
		@window_question.update
		if @item_window.active;        update_item
		elsif @target_window.active;   update_target
		elsif @command_window.active;  update_command_selection
		elsif @number_window.active;   update_number_window
		elsif @update_text;            update_text_window
		elsif @window_question.active; update_question_selection
		end
	end
	#--------------------------------------------------------------------------
	# * update_item
	#--------------------------------------------------------------------------
	def update_item
		if Input.trigger?(Input::B)
			$game_system.se_play($data_system.cancel_se)
			$scene = Scene_Menu.new(0)
		elsif Input.trigger?(Input::C)
			@item_window.active = false
      @encumbrance_window.refresh
			@command_window.visible = @command_window.active = true
		end
	end
	#--------------------------------------------------------------------------
	# * update_command_selection
	#--------------------------------------------------------------------------
	def update_command_selection
		if Input.trigger?(Input::C)
			@item = @item_window.item
			case @command_window.method
			when :use then command_use
			when :dispose then command_dispose
			when :cancel 
				$game_system.se_play($data_system.decision_se) 
				command_exit
			end
		elsif Input.trigger?(Input::B)
			command_exit
		end
	end
	def command_use
		unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
			$game_system.se_play($data_system.buzzer_se)
		else
			$game_system.se_play($data_system.decision_se)
			if @item.scope >= 3
				@command_window.visible = @command_window.active = false
				@target_window.x = (@item_window.index + 1) % 2 * 304
				@target_window.visible = @target_window.active = true		
				if @item.scope == 4 || @item.scope == 6
					@target_window.index = -1
				else
					@target_window.index = 0
				end
			else
				if @item.common_event_id > 0
					$game_temp.common_event_id = @item.common_event_id
					$game_system.se_play(@item.menu_se)
					if @item.consumable
						$game_party.lose_item(@item.id, 1)
						@item_window.draw_item(@item_window.index)
					end
					$scene = Scene_Map.new
					return
				end
			end
		end
	end
	def command_dispose
		if item_dumpable?
			$game_system.se_play($data_system.decision_se)
			@number_window.set(@item, max_item)
			@number_window.visible = @number_window.active = true
      @encumbrance_window.refresh
			@command_window.visible = @command_window.active = false
		else
			$game_system.se_play($data_system.buzzer_se)
			@command_window.active = false
			@message_window.visible = @update_text = true
		end
	end
	def item_dumpable?
		if @item.is_a?(RPG::Item)
			!ACE_ITEM::DISPOSE_ITEM.include?(@item.id)
		elsif @item.is_a?(RPG::Weapon)
			!ACE_ITEM::DISPOSE_WEAPON.include?(@item.id)
		elsif @item.is_a?(RPG::Armor)
			!ACE_ITEM::DISPOSE_ARMOUR.include?(@item.id)
		else
			(!@item.nil?)
		end
	end
	def max_item
		number = case @item
		when RPG::Item then $game_party.item_number(@item.id)
		when RPG::Weapon then $game_party.weapon_number(@item.id)
		when RPG::Armor then $game_party.armor_number(@item.id)
		end
		return number
	end
	def command_exit
		@item_window.active = true
		@command_window.index = 0
		@command_window.visible = @command_window.active = false		
	end
	#--------------------------------------------------------------------------
	# * update_number_window
	#--------------------------------------------------------------------------
	def update_number_window
		on_number_view if Input.trigger?(Input::C)
		on_number_back if Input.trigger?(Input::B)
	end
	def on_number_view
		$game_system.se_play($data_system.decision_se)
		@number_window.active = false
		@window_question.visible = @window_question.active = true
	end	
	def on_number_back
		$game_system.se_play($data_system.cancel_se)
		@number_window.visible = @number_window.active = false
		activate_item_window
	end
	def activate_item_window
    @item_window.refresh 
    @encumbrance_window.refresh
		@item_window.active = true
	end
	#--------------------------------------------------------------------------
	# * update_target
	#--------------------------------------------------------------------------
	def update_text_window
		return unless Input.trigger?(Input::C)
		@message_window.visible = @update_text = false
    @encumbrance_window.refresh
		@command_window.active = true
	end
	#--------------------------------------------------------------------------
	# * update_target
	#--------------------------------------------------------------------------
	def update_target
		if Input.trigger?(Input::B)
			$game_system.se_play($data_system.cancel_se)
			@item_window.refresh unless $game_party.item_can_use?(@item.id)
			@target_window.visible = @target_window.active = false
			@command_window.visible = @command_window.active = true
		elsif Input.trigger?(Input::C)
			if $game_party.item_number(@item.id) == 0
				$game_system.se_play($data_system.buzzer_se)
				return
			end
			if @target_window.index == -1
				used = false
				$game_party.actors {|i| used |= i.item_effect(@item)}
			end
			if @target_window.index >= 0
				target = $game_party.actors[@target_window.index]
				used = target.item_effect(@item)
			end
			if used
				$game_system.se_play(@item.menu_se)
				if @item.consumable
					$game_party.lose_item(@item.id, 1)
					@item_window.draw_item(@item_window.index)
				end
				@target_window.refresh
				if $game_party.all_dead?
					$scene = Scene_Gameover.new
					return
				end
				if @item.common_event_id > 0
					$game_temp.common_event_id = @item.common_event_id
					$scene = Scene_Map.new
					return
				end
			end
			unless used
				$game_system.se_play($data_system.buzzer_se)
			end
			return
		end
	end
	#--------------------------------------------------------------------------
	# * update_warning_window
	#--------------------------------------------------------------------------
	def update_question_selection
		open_question if Input.trigger?(Input::C)
		exit_question if Input.trigger?(Input::B)
	end
	def open_question
		case @window_question.index
		when 0 then view_question
		when 1 then exit_question
		end
	end
	def view_question
		do_item_dump(@number_window.number)
		@number_window.visible = false
		@window_question.visible = @window_question.active = false
		activate_item_window		
	end	
	def do_item_dump(number)
		case @item
		when RPG::Item then $game_party.lose_item(@item.id, number)
		when RPG::Weapon then $game_party.lose_weapon(@item.id, number)
		when RPG::Armor then $game_party.lose_armor(@item.id, number)
		end
	end
	def exit_question
		$game_system.se_play($data_system.cancel_se)
		@window_question.visible = @window_question.active = false
		@window_question.index = 0
    @encumbrance_window.refresh
		@number_window.visible = @number_window.active = true
	end
end

Hope these 2 scripts help :)

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.

×
×
  • Create New...