[RMXP] Why I get this....

Started by bigace, March 05, 2013, 06:12:39 pm

Previous topic - Next topic

bigace

March 05, 2013, 06:12:39 pm Last Edit: March 06, 2013, 03:22:00 pm by bigace
Can anyone tell me why I keep getting this annoying ass error every time:
QuoteScript 'Game_Actors' line 20: NoMethodError occured.

undefined method '>' for #<Game_Actor:0x3171440>


This happens when I add something to Game_Party and then add the method from the Game:: class to a window.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

March 05, 2013, 07:14:40 pm #1 Last Edit: March 06, 2013, 02:21:24 am by Ryex
Code: ruby

 #--------------------------------------------------------------------------
 # * Get Actor
 #     actor_id : actor ID
 #--------------------------------------------------------------------------
 def [](actor_id)
   if actor_id > 999 or $data_actors[actor_id] == nil
     return nil
   end
   if @data[actor_id] == nil
     @data[actor_id] = Game_Actor.new(actor_id)
   end
   return @data[actor_id]
 end

Clearly, the parameter actor_id is being passed as a Game_Actor instead of an int. Somewhere in your code, you are doing this:

a = Game_Actor.new(n) # or perhaps $game_actors[n]
. . .
$game_actors[a]

If you can't locate where this is happening, I suggest using some type of backtrace method, preferably the one in RMX-OS.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

I know where it's happening, I just don't know how to keep it from happening.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

March 05, 2013, 11:56:44 pm #3 Last Edit: March 06, 2013, 12:31:31 am by KK20
Because you are passing a Game_Actor class as the parameter, why not use Game_Actor#actor_id?

a = Game_Actor.new(5)
$game_actors[a.actor_id] #=> $game_actors[5]


EDIT: Epic facepalm...It's been a long day for me |:(

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

March 06, 2013, 03:21:41 pm #4 Last Edit: March 06, 2013, 09:04:29 pm by Ryex
Ya the issue still persists. Here's a small snippet of I'm doing.
Code: ruby
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Game_Party
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_Party
def party_members
last_actor = Game_Actor.new(5)
result = []
for id in @actors
unless result.include?($game_actors[last_actor.id])
result.push($game_actors[last_actor.id])
end
end
return result
end
def all_members
return party_members.uniq
end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Window_PartyExtras
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_PartyExtras < Window_PartyBase
def initialize
super(0, 192, 200, fitting_height(8))
self.contents = Bitmap.new(width - 32, height - 32)
   @members = $game_party.all_members
unselect
refresh
end
def make_item_list
@members.each do |member|
next if member.nil?
@data << member.id
end
@data = @data + [0]
end
end


I don't know, maybe I need an extra method or maybe I need to fix something in the refresh method. This is confusing. Note: This is a party system if you were curious.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

I don't understand what Game_Party#party_members and #all_members are supposed to accomplish. Does your script allow duplicate actors or something?

So you're saying that

        for actor in @actors
            unless result.include?($game_actors[actor.id])
                result.push($game_actors[actor.id])
            end
        end

didn't work?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

No that doesn't work either  :???:

I'll start with an image.

1 = Current Party
2 = Reserve Party list

What I was trying to accomplish was to have all party members, current and reserve, appear in the window #2. Those who are part of the current party would have their names change colors to whatever the developer wants, while those who aren't in the current party would just have white colored names. The problem I was having is that only the reserve would appear in the window #2. So no matter what I do I seem to get that error that's in the OP.  Hopefully this makes more sense.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

Ryex

March 06, 2013, 09:11:22 pm #7 Last Edit: March 06, 2013, 09:17:26 pm by Ryex
I don't understand what last_actor or that loop is trying to do
the code inside the 'unless' branch will only executed once because of the condition.

if your trying to swap party member position you need to sore the position of the member you swamping and save the member in a local variable then move the member in the position your swapping to to the position of the member your swapping and move the member your swapping to the new position form the local variable.

like so

Code: ruby

#the array your swapping positions around in
a = []
#get positions
pos = n
newpos = x
#swap
val = a[pos]
a[pos] = a[newpos]
a[newpos] = val
#positions now swapped
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

bigace

March 07, 2013, 07:36:52 am #8 Last Edit: March 07, 2013, 07:38:19 am by bigace
uh, thats not what I meant Ryex. I already have that in the scene, but what I was talking about was adding and removing an actor from the current party, not switching around their position.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

LiTTleDRAgo

I didn't understand what are you trying to accomplish, it would be faster to help if you post your code

Quote from: bigace on March 06, 2013, 08:13:02 pm
What I was trying to accomplish was to have all party members, current and reserve, appear in the window #2. Those who are part of the current party would have their names change colors to whatever the developer wants, while those who aren't in the current party would just have white colored names. The problem I was having is that only the reserve would appear in the window #2. So no matter what I do I seem to get that error that's in the OP.  Hopefully this makes more sense.


let's say if you have two variables, @actors and @reserve in $game_party
to show all of them at once you can use

for actor in $game_party.actors + $game_party.reserve
   ...
end


then if you want to change the name if that actor(s) is in the party

self.contents.font.color = Color.new(255,0,0) if $game_party.actors.include?(actor)

KK20

Does a script call through an event with the following:
Code: ruby

a = Game_Actor.new(8)
p $game_actors[a.id].name

return Hilda? If yes, then the problem isn't being shown in your code snippet.
Quote from: LiTTleDRAgo on March 07, 2013, 11:43:16 am
I didn't understand what are you trying to accomplish, it would be faster to help if you post your code

I am highly considering this option now.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

Okay so I've tried all I can for now, I guess you guys can take a crack at it see what the issue is. Here's the script: http://db.tt/YBM8jP8E


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

March 13, 2013, 09:22:52 pm #12 Last Edit: March 13, 2013, 09:53:07 pm by KK20
I'm noticing a lot of confusion as to what the variables are currently holding (one such instance equaling a Game_Actor object and then, during the scene, changes into an integer). I was able to get past the first error evident in the demo, which was getting the demo to actually run. But swapping and removing actors in the scene are bringing up errors, mostly in drawing actor stats (e.g. the methods require a Game_Actor parameter, but an integer is passed instead).

The #all_members and #party_members methods seem really redundant when $game_party.actors already does that (unless, as I said before, you have a way where there can be duplicate actors in the party).

EDIT: Seeing a lot of instances where you do $game_party[Game_Actor object]. Every time I change one thing, another error pops up. I'm not going to go through all of this and fix it--I'll point you into areas instead.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

quick question, so when you fix said issue that was connect to Window_PartyExtra, did the actors that are in the party appear in the reserve as well. If no, then I need to still figure out how to get that result.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

The reserve list, which I take it is the window on the bottom left, gave me the following:
Remove, Aluxes, Basil, Cyrus, Dorothy

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

okay cool, so how did you get past the first error that gave you those actors?


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

LiTTleDRAgo

Quote from: bigace on March 13, 2013, 10:08:42 pm
quick question, so when you fix said issue that was connect to Window_PartyExtra, did the actors that are in the party appear in the reserve as well. If no, then I need to still figure out how to get that result.


Spoiler: ShowHide


for the first error :

Quote#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Game_Party
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_Party
   def battle_members
      initialize_battle_members if initialize_battle_members?
      array = []
      @battle_members_array.each do |member|
         break if array.size > max_battle_members
         next if member.nil?
         next if $game_actors[member.id].nil?
         next unless $game_actors[member.id].exist?
         array << member.id
      end
      return array
   end
end