Help - Search - Members - Calendar
Full Version: The Script Builders' Help Topic
RPG RPG Revolution Forums > Scripting > Script Development and Support > Script Requests
Pages: 1, 2
Legacy
The Script Builders' Help Topic

- Refuge for scripters everywhere, get your problems sorted here. -



Introduction

Welcome to the Script Builders' Help Topic. If you have come to this topic, you are probably looking for help with a script you have found, or are making. Well this is the aim of this topic. The Script Builders will try their hardest to help you out with buggy script errors that you may encounter, or maybe you have a question about a function like how to display an item's name from a script. Well all you'll need to do is follow the simple rules and fill in the request form which are found further on.


Rules

Here are just a few rules to help keep this much easier.

Please do not pressure us. Once we have recieved your request, we will work on it and will work in the order that we have recived the scripts in. So please be patient. Also, this is a must: do not spam this topic, this is a serious topic that we have created to bring you the most support we can, if you want to spam please do it in the Off-Topic Cesspool. One more rule, please be kind to the Script builders as we are giving up our spare time to try and help your own problems, we won't have a go at you if it's something very simple, but saying that we do not expect you to have a go at us if we get it wrong.

Thank you for following and reading these rules.


Request Form

To help us to help you more efficently, try and follow the form bellow to give us the most infomation about the error or question you need.

Form:

Link to Script Topic (If needed):

(If not the above)Actual script:

Error or problem you have encountered (Please explain in as much detail as you can, screen shots of the error work wonders):


Conclusion

Please post your request here in this topic, or if you think its urgent, you may PM the following people.

- Legacy
- The Law G14
- Night_Runner
- Night5h4d3
- Juan

Please try to explain your problem in full detail, this will make it faster to find the problem. Also, when PMing either of the above members, please try to use the form above.

Thank you
- Legacy -
The Law G14
Great work on this Legacy smile.gif

I fixed all the little mistakes in the thread and pinned the topic. So if you need any script support, just come on in smile.gif
Legacy
hmm, no requests? None at all...
The Law G14
Hey, no requests at all? Any feedback or ideas for this, RRR?
dummy1234
I'm not really sure if this question belongs here pinch.gif but still:

Is it possible to have a script that can activate/deactivate other scripts with in-game commands? [similar to the tons-of-addns thing]

Eventhough I'm overly busy with other stuff, if that's possible, I'd give it a shot and try to make it.
[example of use: have a battler or a sideview battlestyles depending depending on the creature you fight by adding a activation script line before battle processing]

So yeah sweat.gif probably wrong place to ask, but since noone else is asking anything mightaswell use it to bump the topic sweat.gif
Darkreaper
If youre answering questions i have 3

Would it be possible to create a script that copies an existing event and places the copy at a location you specify?

Is it possible to create a script that calls up the item menu, lets you select an item and then stores the value of the item to a variable?

And how bout a script that matches X and Y coordinates to a set of variables and then identifies the parent event?
(So you dont need to write a list of if statements a mile long)
The Law G14
@Dummy: Hm, that seems like something really difficult to do. I do know of an easy way to deactivate a whole script very easily by putting

CODE
=begin


at the beginning of the script which will comment out everything below it. If that's not what you're looking for, I have an idea on how you could go about doing this.

@Darkreaper: I don't have your first or third questions figured out yet, but for your second question, I have a pretty rough draft of what I think you're looking for:

CODE
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs item screen processing.
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias law_item_variable_update_item update_item
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    law_item_variable_update_item
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      $game_variables[1] = @item
      $scene = Scene_Map.new
    end
  end
end


Just open up your item screen, pick an item, and it should be saved in variable 1. You can change what variable it is stored in the 5th to last line of the script.
Darkreaper
awesome, where would i install that?
Night_Runner
Darkreaper? I remember Charlie Lee & Ty tried answering your question.....
Basically, Sephiroth's script isn't what you're after, it lets you make events, not make copies of them.
Charlie's Auto Populate script hosted here only lets you create copies of events. Unfortunately, I think you need to sign up to RMVXP to see the post, but you won't be able to understand what's going on without Charlie's instructions...
I don't think charlie's script lets you just put the event's clone at a position, but I've got an edited version I can PM you if you want (I got the impression he wouldn't appreciate me posting it here).


2) If you go into the Script Editor, and scroll down to the bottom there should be Main, just right click and insert The Law's script before Main, but Scene_Debug smile.gif


Oh well, I've made a script for your question 3, read through the instructions a the start, but basically have an event run:
CODE
event_at(7, 8, 9)
and it will look in variable #7 for the x, variable #8 for the y, and return the event at (x, y) in variable #9
[Show/Hide] Night_Runner's Event_At script
CODE
#==============================================================================
# ** Night_Runner's Event_At Script
#------------------------------------------------------------------------------
# Date Created: 5/Dec/09
#      Version: 1.0
# Created for Darkreaper
#  @> http://www.rpgrevolution.com/forums/index.php?showtopic=37119
#
# DESCRIPTION:
#  This script is designed to find the event at a certain x and y coordinates,
#   and return the event's ID number, or 0 if no events are present.
#
# USAGE:
#  Have an event run the script:
#    event_at(3, 4, 5)
#   and this script will look in the game variable 3 for the x coordinate, the
#   game variable 4 for the y coordinate, and will return the event's ID in the
#   game variable 5.
#
#==============================================================================



#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  Edited to have the event_at command
#==============================================================================


class Interpreter
  #----------------------------------------------------------------------------
  # * Event at (x-coordinate-variable, y-coordinate-variable,
  #              event_id-variable)
  #----------------------------------------------------------------------------
  def event_at(x_var, y_var, ret_var)
    # Get the x & y from the variable
    x = $game_variables[x_var]
    y = $game_variables[y_var]
    # Set the variable to 0 by default
    $game_variables[ret_var] = 0
    # For each event
    for event in $game_map.events.values
      # If the event's x & y match
      if event.x == x and event.y == y
        # Set the variable to the event ID
        $game_variables[ret_var] = event.id
        # Break the for loop
        break
      end
    end
  end
end



#==============================================================================
# END OF SCRIPT
#==============================================================================
Darkreaper
wow thats awesome biggrin.gif
The Law G14
So you got all your questions answered Darkreaper or are you still having some issues?
Darkreaper
QUOTE (The Law G14 @ Dec 4 2009, 06:22 PM) *
@Darkreaper: I don't have your first or third questions figured out yet, but for your second question, I have a pretty rough draft of what I think you're looking for:

CODE
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs item screen processing.
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias law_item_variable_update_item update_item
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    law_item_variable_update_item
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      $game_variables[1] = @item
      $scene = Scene_Map.new
    end
  end
end


Just open up your item screen, pick an item, and it should be saved in variable 1. You can change what variable it is stored in the 5th to last line of the script.


So i think it kinda works, but not how i need it.
What im using it for is for cooking:
Say you have an apple and a fish, you make a fire and want to cook some food. So you "use" the fire and it pulls up your inventory screen and lets you choose what you want to cook. You pick the fish, it removes the fish item and after a little bit gives you a "Cooked Fish" item
The Law G14
Sorry for the late response, but does this item screen only inlcdue items that can be cooked or just any item in your inventory inlcuding weapons and armor?
Darkreaper
well id prefer it if it was only "cookable" items, but i dont know if thats possible or worth the trouble
The Law G14
Yeah, that's possible so I'll try to get this script in to you in the next couple of days smile.gif
Darkreaper
Sweet, thatd be of great help biggrin.gif
The Law G14
This is a rough draft of what I have so far. Just make an event and go to the third page of the list of event commands and click Script. Type in this code:

CODE
$scene = Scene_Cooking.new


To change what variable the item is stored in, go to line 81 of the script.

Hope I was at least kind of close lol:


CODE
#==============================================================================
# ** Scene_Cooking
#------------------------------------------------------------------------------
#  This class performs cooking screen processing.
#==============================================================================

class Scene_Cooking
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @cooking_window = Window_Cooking.new
    # Associate help window
    @cooking_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @cooking_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @cooking_window.update
    # If cooking window is active: call update_cooking
    if @cooking_window.active
      update_cooking
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_cooking
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @cooking_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      $game_variables[1] = @item
      $scene = Scene_Map.new
      # If command event ID is valid
      if @item.common_event_id > 0
        # Command event call reservation
        $game_temp.common_event_id = @item.common_event_id
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Draw item window item
          @item_window.draw_item(@item_window.index)
        end
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end
    return
  end
end

#==============================================================================
# ** Window_Cooking
#------------------------------------------------------------------------------
#  This window displays cooking items in possession.
#==============================================================================

class Window_Cooking < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

Darkreaper
QUOTE (The Law G14 @ Dec 10 2009, 02:05 PM) *
This is a rough draft of what I have so far. Just make an event and go to the third page of the list of event commands and click Script. Type in this code:

CODE
$scene = Scene_Cooking.new


To change what variable the item is stored in, go to line 81 of the script.

Hope I was at least kind of close lol:


CODE
#==============================================================================
# ** Scene_Cooking
#------------------------------------------------------------------------------
#  This class performs cooking screen processing.
#==============================================================================

class Scene_Cooking
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @cooking_window = Window_Cooking.new
    # Associate help window
    @cooking_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @cooking_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @cooking_window.update
    # If cooking window is active: call update_cooking
    if @cooking_window.active
      update_cooking
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_cooking
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @cooking_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      $game_variables[1] = @item
      $scene = Scene_Map.new
      # If command event ID is valid
      if @item.common_event_id > 0
        # Command event call reservation
        $game_temp.common_event_id = @item.common_event_id
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Draw item window item
          @item_window.draw_item(@item_window.index)
        end
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end
    return
  end
end

#==============================================================================
# ** Window_Cooking
#------------------------------------------------------------------------------
#  This window displays cooking items in possession.
#==============================================================================

class Window_Cooking < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end


Works perfectly up until i pick an item in the inventory prompt, then it errored out. Also the icon for the item showed up but not the name
????? 'Cooking' ? 94 ??? NoMethodError ???????
undefined method 'index' for nil:NilClass
Zeriab
@Dummy:
Assuming you mean whether it's possible to activate/deactive scripts dynamically in-game then I am afraid it's in the general case impossible. I believe that problem is undecidable. If it is, then it is impossible to write an algorithm which solves the problem in the general case.
In that case I would suggest dealing with it application specific. I.e. customizing the scripts so they can be turned on and off dynamically.

If you are talking about statically say not evaluating certain sections, then that is very much possible.

*hugs*
The Law G14
@Darkreaper: Did you put weapons or armor in there? I only made it so that it included items only but I can add weapons and armor if you want. Also, do you have any other custom scripts?
Darkreaper
QUOTE (The Law G14 @ Dec 11 2009, 01:43 PM) *
@Darkreaper: Did you put weapons or armor in there? I only made it so that it included items only but I can add weapons and armor if you want. Also, do you have any other custom scripts?

No i didnt try it with armour or anything, just with items and this is the only custom script i have so far
The Law G14
Ah, I found out what the problem is, just change that line that has an error, which should be line 94, to this:

CODE
@cooking_window.draw_item(@cooking_window.index)
Darkreaper
QUOTE (The Law G14 @ Dec 11 2009, 05:55 PM) *
Ah, I found out what the problem is, just change that line that has an error, which should be line 94, to this:

CODE
@cooking_window.draw_item(@cooking_window.index)

ok no error now laugh.gif but still not showing the item names, just the icon. Tried cooking a few items, but i think they just ended up using them, it did store the value of the item to the variable though. Although its a long string and im not sure what it means
The Law G14
That's weird, it should be displaying the item name, what does your event look like?
Darkreaper
QUOTE (The Law G14 @ Dec 11 2009, 06:52 PM) *
That's weird, it should be displaying the item name, what does your event look like?

which one, the cooking event? or the display variable event?
The Law G14
The cooking event. Also, I've got around making it so that it doesn't show a long string of text when you talk to the display variable event. I've added another $game_variable at line 82 of the script. Just display that variable if you'd like to show the name of the item:

CODE
#==============================================================================
# ** Scene_Cooking
#------------------------------------------------------------------------------
#  This class performs cooking screen processing.
#==============================================================================

class Scene_Cooking
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @cooking_window = Window_Cooking.new
    # Associate help window
    @cooking_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @cooking_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @cooking_window.update
    # If cooking window is active: call update_cooking
    if @cooking_window.active
      update_cooking
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_cooking
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @cooking_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      $game_variables[1] = @item.name
      $game_variables[2] = @item
      $scene = Scene_Map.new
      # If command event ID is valid
      if @item.common_event_id > 0
        # Command event call reservation
        $game_temp.common_event_id = @item.common_event_id
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Draw item window item
          @cooking_window.draw_item(@cooking_window.index)
        end
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end
    return
  end
end

#==============================================================================
# ** Window_Cooking
#------------------------------------------------------------------------------
#  This window displays cooking items in possession.
#==============================================================================

class Window_Cooking < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

Darkreaper
drew this error soon as i tried to cook something
????? 'Interpreter 4' ? 161 ??? Argument Error ?????
comparison of String with 99999999 failed
The Law G14
Did you put in the game variable for the string of text for the item or the actual item because it's important that you keep them seperate. The first game variable (the one that you had already set) is for cooking, the new one is for showing the item's name. Just send me a PM with the project that has your cooking event and I'll see what I can do smile.gif
Darkreaper
oh whoops :S so wait, what? which ones which? im confused now
The Law G14
First of all, I've updated the script a little bit:

CODE
#==============================================================================
# ** Scene_Cooking
#------------------------------------------------------------------------------
#  This class performs cooking screen processing.
#==============================================================================

class Scene_Cooking
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @cooking_window = Window_Cooking.new
    # Associate help window
    @cooking_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @cooking_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @cooking_window.update
    # If cooking window is active: call update_cooking
    if @cooking_window.active
      update_cooking
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_cooking
    # If B button was pressed
    if Input.trigger?(Input::B)
      unless $game_party.item_can_use?(@item.id)
        # Remake item window contents
        @cooking_window.refresh
      end
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @cooking_window.item
      target = $game_party.actors[@cooking_window.index]
      used = target.item_effect(@item)
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      # Decrease used items by 1
      $game_party.lose_item(@item.id, 1)
      # Redraw item window item
      @cooking_window.draw_item(@cooking_window.index)
      $game_variables[1] = @item.name
      $game_variables[2] = @item
      $scene = Scene_Map.new
      if @item.common_event_id > 0
        # Command event call reservation
        $game_temp.common_event_id = @item.common_event_id
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Draw item window item
          @cooking_window.draw_item(@cooking_window.index)
        end
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end
    return
  end
end


#==============================================================================
# ** Window_Cooking
#------------------------------------------------------------------------------
#  This window displays cooking items in possession.
#==============================================================================

class Window_Cooking < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end


On line 90 of the script is where you put what game_variable is assigned the item name. On line 91 is where you put what game_variable is assigned the actual item, which is what you use to cook.
Darkreaper
ok, very interesting outcome now, when i go to cook an apple, i get a game over, when i try to cook a fish i get this error
????? 'Cooking' ? 72 ??? NoMethodError ?????
undefined method 'item_effect' for nil:NilClass


there something im missing here?
The Law G14
Weird, just send me a demo of your project via PM and I'll edit everything from there smile.gif
Darkreaper
how do you upload an attachment into a pm? mellow.gif
The Law G14
Sadly, you can't have any attachments in PMs so your going to have to use sort sort of uploading site like Megaupload or Mediafire.
tagg1080
I am sure you guys would appreciate the necro-post, xD


This is a noob question, but I have been having a little trouble trying to figure it out:

RPGM VX, how do I use game variables in a script?
( I understand you guys are in the XP section, but I noticed this was untouched, and thought I might give you guys a small question to answer)


Right now I have a script that adds to stats on level up. (reijubv's)



It works with a hash:


Actor_MaxInc[1] = [ 5 , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment
Actor_MinInc[1] = [ 1 , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment

So the question is, how do I replace the numbers up there^ with game variables?


@game_variable[X] is the right syntax?

But if I place that into the hash, I get a syntax error, so do I need to create separate variables in script, and set then to the variables I want to use, and then make the array with those?

Or is there a more simple way?
The Law G14
Well, you got the syntax for variables a little wrong, it should look like this:

CODE
$game_variables[X]


Try putting that into your array to see if it works smile.gif
tagg1080
QUOTE (The Law G14 @ Jan 8 2010, 05:38 PM) *
Well, you got the syntax for variables a little wrong, it should look like this:

CODE
$game_variables[X]


Try putting that into your array to see if it works smile.gif




Line 86:

Actor_MaxInc[1] = [ $game_variables[9] , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0]


(Working) Line 86:

Actor_MaxInc[1] = [ 5 , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0]

Thank you for correction, but I still get^
The Law G14
Then put above that line, this:

CODE
x = $game_variables[9]


then replace line 86 with this:

CODE
Actor_MaxInc[1] = [ x, 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0]
tagg1080
QUOTE (The Law G14 @ Jan 8 2010, 09:00 PM) *
Then put above that line, this:

CODE
x = $game_variables[9]


then replace line 86 with this:

CODE
Actor_MaxInc[1] = [ x, 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0]


#=========================================================================
======
# > [VX] Rei Levelup Stat Randomizer
#-------------------------------------------------------------------------------
# > by reijubv [aruyasoft@comic.com]
# > RPG RPG Revolution
# > Released on: 27/04/2009
# > Version: 1.1 (April 25th 2009)
#-------------------------------------------------------------------------------
# > Changelog:
# V.1.0 (25-04-09) = Initial release
# V.1.1 (29-04-09) = Added a function to restore HP/MP to max when level up
# V.1.1a (30-04-09) = Fixed a small bug wich I forgot to write something in
# the script that can makes the game crashes.....
#-------------------------------------------------------------------------------
# > Information:
# This script will modify an actor's stats gain on level up by a random number
# between maximum and minimum amount that you can specify for each actors.
# For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5,
# when that actor gains a level, he/she'll gains AGI by random number between 1 to 5!
# I suggest you set actor's stats in database to the same from his/her starting level
# to 99, so if in database your actor's HP at starting level is 100, from that level
# to 99 the HP should not be changed! This's just a suggestion anyway....
#-------------------------------------------------------------------------------
# > Compatibility :
#
# * Aliases :
# class Game_Actor
# def setup
# def base_maxhp
# def base_maxmp
# def base_atk
# def base_def
# def base_spi
# def base_agi
# def hit
# def eva
# def cri
# * Rewrites :
# class Game_Actor
# def level_up
# def level_down
#-------------------------------------------------------------------------------
# Credit reijubv if you use this script....
# Credit woratana for his recover HP/MP/States when Level Up script
#-------------------------------------------------------------------------------
# > Installation:
# Put this script above main, setup script below.
#==========================================================================
module Rei
module RandStat
#----------------------------------------------------------------------------
# * Create Arrays
#----------------------------------------------- ----------------------------
Actor_MaxInc = Array.new
Actor_MinInc = Array.new
#----------------------------------------------------------------------------
# * HP/MP/STATE Restoration Setting (CREDIT TO WORATANA FOR THIS FUNCTIONS)
#----------------------------------------------------------------------------
RECOVER_HP = true # Recover HP when level up? (true/false)
RECOVER_MP = true # Recover MP when level up?
REMOVE_STATES = true # Cure all states when level up?
#--------------------Setup each actors below----------------------------------
# Use this template :
#
# Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI]
# > This setup actor #'s each stats' maximum increments
#
# Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI]
# > This setup actor #'s each stats' minimum increments
#
# Use 0 if you don't want to increase any stat on level up
#
# Note : >Actor_MaxInc should be higher than Actor_MinInc!
# >Don't use negative values, or your actor's stats would be messed up!
# >Don't forget to setup max and min value for EVERY actors that you used
# in your game!
#
# Just in case that you don't know :
#
# HP = Hit Points DEF = Defense HIT = Hit rate
# MP = Magic Points SPI = Spirit EVA = Evasion rate
# ATK = Attack AGI = Agility CRI = Critical rate
#----------------------------------------------------------------------------
#Samples :
# actorId HP MP ATK DEF SPI AGI HIT EVA CRI

x = $game_variables[9]
y = $game_variables[8]

Actor_MaxInc[1] = [ x , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment
Actor_MinInc[1] = [ y , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment

end
end

#==========================================================================

# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. Its used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==========================================================================


class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
alias reisetup setup
def setup(actor_id)
@stat_gains = {}
for i in 0..8
@stat_gains[i] = []
end
reisetup(actor_id)
end
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
alias reibasemaxhp base_maxhp
def base_maxhp
n = reibasemaxhp
n+= @stat_gains[0].sum
return n
end
#--------------------------------------------------------------------------
# * Get basic Maximum MP
#--------------------------------------------------------------------------
alias reibasemaxmp base_maxmp
def base_maxmp
n = reibasemaxmp
n+= @stat_gains[1].sum
return n
end
#--------------------------------------------------------------------------
# * Get Basic Attack
#--------------------------------------------------------------------------
alias reibaseatk base_atk
def base_atk
n = reibaseatk
n+= @stat_gains[2].sum
return n
end
#--------------------------------------------------------------------------
# * Get Basic Defense
#--------------------------------------------------------------------------
alias reibasedef base_def
def base_def
n = reibasedef
n+= @stat_gains[3].sum
return n
end
#--------------------------------------------------------------------------
# * Get Basic Spirit
#--------------------------------------------------------------------------
alias reibasespi base_spi
def base_spi
n = reibasespi
n+= @stat_gains[4].sum
return n
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
alias reibaseagi base_agi
def base_agi
n = reibaseagi
n+= @stat_gains[5].sum
return n
end
#--------------------------------------------------------------------------
# * Get Hit Rate
#--------------------------------------------------------------------------
alias reihit hit
def hit
n = reihit
n+= @stat_gains[6].sum
return n
end
#--------------------------------------------------------------------------
# * Get Evasion Rate
#--------------------------------------------------------------------------
alias reieva eva
def eva
n = reieva
n+= @stat_gains[7].sum
return n
end
#--------------------------------------------------------------------------
# * Get Critical Ratio
#--------------------------------------------------------------------------
alias reicri cri
def cri
n = reicri
n+= @stat_gains[8].sum
return n
end
#--------------------------------------------------------------------------
# * Level Up
#--------------------------------------------------------------------------
def level_up
r = {}
a = {}
b = {}
@level += 1
for i in 0..8
a[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i]
b[i] = Rei::RandStat::Actor_MinInc[@actor_id][i]
r[i] = b[i]+rand(a[i]-b[i]+1)
if r[i] <= Rei::RandStat::Actor_MinInc[@actor_id][i] then
r[i] = Rei::RandStat::Actor_MinInc[@actor_id][i]
end
if r[i] >= Rei::RandStat::Actor_MaxInc[@actor_id][i] then
r[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i]
end
@stat_gains[i] << r[i]
end

#from woratana's script v
@hp = maxhp if Rei::RandStat::RECOVER_HP
@mp = maxmp if Rei::RandStat::RECOVER_MP
if Rei::RandStat::REMOVE_STATES
@states.clone.each {|i| remove_state(i) }
end
#from woratana's script ^

for learning in self.class.learnings
learn_skill(learning.skill_id) if learning.level == @level
end
end
#--------------------------------------------------------------------------
# * Level Down
#--------------------------------------------------------------------------
def level_down
@level-= 1
for i in 0..8
@stat_gains[i].pop
end
end
end
#==========================================================================
# ** Array
#------------------------------------------------------------------------------
# This hidden class handles arrays. It is used within many other
# classes to store data for future retrieval.
#==========================================================================

class Array
#---------------------------------------------------------------------------
# * Name : Sum
# Info : Sums all values in the array
# Author : Trickster
# Call Info : No Arguments
#---------------------------------------------------------------------------
def sum
# Initialize local variable n
n = 0
# Sum Up Values in Array
each {|num| n += num}
# Return number
return n
end
end



That is the script^


I am still getting a null error, even with that attempt^

I can't find any solution, so even a messy one would be fine, xD
Night_Runner
The problem is that $game_variables isn't yet defined ....
Somewhere in Scene_Title it defines $game_variables = Game_Variables.new, but it reaches this bit of code before it reaches Scene_Title ....

Sorry, ummmmmmmmm, try something like this, it's mostly the same, but kinda not....


[Show/Hide] some code....
CODE
#===============================================================================
  # >  [VX]  Rei Levelup Stat Randomizer  
  #-------------------------------------------------------------------------------
  # >  by reijubv [aruyasoft@comic.com]
  # >  RPG RPG Revolution
  # >  Released on: 27/04/2009
  # >  Version: 1.1 (April 25th 2009)
  #-------------------------------------------------------------------------------
  # > Changelog:
  #   V.1.0 (25-04-09) = Initial release
  #   V.1.1 (29-04-09) = Added a function to restore HP/MP to max when level up
  #   V.1.1a (30-04-09) = Fixed a small bug wich I forgot to write something in
  #                                    the script that can makes the game crashes.....
  #-------------------------------------------------------------------------------
  # >  Information:
  # This script will modify an actor's stats gain on level up by a random number
  # between maximum and minimum amount that you can specify for each actors.
  # For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5,
  # when that actor gains a level, he/she'll gains AGI by random number between 1 to 5!
  # I suggest you set actor's stats in database to the same from his/her starting level
  # to 99, so if in database your actor's HP at starting level is 100, from that level
  # to 99 the HP should not be changed! This's just a suggestion anyway....
  #-------------------------------------------------------------------------------
  # >  Compatibility :
  #
  #   * Aliases :
  #               class Game_Actor
  #                 def setup
  #                 def base_maxhp
  #                 def base_maxmp
  #                 def base_atk
  #                 def base_def
  #                 def base_spi
  #                 def base_agi
  #                 def hit
  #                 def eva
  #                 def cri
  #   * Rewrites :
  #               class Game_Actor
  #                 def level_up
  #                 def level_down
  #-------------------------------------------------------------------------------
  # Credit reijubv if you use this script....
  # Credit woratana for his recover HP/MP/States when Level Up script
  #-------------------------------------------------------------------------------
  # > Installation:
  # Put this script above main, setup script below.
  #==========================================================================
  module Rei
    module RandStat
     #----------------------------------------------------------------------------
     # * Create Arrays
     #----------------------------------------------- ----------------------------
      Actor_MaxInc = Array.new
      Actor_MinInc = Array.new
     #----------------------------------------------------------------------------
     # * HP/MP/STATE Restoration Setting (CREDIT TO WORATANA FOR THIS FUNCTIONS)
     #----------------------------------------------------------------------------
      RECOVER_HP    = true # Recover HP when level up? (true/false)
      RECOVER_MP    = true # Recover MP when level up?
      REMOVE_STATES = true # Cure all states when level up?
     #--------------------Setup each actors below----------------------------------    
     # Use this template :
     #
     # Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI]
     # >  This setup actor #'s each stats' maximum increments
     #
     # Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI]
     # >  This setup actor #'s each stats' minimum increments  
     #  
     # Use 0 if you don't want to increase any stat on level up
     #
     # Note : >Actor_MaxInc should be higher than Actor_MinInc!
     #        >Don't use negative values, or your actor's stats would be messed up!
     #        >Don't forget to setup max and min value for EVERY actors that you used
     #         in your game!
     #
     # Just in case that you don't know :
     #
     # HP  = Hit Points          DEF = Defense        HIT = Hit rate
     # MP  = Magic Points        SPI = Spirit        EVA = Evasion rate
     # ATK = Attack              AGI = Agility        CRI = Critical rate
     #----------------------------------------------------------------------------
     #Samples  :
     #         actorId   HP MP ATK DEF SPI AGI HIT EVA CRI
     #--------------------------------------------------------------------------
     # Maximum Increment
     #--------------------------------------------------------------------------
     def Actor_MaxInc(actor_id, stat)
       return if $game_variables.nil?
       actor_MaxInc[1] = [ $game_variables[8] , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment
       #etc
       return actor_MaxInc[actor_id][stat]
     end
     #--------------------------------------------------------------------------
     # Minimum increment
     #--------------------------------------------------------------------------
     def Actor_MinInc(actor_id, stat)
       return if $game_variables.nil?
       actor_MinInc[1] = [ $game_variables[9] , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment
       # etc
       return actor_MinInc[actor_id][stat]
     end
    end
  end
  
  #==========================================================================
  # ** Game_Actor
  #------------------------------------------------------------------------------
  #  This class handles actors. Its used within the Game_Actors class
  # ($game_actors) and referenced by the Game_Party class ($game_party).
  #==========================================================================

  
  class Game_Actor < Game_Battler
    #--------------------------------------------------------------------------
    # * Setup
    #     actor_id : actor ID
    #--------------------------------------------------------------------------
    alias reisetup setup
    def setup(actor_id)
      @stat_gains = {}
      for i in 0..8
        @stat_gains[i] = []
      end
      reisetup(actor_id)
    end
    #--------------------------------------------------------------------------
    # * Get Basic Maximum HP
    #--------------------------------------------------------------------------
    alias reibasemaxhp base_maxhp
    def base_maxhp
      n = reibasemaxhp
      n+= @stat_gains[0].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get basic Maximum MP
    #--------------------------------------------------------------------------
    alias reibasemaxmp base_maxmp
    def base_maxmp
      n = reibasemaxmp
      n+= @stat_gains[1].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Basic Attack
    #--------------------------------------------------------------------------
    alias reibaseatk base_atk
    def base_atk
      n = reibaseatk
      n+= @stat_gains[2].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Basic Defense
    #--------------------------------------------------------------------------
    alias reibasedef base_def
    def base_def
      n = reibasedef
      n+= @stat_gains[3].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Basic Spirit
    #--------------------------------------------------------------------------
    alias reibasespi base_spi
    def base_spi
      n = reibasespi
      n+= @stat_gains[4].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Basic Agility
    #--------------------------------------------------------------------------
    alias reibaseagi base_agi
    def base_agi
      n = reibaseagi
      n+= @stat_gains[5].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Hit Rate
    #--------------------------------------------------------------------------
    alias reihit hit
    def hit
      n = reihit
      n+= @stat_gains[6].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Evasion Rate
    #--------------------------------------------------------------------------
    alias reieva eva
    def eva
      n = reieva
      n+= @stat_gains[7].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Get Critical Ratio
    #--------------------------------------------------------------------------
    alias reicri cri
    def cri
      n = reicri
      n+= @stat_gains[8].sum
      return n
    end
    #--------------------------------------------------------------------------
    # * Level Up
    #--------------------------------------------------------------------------
    def level_up
      r = {}
      a = {}
      b = {}
      @level += 1
      for i in 0..8
        a[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
        b[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
        r[i] = b[i]+rand(a[i]-b[i]+1)
        if r[i] <= Rei::RandStat::Actor_MinInc(@actor_id, i) then
          r[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
        end
        if r[i] >= Rei::RandStat::Actor_MaxInc(@actor_id, i) then
          r[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
        end
        @stat_gains[i] << r[i]
      end
      
      #from woratana's script v
      @hp = maxhp if Rei::RandStat::RECOVER_HP
      @mp = maxmp if Rei::RandStat::RECOVER_MP
      if Rei::RandStat::REMOVE_STATES
        @states.clone.each {|i| remove_state(i) }
      end
      #from woratana's script ^
      
      for learning in self.class.learnings
        learn_skill(learning.skill_id) if learning.level == @level
      end
    end
    #--------------------------------------------------------------------------
    # * Level Down
    #--------------------------------------------------------------------------
    def level_down
      @level-= 1
      for i in 0..8
        @stat_gains[i].pop
      end
    end
  end
  #==========================================================================
  # ** Array
  #------------------------------------------------------------------------------
  #  This hidden class handles arrays. It is used within many other
  # classes to store data for future retrieval.
  #==========================================================================

  class Array
    #---------------------------------------------------------------------------
    # * Name      : Sum
    #   Info      : Sums all values in the array
    #   Author    : Trickster
    #   Call Info : No Arguments
    #---------------------------------------------------------------------------
    def sum
      # Initialize local variable n
      n = 0
      # Sum Up Values in Array
      each {|num| n += num}
      # Return number
      return n
    end
  end


It doesn't error out, but then again, I have no idea what the script actually does or how it works (sorry)

If it doesn't work, it will need a more manual approach, so I'll need to know specifically which stats follow a variable, and it will be applied to every actor...
tagg1080
QUOTE (Night_Runner @ Jan 11 2010, 12:45 AM) *
The problem is that $game_variables isn't yet defined ....
Somewhere in Scene_Title it defines $game_variables = Game_Variables.new, but it reaches this bit of code before it reaches Scene_Title ....

Sorry, ummmmmmmmm, try something like this, it's mostly the same, but kinda not....


[Show/Hide] some code....
CODE
#===============================================================================
   # >  [VX]  Rei Levelup Stat Randomizer  
   #-------------------------------------------------------------------------------
   # >  by reijubv [aruyasoft@comic.com]
   # >  RPG RPG Revolution
   # >  Released on: 27/04/2009
   # >  Version: 1.1 (April 25th 2009)
   #-------------------------------------------------------------------------------
   # > Changelog:
   #   V.1.0 (25-04-09) = Initial release
   #   V.1.1 (29-04-09) = Added a function to restore HP/MP to max when level up
   #   V.1.1a (30-04-09) = Fixed a small bug wich I forgot to write something in
   #                                    the script that can makes the game crashes.....
   #-------------------------------------------------------------------------------
   # >  Information:
   # This script will modify an actor's stats gain on level up by a random number
   # between maximum and minimum amount that you can specify for each actors.
   # For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5,
   # when that actor gains a level, he/she'll gains AGI by random number between 1 to 5!
   # I suggest you set actor's stats in database to the same from his/her starting level
   # to 99, so if in database your actor's HP at starting level is 100, from that level
   # to 99 the HP should not be changed! This's just a suggestion anyway....
   #-------------------------------------------------------------------------------
   # >  Compatibility :
   #
   #   * Aliases :
   #               class Game_Actor
   #                 def setup
   #                 def base_maxhp
   #                 def base_maxmp
   #                 def base_atk
   #                 def base_def
   #                 def base_spi
   #                 def base_agi
   #                 def hit
   #                 def eva
   #                 def cri
   #   * Rewrites :
   #               class Game_Actor
   #                 def level_up
   #                 def level_down
   #-------------------------------------------------------------------------------
   # Credit reijubv if you use this script....
   # Credit woratana for his recover HP/MP/States when Level Up script
   #-------------------------------------------------------------------------------
   # > Installation:
   # Put this script above main, setup script below.
   #==========================================================================
   module Rei
     module RandStat
      #----------------------------------------------------------------------------
      # * Create Arrays
      #----------------------------------------------- ----------------------------
       Actor_MaxInc = Array.new
       Actor_MinInc = Array.new
      #----------------------------------------------------------------------------
      # * HP/MP/STATE Restoration Setting (CREDIT TO WORATANA FOR THIS FUNCTIONS)
      #----------------------------------------------------------------------------
       RECOVER_HP    = true # Recover HP when level up? (true/false)
       RECOVER_MP    = true # Recover MP when level up?
       REMOVE_STATES = true # Cure all states when level up?
      #--------------------Setup each actors below----------------------------------    
      # Use this template :
      #
      # Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI]
      # >  This setup actor #'s each stats' maximum increments
      #
      # Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI]
      # >  This setup actor #'s each stats' minimum increments  
      #  
      # Use 0 if you don't want to increase any stat on level up
      #
      # Note : >Actor_MaxInc should be higher than Actor_MinInc!
      #        >Don't use negative values, or your actor's stats would be messed up!
      #        >Don't forget to setup max and min value for EVERY actors that you used
      #         in your game!
      #
      # Just in case that you don't know :
      #
      # HP  = Hit Points          DEF = Defense        HIT = Hit rate
      # MP  = Magic Points        SPI = Spirit        EVA = Evasion rate
      # ATK = Attack              AGI = Agility        CRI = Critical rate
      #----------------------------------------------------------------------------
      #Samples  :
      #         actorId   HP MP ATK DEF SPI AGI HIT EVA CRI
      #--------------------------------------------------------------------------
      # Maximum Increment
      #--------------------------------------------------------------------------
      def Actor_MaxInc(actor_id, stat)
        return if $game_variables.nil?
        actor_MaxInc[1] = [ $game_variables[8] , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment
        #etc
        return actor_MaxInc[actor_id][stat]
      end
      #--------------------------------------------------------------------------
      # Minimum increment
      #--------------------------------------------------------------------------
      def Actor_MinInc(actor_id, stat)
        return if $game_variables.nil?
        actor_MinInc[1] = [ $game_variables[9] , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment
        # etc
        return actor_MinInc[actor_id][stat]
      end
     end
   end
  
   #==========================================================================
   # ** Game_Actor
   #------------------------------------------------------------------------------
   #  This class handles actors. Its used within the Game_Actors class
   # ($game_actors) and referenced by the Game_Party class ($game_party).
   #==========================================================================

  
   class Game_Actor < Game_Battler
     #--------------------------------------------------------------------------
     # * Setup
     #     actor_id : actor ID
     #--------------------------------------------------------------------------
     alias reisetup setup
     def setup(actor_id)
       @stat_gains = {}
       for i in 0..8
         @stat_gains[i] = []
       end
       reisetup(actor_id)
     end
     #--------------------------------------------------------------------------
     # * Get Basic Maximum HP
     #--------------------------------------------------------------------------
     alias reibasemaxhp base_maxhp
     def base_maxhp
       n = reibasemaxhp
       n+= @stat_gains[0].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get basic Maximum MP
     #--------------------------------------------------------------------------
     alias reibasemaxmp base_maxmp
     def base_maxmp
       n = reibasemaxmp
       n+= @stat_gains[1].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Attack
     #--------------------------------------------------------------------------
     alias reibaseatk base_atk
     def base_atk
       n = reibaseatk
       n+= @stat_gains[2].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Defense
     #--------------------------------------------------------------------------
     alias reibasedef base_def
     def base_def
       n = reibasedef
       n+= @stat_gains[3].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Spirit
     #--------------------------------------------------------------------------
     alias reibasespi base_spi
     def base_spi
       n = reibasespi
       n+= @stat_gains[4].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Agility
     #--------------------------------------------------------------------------
     alias reibaseagi base_agi
     def base_agi
       n = reibaseagi
       n+= @stat_gains[5].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Hit Rate
     #--------------------------------------------------------------------------
     alias reihit hit
     def hit
       n = reihit
       n+= @stat_gains[6].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Evasion Rate
     #--------------------------------------------------------------------------
     alias reieva eva
     def eva
       n = reieva
       n+= @stat_gains[7].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Critical Ratio
     #--------------------------------------------------------------------------
     alias reicri cri
     def cri
       n = reicri
       n+= @stat_gains[8].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Level Up
     #--------------------------------------------------------------------------
     def level_up
       r = {}
       a = {}
       b = {}
       @level += 1
       for i in 0..8
         a[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
         b[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
         r[i] = b[i]+rand(a[i]-b[i]+1)
         if r[i] <= Rei::RandStat::Actor_MinInc(@actor_id, i) then
           r[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
         end
         if r[i] >= Rei::RandStat::Actor_MaxInc(@actor_id, i) then
           r[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
         end
         @stat_gains[i] << r[i]
       end
      
       #from woratana's script v
       @hp = maxhp if Rei::RandStat::RECOVER_HP
       @mp = maxmp if Rei::RandStat::RECOVER_MP
       if Rei::RandStat::REMOVE_STATES
         @states.clone.each {|i| remove_state(i) }
       end
       #from woratana's script ^
      
       for learning in self.class.learnings
         learn_skill(learning.skill_id) if learning.level == @level
       end
     end
     #--------------------------------------------------------------------------
     # * Level Down
     #--------------------------------------------------------------------------
     def level_down
       @level-= 1
       for i in 0..8
         @stat_gains[i].pop
       end
     end
   end
   #==========================================================================
   # ** Array
   #------------------------------------------------------------------------------
   #  This hidden class handles arrays. It is used within many other
   # classes to store data for future retrieval.
   #==========================================================================

   class Array
     #---------------------------------------------------------------------------
     # * Name      : Sum
     #   Info      : Sums all values in the array
     #   Author    : Trickster
     #   Call Info : No Arguments
     #---------------------------------------------------------------------------
     def sum
       # Initialize local variable n
       n = 0
       # Sum Up Values in Array
       each {|num| n += num}
       # Return number
       return n
     end
   end


It doesn't error out, but then again, I have no idea what the script actually does or how it works (sorry)

If it doesn't work, it will need a more manual approach, so I'll need to know specifically which stats follow a variable, and it will be applied to every actor...



I am not at my desktop, so I can't check, but will later, thanks for the help.
Darkreaper
In RM2k and 2k3 there were the options to swap tiles and even change entire tilesets. These features are absent in rmxp, any chance a script could be coded to bring them back?
Holder
I'd like to make a suggestion for a future tutorial, it's basically an instructional one.

The main focus is how to find out what code to use, say for example there's no one you can ask, How could you discover how to say for example insert an image, even if the solution is within the help file, instructions on what part of the help file to check, how to look through the default scripts to find a similar line etc.

Just so when someone comes to the point where they wish to try something themselves without the answer there in front of them can go about searching and discovering it, without help.
Darkreaper
yeah, now if only i read hiragana laugh.gif
The Law G14
@Darkreaper: So do you still need the script lol?

@Holder: I'm discussing it with another member of the Script Builders since we're also trying to make a tutorial about scenes so one of us will do your idea and the other will do the tutorial about scenes smile.gif
Darkreaper
QUOTE (The Law G14 @ Jan 24 2010, 04:02 PM) *
@Darkreaper: So do you still need the script lol?

@Holder: I'm discussing it with another member of the Script Builders since we're also trying to make a tutorial about scenes so one of us will do your idea and the other will do the tutorial about scenes smile.gif


well technically i need a few scripts laugh.gif but ive tried to work around the cooking one, for now im just using eventing. But im also trying to get the populate script to work, without much success
The Law G14
Populate script? Try posting it and I'll see what I can do for you. Also, post the error or whatever is causing you problems with the script smile.gif
Darkreaper
#=========================================================================
=====
# ** Auto Populate Maps by Charlie Fleed
#
# Version: 0.4
# Author: Charlie Fleed
# Edited by: Night_Runner
#==============================================================================



class Interpreter
#--------------------------------------------------------------------------
# ● Populate At:
# creates a copy at the coordinates
#--------------------------------------------------------------------------
def populate_at(event_id, x, y)
# Get the event_id, x, and y from the game's variables
event_id = $game_variables[30]
x = $game_variables[86]
y = $game_variables[87]
# Duplicate the Event.
e = $game_map.events[event_id].event.dup
# Get the event_id
i=1
events_positions=[]
while $game_map.events[i]!=nil
i+=1
end
e.id=i
# Create the event
ge = Game_Event.new($game_map.map_id, e)
$game_map.events[i] = ge
$game_map.events[i].moveto(x,y)
events_positions.push([x,y])
# Update the map to include the new event.
$game_map.refresh
$game_map.update
if $scene.is_a?(Scene_Map)
$scene.spriteset.dispose
$scene.spriteset = Spriteset_Map.new
end
end
end



class Game_Map
attr_reader :map
end



class Game_Event < Game_Character
attr_reader :event
end


#==============================================================================
# END OF SCRIPT
#==============================================================================


Name Error
undefined local variable or method 'x' for #<Interpreter:0x2dc70e8>
Fixxxer4153
QUOTE (tagg1080 @ Jan 13 2010, 07:02 PM) *
QUOTE (Night_Runner @ Jan 11 2010, 12:45 AM) *
The problem is that $game_variables isn't yet defined ....
Somewhere in Scene_Title it defines $game_variables = Game_Variables.new, but it reaches this bit of code before it reaches Scene_Title ....

Sorry, ummmmmmmmm, try something like this, it's mostly the same, but kinda not....


[Show/Hide] some code....
CODE
#===============================================================================
   # >  [VX]  Rei Levelup Stat Randomizer  
   #-------------------------------------------------------------------------------
   # >  by reijubv [aruyasoft@comic.com]
   # >  RPG RPG Revolution
   # >  Released on: 27/04/2009
   # >  Version: 1.1 (April 25th 2009)
   #-------------------------------------------------------------------------------
   # > Changelog:
   #   V.1.0 (25-04-09) = Initial release
   #   V.1.1 (29-04-09) = Added a function to restore HP/MP to max when level up
   #   V.1.1a (30-04-09) = Fixed a small bug wich I forgot to write something in
   #                                    the script that can makes the game crashes.....
   #-------------------------------------------------------------------------------
   # >  Information:
   # This script will modify an actor's stats gain on level up by a random number
   # between maximum and minimum amount that you can specify for each actors.
   # For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5,
   # when that actor gains a level, he/she'll gains AGI by random number between 1 to 5!
   # I suggest you set actor's stats in database to the same from his/her starting level
   # to 99, so if in database your actor's HP at starting level is 100, from that level
   # to 99 the HP should not be changed! This's just a suggestion anyway....
   #-------------------------------------------------------------------------------
   # >  Compatibility :
   #
   #   * Aliases :
   #               class Game_Actor
   #                 def setup
   #                 def base_maxhp
   #                 def base_maxmp
   #                 def base_atk
   #                 def base_def
   #                 def base_spi
   #                 def base_agi
   #                 def hit
   #                 def eva
   #                 def cri
   #   * Rewrites :
   #               class Game_Actor
   #                 def level_up
   #                 def level_down
   #-------------------------------------------------------------------------------
   # Credit reijubv if you use this script....
   # Credit woratana for his recover HP/MP/States when Level Up script
   #-------------------------------------------------------------------------------
   # > Installation:
   # Put this script above main, setup script below.
   #==========================================================================
   module Rei
     module RandStat
      #----------------------------------------------------------------------------
      # * Create Arrays
      #----------------------------------------------- ----------------------------
       Actor_MaxInc = Array.new
       Actor_MinInc = Array.new
      #----------------------------------------------------------------------------
      # * HP/MP/STATE Restoration Setting (CREDIT TO WORATANA FOR THIS FUNCTIONS)
      #----------------------------------------------------------------------------
       RECOVER_HP    = true # Recover HP when level up? (true/false)
       RECOVER_MP    = true # Recover MP when level up?
       REMOVE_STATES = true # Cure all states when level up?
      #--------------------Setup each actors below----------------------------------    
      # Use this template :
      #
      # Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI]
      # >  This setup actor #'s each stats' maximum increments
      #
      # Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI]
      # >  This setup actor #'s each stats' minimum increments  
      #  
      # Use 0 if you don't want to increase any stat on level up
      #
      # Note : >Actor_MaxInc should be higher than Actor_MinInc!
      #        >Don't use negative values, or your actor's stats would be messed up!
      #        >Don't forget to setup max and min value for EVERY actors that you used
      #         in your game!
      #
      # Just in case that you don't know :
      #
      # HP  = Hit Points          DEF = Defense        HIT = Hit rate
      # MP  = Magic Points        SPI = Spirit        EVA = Evasion rate
      # ATK = Attack              AGI = Agility        CRI = Critical rate
      #----------------------------------------------------------------------------
      #Samples  :
      #         actorId   HP MP ATK DEF SPI AGI HIT EVA CRI
      #--------------------------------------------------------------------------
      # Maximum Increment
      #--------------------------------------------------------------------------
      def Actor_MaxInc(actor_id, stat)
        return if $game_variables.nil?
        actor_MaxInc[1] = [ $game_variables[8] , 3 ,3 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment
        #etc
        return actor_MaxInc[actor_id][stat]
      end
      #--------------------------------------------------------------------------
      # Minimum increment
      #--------------------------------------------------------------------------
      def Actor_MinInc(actor_id, stat)
        return if $game_variables.nil?
        actor_MinInc[1] = [ $game_variables[9] , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment
        # etc
        return actor_MinInc[actor_id][stat]
      end
     end
   end
  
   #==========================================================================
   # ** Game_Actor
   #------------------------------------------------------------------------------
   #  This class handles actors. Its used within the Game_Actors class
   # ($game_actors) and referenced by the Game_Party class ($game_party).
   #==========================================================================

  
   class Game_Actor < Game_Battler
     #--------------------------------------------------------------------------
     # * Setup
     #     actor_id : actor ID
     #--------------------------------------------------------------------------
     alias reisetup setup
     def setup(actor_id)
       @stat_gains = {}
       for i in 0..8
         @stat_gains[i] = []
       end
       reisetup(actor_id)
     end
     #--------------------------------------------------------------------------
     # * Get Basic Maximum HP
     #--------------------------------------------------------------------------
     alias reibasemaxhp base_maxhp
     def base_maxhp
       n = reibasemaxhp
       n+= @stat_gains[0].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get basic Maximum MP
     #--------------------------------------------------------------------------
     alias reibasemaxmp base_maxmp
     def base_maxmp
       n = reibasemaxmp
       n+= @stat_gains[1].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Attack
     #--------------------------------------------------------------------------
     alias reibaseatk base_atk
     def base_atk
       n = reibaseatk
       n+= @stat_gains[2].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Defense
     #--------------------------------------------------------------------------
     alias reibasedef base_def
     def base_def
       n = reibasedef
       n+= @stat_gains[3].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Spirit
     #--------------------------------------------------------------------------
     alias reibasespi base_spi
     def base_spi
       n = reibasespi
       n+= @stat_gains[4].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Basic Agility
     #--------------------------------------------------------------------------
     alias reibaseagi base_agi
     def base_agi
       n = reibaseagi
       n+= @stat_gains[5].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Hit Rate
     #--------------------------------------------------------------------------
     alias reihit hit
     def hit
       n = reihit
       n+= @stat_gains[6].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Evasion Rate
     #--------------------------------------------------------------------------
     alias reieva eva
     def eva
       n = reieva
       n+= @stat_gains[7].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Get Critical Ratio
     #--------------------------------------------------------------------------
     alias reicri cri
     def cri
       n = reicri
       n+= @stat_gains[8].sum
       return n
     end
     #--------------------------------------------------------------------------
     # * Level Up
     #--------------------------------------------------------------------------
     def level_up
       r = {}
       a = {}
       b = {}
       @level += 1
       for i in 0..8
         a[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
         b[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
         r[i] = b[i]+rand(a[i]-b[i]+1)
         if r[i] <= Rei::RandStat::Actor_MinInc(@actor_id, i) then
           r[i] = Rei::RandStat::Actor_MinInc(@actor_id, i)
         end
         if r[i] >= Rei::RandStat::Actor_MaxInc(@actor_id, i) then
           r[i] = Rei::RandStat::Actor_MaxInc(@actor_id, i)
         end
         @stat_gains[i] << r[i]
       end
      
       #from woratana's script v
       @hp = maxhp if Rei::RandStat::RECOVER_HP
       @mp = maxmp if Rei::RandStat::RECOVER_MP
       if Rei::RandStat::REMOVE_STATES
         @states.clone.each {|i| remove_state(i) }
       end
       #from woratana's script ^
      
       for learning in self.class.learnings
         learn_skill(learning.skill_id) if learning.level == @level
       end
     end
     #--------------------------------------------------------------------------
     # * Level Down
     #--------------------------------------------------------------------------
     def level_down
       @level-= 1
       for i in 0..8
         @stat_gains[i].pop
       end
     end
   end
   #==========================================================================
   # ** Array
   #------------------------------------------------------------------------------
   #  This hidden class handles arrays. It is used within many other
   # classes to store data for future retrieval.
   #==========================================================================

   class Array
     #---------------------------------------------------------------------------
     # * Name      : Sum
     #   Info      : Sums all values in the array
     #   Author    : Trickster
     #   Call Info : No Arguments
     #---------------------------------------------------------------------------
     def sum
       # Initialize local variable n
       n = 0
       # Sum Up Values in Array
       each {|num| n += num}
       # Return number
       return n
     end
   end


It doesn't error out, but then again, I have no idea what the script actually does or how it works (sorry)

If it doesn't work, it will need a more manual approach, so I'll need to know specifically which stats follow a variable, and it will be applied to every actor...



I am not at my desktop, so I can't check, but will later, thanks for the help.


Hey I have a couple of questions about this Stat Randomization Script...

First off, is there a version of it for RMXP?
And if there is, does anyone think it could be modded to work with Blizzards' CSGS (Custom Stat Growing System)?
Because Blizzards' system eliminates leveling, this stat randomization script isn't exactly compatible, that is, even if there's a version of it for XP.

Anyway, if it could, then in-game once your actor reaches their limit for actions determining a stat increase, instead of raising the stat by a set amount, raises it by a random number between a min and max, giving the effect that your stat increases aren't always the same, and could possibly give you the illusion of a die roll system like D&D 3.5 rules where once you've earned the stat increase (in D&D its a level up) then the die of your size (obviously governed by the min and max; in D&D it's set by which class you are) is rolled to configure how much of a bonus you'd receive to that stat.

If something like that would be more work that its worth then never mind, but it would be a cool aspect to add to an already D&D-esque rpg.
mikesp86
i'm getting an error with rpg advpcates two handed weapon script on line 119



heres the script im using

CODE

# Two-Handed Weapons
# by RPG Advocate


#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :two_handed_weapons # array of two-handed weapons
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias twohanded_initialize initialize
def initialize
twohanded_initialize
@two_handed_weapons = []
end
end




#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================

class Window_EquipRight < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :translucent_text
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
alias twoh_initialize initialize
def initialize(actor)
@translucent_text = [false, false]
twoh_initialize(actor)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias twoh_refresh refresh
def refresh
# Perform the original call
twoh_refresh
draw_item_name(@data[0], 92, 32 * 0, @translucent_text[0])
draw_item_name(@data[1], 92, 32 * 1, @translucent_text[1])
draw_item_name(@data[2], 92, 32 * 2, false)
draw_item_name(@data[3], 92, 32 * 3, false)
draw_item_name(@data[4], 92, 32 * 4, false)
end
#--------------------------------------------------------------------------
# * Draw Item Name
# item : item
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# translucent : translucent
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, translucent = true)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
if translucent
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 128)
self.contents.font.color = disabled_color
else
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
end
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
end





#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs equipment screen processing.
#==============================================================================

class Scene_Equip

#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias twoh_refresh refresh
def refresh
# The original call
twoh_refresh
# Get currently equipped item
item1 = @right_window.item
# If item window is active
if @item_window.active
# Get currently selected item
item2 = @item_window.item
item3 = @actor.armor1_id
item4 = @actor.weapon_id
# Change equipment
last_hp = @actor.hp
last_sp = @actor.sp
w = item2.id
if item2.is_a?(RPG::Weapon) && $game_system.two_handed_weapons.include?(w)
@right_window.translucent_text = [false, true]
@right_window.refresh
@actor.equip(1, 0)
end
if item2.is_a?(RPG::Armor) && item2.kind == 0 &&
$game_system.two_handed_weapons.include?(@actor.weapon_id)
@right_window.translucent_text = [true, false]
@right_window.refresh
flag = true
@actor.equip(0, 0)
end
# Get parameters for after equipment change
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
# Return equipment
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
if item2.is_a?(RPG::Weapon) && $game_system.two_handed_weapons.include?(w)
@actor.equip(1, item3)
end
if item2.is_a?(RPG::Armor) && item2.kind == 0 && flag
@actor.equip(0, item4)
end
@actor.hp = last_hp
@actor.sp = last_sp
# Draw in left window
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias twoh_update update
def update
# If item_window value is changed
if @item_window.index != @old_index
@right_window.translucent_text = [false, false]
@right_window.refresh
end
@old_index = @item_window.index
# Perform the original call
twoh_update
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::cool.gif
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# Obtain id of item selected
w = item.id
# If two-handed weapon selected, equip weapon remove shield
if item.is_a?(RPG::Weapon) && $game_system.two_handed_weapons.include?(w)
@actor.equip(1, 0)
end
# if shield selected and two-handed equipped, remove two-handed weapon
if item.is_a?(RPG::Armor) && item.kind == 0 &&
$game_system.two_handed_weapons.include?(@actor.weapon_id)
@actor.equip(0, 0)
end
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
# Refresh item windows
@item_window1.refresh
@item_window2.refresh
return
end
end
end



This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.