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.
#--------------------------------------------------------------------------
# * 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.
I know where it's happening, I just don't know how to keep it from happening.
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 |:(
Ya the issue still persists. Here's a small snippet of I'm doing.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ 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.
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?
No that doesn't work either :???:
I'll start with an image.
(http://db.tt/PP6ZVlpr)
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.
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
#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
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.
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)
Does a script call through an event with the following:
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.
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
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.
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.
The reserve list, which I take it is the window on the bottom left, gave me the following:
Remove, Aluxes, Basil, Cyrus, Dorothy
okay cool, so how did you get past the first error that gave you those actors?
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.
(https://dl.dropbox.com/u/74796308/upload/partysystembug.JPG)
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