Recent Posts

Pages: [1] 2 3 ... 10
1
Script Troubleshooting / Re: NoMethodError Help
« Last post by BoisterousHero on Today at 01:37:55 AM »
Incredible, thank you so much. I can't begin to express how grateful I am that you took the time to help me troubleshoot such an old script. The logic explanation is really helpful too.

It would have taken me a really long time to figure that out. Thanks again!
2
Script Troubleshooting / Re: NoMethodError Help
« Last post by KK20 on Today at 01:19:57 AM »
Yep, it's his bug.

Problem is with the logic regarding recent items.
Code: [Select]
for i in 0...$recent_items.size
  puts [i, $recent_items[i]].inspect
  if $recent_items[i].id == $data_items[item_id].id && $recent_items[i].is_a?(RPG::Item)
    $recent_items.delete_at(i)
  end
end
$recent_items.push(item)
if $recent_items.size > 40
  $recent_items.delete_at(0)
end
If you are to gain another item that you recently obtained, it deletes the item from the $recent_items list and then re-adds it again. However, if you were to gain item A, then item B, then item A, the use of $recent_items.delete_at(i) modifies the array WHILE we are currently iterating through it in the loop. This created a nil record, hence the error message received.

He should have used delete_if instead. I went ahead and modified the methods to do this. I also checked if he made this delete_at error anywhere else, and found out that the lose_item/weapon/armor methods he rewrote are completely wrong. I fixed those as well.

Replace the Game_Party class in the script with this:
Code: [Select]
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def gain_item(item_id, n)
    # Update quantity data in the hash.
    if item_id > 0
      @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
      gain_recent_item(item_id) if n >= 0
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id, n)
    # Update quantity data in the hash.
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
      gain_recent_weapon(weapon_id) if n >= 0
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def gain_armor(armor_id, n)
    # Update quantity data in the hash.
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
      gain_recent_armor(armor_id) if n >= 0
    end
  end
  #--------------------------------------------------------------------------
  # * Lose Items
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def lose_item(item_id, n)
    # Reverse the numerical value and call it gain_item
    gain_item(item_id, -n)
    if $game_party.item_number(item_id) == 0
      $recent_items.delete_if { |i| i.id == item_id && i.is_a?(RPG::Item) }
    end
  end
  #--------------------------------------------------------------------------
  # * Lose Weapons
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def lose_weapon(weapon_id, n)
    # Reverse the numerical value and call it gain_weapon
    gain_weapon(weapon_id, -n)
    if $game_party.weapon_number(weapon_id) == 0
      $recent_items.delete_if { |i| i.id == weapon_id && i.is_a?(RPG::Weapon) }
    end
  end
  #--------------------------------------------------------------------------
  # * Lose Armor
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def lose_armor(armor_id, n)
    # Reverse the numerical value and call it gain_armor
    gain_armor(armor_id, -n)
    if $game_party.armor_number(armor_id) == 0
      $recent_items.delete_if { |i| i.id == armor_id && i.is_a?(RPG::Armor) }
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Recent Items
  #     item_id  : item ID
  #--------------------------------------------------------------------------
  def gain_recent_item(item_id)
    item = $data_items[item_id]
    $recent_items.delete_if { |i| i.id == item.id && i.is_a?(RPG::Item) }
    $recent_items.push(item)
    if $recent_items.size > 40
      $recent_items.delete_at(0)
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Recent Weapons
  #     weapon_id : weapon ID
  #--------------------------------------------------------------------------
  def gain_recent_weapon(weapon_id)
    weapon = $data_weapons[weapon_id]
    $recent_items.delete_if { |i| i.id == weapon.id && i.is_a?(RPG::Weapon) }
    $recent_items.push(weapon)
    if $recent_items.size > 40
      $recent_items.delete_at(0)
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Recent Armor
  #     armor_id  : armor ID
  #--------------------------------------------------------------------------
  def gain_recent_armor(armor_id)
    armor = $data_armors[armor_id]
    $recent_items.delete_if { |i| i.id == armor.id && i.is_a?(RPG::Armor) }
    $recent_items.push(armor)
    if $recent_items.size > 40
      $recent_items.delete_at(0)
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def equip_item(item_id, n)
    # Update quantity data in the hash.
    if item_id > 0
      @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def equip_weapon(weapon_id, n)
    # Update quantity data in the hash.
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def equip_armor(armor_id, n)
    # Update quantity data in the hash.
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
    end
  end
end
3
Script Troubleshooting / Re: NoMethodError Help
« Last post by BoisterousHero on Today at 12:02:21 AM »
Here is the demo, thanks again for your help on this:

https://drive.google.com/open?id=0B7V-QZ1oDCawTzRtOHlWWlZQcTg
4
Script Troubleshooting / Re: NoMethodError Help
« Last post by BoisterousHero on October 23, 2017, 11:49:20 PM »
Awesome, thanks for the help! I am using a side view combat system, but there weren't any conflicting Game_Party methods from what I could tell. I also wasn't sure if my edits to the menu system were disastrous.

I'll prepare a demo!
5
Script Troubleshooting / Re: NoMethodError Help
« Last post by KK20 on October 23, 2017, 11:06:16 PM »
Can you post a demo instead? If it does happen to be another script conflicting with it, I will need that other script too. I can say for certainty that it has nothing to do with XPA.

Regarding the line
Code: [Select]
if $recent_items[i].id == $data_items[item_id].id
I'm betting that item_id is 0. That would mean albertfish's script has a bug.
6
Script Troubleshooting / NoMethodError Help
« Last post by BoisterousHero on October 23, 2017, 10:19:10 PM »
I'm running into a little trouble with a NoMethodError and I'm just looking for a little help to get me into the right direction.

I am using a custom menu script made by "albertfish", it's quite old. I am using it as a framework to write my own custom menu.

I am currently using RPG Maker XP with the RPG Maker VX Ace engine, as defined here: http://forum.chaos-project.com/index.php/topic,12899.msg173956.html#msg173956

This error:
(click to show/hide)
Appears when my actors receive items.

The specific line is here:
Code: [Select]
if $recent_items[i].id == $data_items[item_id].id && $recent_items[i].is_a?(RPG::Item)
The problem I'm having is with a custom "Game_Party" class. It is telling me the method "id" is not defined, but I'm pretty certain it is a built-in RGSS method. I'm not sure if the problem is due to me using the RPG Maker VX engine and that there is a syntax change, or it is a script conflict issue.

This is the particular area that it is flagging:
(click to show/hide)

This script is pretty big I've uploaded the whole thing to pastebin:
https://pastebin.com/WEGdtdrK

Any sort of hints or advice would be helpful!


7
Troubleshooting / Help / Re: Basic RGSS Window Questions
« Last post by Blizzard on October 23, 2017, 07:28:40 PM »
- update() is called every frame (in theory) in order to process input and stuff that you need every frame
- refresh() can be considered update-on-demand and it also handled drawing on the Bitmaps within windows (since drawing is expensive)

To get more technically, the main() method within a scene is the main loop, it calls its own update() method in a loop then (and does rendering through "Graphics.update"). Within its update() method it usually calls the windows' update() methods. If there are more windows, sometimes some of them aren't visible at the time so it doesn't update them during that time. refresh() is usually only called when some display data needs to be changed in the window, e.g. the HP display changes so the Bitmap object contained within the window needs to be changed.

I can't think of a tutorial right now, but a good idea is that you just go ahead and try to edit the existing menu code (make a backup first!) and just see what happens. The menu code isn't that complicated and now that you know the basics, it should be relatively straightforward to understand what's going on.
8
Troubleshooting / Help / Basic RGSS Window Questions
« Last post by BoisterousHero on October 23, 2017, 06:09:45 PM »
Hi guys,

I am pretty new to this forum, but I've been using RPG Maker for a while. I am currently working with RPG Maker XP ("Ace" version). Hopefully I am asking this in the right spot.

I am working on modifying the menu system in my game and I was wondering if there was a good resource that had basic explanations of the basic methods or if someone could give a quick explanation. I don't really need a full RGSS guide--I've got a pretty good handle on things--but I'm curious on the process of drawing a window to make sure I get things right.

I understand the classes "Window_" handle how a window is drawn and "Scene_" actually draws the windows.

I just need a little help with the basic methods and when to use them. I understand "initialize" initializes the object, but I am a little confused with "refresh" and "update" and the difference between the two.

I suppose the TL:DR of my question: Is there a quick explanation on the "refresh" and "update" methods and when to use them when drawing menu windows?

Or, if anyone knows of a nice tutorial focused on creating/editing menu systems specifically, that would also be helpful. I have had a hard time finding one.

Thanks!
9
RMXP Script Database / Re: [XP] Super Event Sensor (Event NPC Advanced AI)
« Last post by Heretic86 on October 21, 2017, 07:00:44 PM »
Honestly, not sure.  Probably.  I dont think the Blizz ABS does anything with Switches, so in theory it should be.  You could try it out and see if it is or is not, then post!  If it isnt, then both Blizz and I will have some work to do as they would be quite nice working with each other...
10
RMXP Script Database / Re: [XP] XP Ace Tilemap
« Last post by kreiss on October 20, 2017, 05:54:47 AM »
Thanks, it work perfectly !
Pages: [1] 2 3 ... 10