Posts: 96
Threads: 10
Joined: Nov 2024
Hi! I tried implementing the Lead Actor Swapper script by Sheol:
https://www.save-point.org/showthread.php?tid=6559
But when I tried swapping a character out using the Q button (L on a gamepad), I encounter an error on line 64:
Code: $game_system.lead_actor = ($game_system.lead_actor - 1) % $game_party.actors.size
I use a caterpillar script, could that be the problem? I was hoping I could swap/change character's party positions using the script and they would also swap on the caterpillar.
Posts: 4,862
Threads: 587
Joined: Dec 2009
Is that really all the information the popup window has provided you with?
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 12,580
Threads: 1,755
Joined: May 2009
08-30-2025, 02:08 PM
(This post was last modified: 08-30-2025, 02:10 PM by DerVVulfman.)
I'm wondering.....
Code: $game_system.lead_actor = ($game_system.lead_actor - 1) % $game_party.actors.size
Is this an issue where it tries to go FROM lead_actor #0 and attempts to incorrectly generate lead_actor #-1
I think you could go two different ways:
>> If you cannot go below actor #0 or past the party limit -- no cycling <<
Code: def update
slipknog_las_update
# Button input adjustments to lead actor
$game_system.lead_actor += 1 if Input.trigger?(Input::R)
$game_system.lead_actor -= 1 if Input.trigger?(Input::L)
# Get max party size limit
sz_limit = $game_party.actors.size - 1
# Keep lead actor in range
$game_system.lead_actor 0 if $game_system.lead_actor < 0
$game_system.lead_actor sz_limit if $game_system.lead_actor > sz_limit
end
>> Allow cycling, on going below actor #0... or past party limit... -- no cycling <<
Code: def update
slipknog_las_update
# Button input adjustments to lead actor
$game_system.lead_actor += 1 if Input.trigger?(Input::R)
$game_system.lead_actor -= 1 if Input.trigger?(Input::L)
# Get max party size limit
sz_limit = $game_party.actors.size - 1
# Keep lead actor in range
$game_system.lead_actor sz_limit if $game_system.lead_actor < 0
$game_system.lead_actor 0 if $game_system.lead_actor > sz_limit
end
Again, I am still without my main PC and RPGMaker.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 4,862
Threads: 587
Joined: Dec 2009
08-30-2025, 10:01 PM
(This post was last modified: 08-30-2025, 10:02 PM by kyonides.)
(08-30-2025, 02:08 PM)DerVVulfman Wrote: I'm wondering.....
Code: $game_system.lead_actor = ($game_system.lead_actor - 1) % $game_party.actors.size
Is this an issue where it tries to go FROM lead_actor #0 and attempts to incorrectly generate lead_actor #-1
And that's hoping there's no such issue as a NilClass error message because Game_System never owned any lead_actor method or @lead_actor being set to nil (the default value)...
So Ace_V, was there any specific error message mentioned in your popup window or backtrace script? Can you post it here as is?
It's just to make sure nobody is skipping or ignoring any vital details here...
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 96
Threads: 10
Joined: Nov 2024
08-31-2025, 07:44 AM
(This post was last modified: 08-31-2025, 08:00 AM by Ace_V.)
(08-30-2025, 10:01 PM)kyonides Wrote: And that's hoping there's no such issue as a NilClass error message because Game_System never owned any lead_actor method or @lead_actor being set to nil (the default value)...
So Ace_V, was there any specific error message mentioned in your popup window or backtrace script? Can you post it here as is?
It's just to make sure nobody is skipping or ignoring any vital details here...
Hi, kyonides and DerVVulfman!
Here's the error that is displayed.
EDIT: I also tried both of DerVVulfman's suggestions (I spotted the slipknog typo and changed it to slipknot) but kept getting errors regarding $game_system.lead_actor:
Script 'Lead Actor Swapper' line 66: NoMethodError occurred. Undefined method '<' for nil:NilClass
I guess it doesn't recognize this? $game_system.lead_actor 0 if $game_system.lead_actor < 0
Posts: 4,862
Threads: 587
Joined: Dec 2009
08-31-2025, 10:11 AM
(This post was last modified: 08-31-2025, 10:17 AM by kyonides.)
A quick way to solve it would be to go to that custom script and look for the @lead_actor variable in Game_System's initialize method. (I think it should have been aliased by that scripter.) There set it to 0.
This should prevent it from crashing because of any NilClass related errors. nil means nothing in Latin...
In that update method you've been working on, you could add these lines:
Code: sz_limit = $game_party.actors.size - 1
$game_system.lead_actor = 0 if $game_system.lead_actor < 0
$game_system.lead_actor = last_actor if $game_system.lead_actor > sz_limit
The assignment operator = was missing twice there.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 12,580
Threads: 1,755
Joined: May 2009
Yesterday, 01:56 AM
(This post was last modified: Yesterday, 01:57 AM by DerVVulfman.)
I see something actually more malicious.
According to your error message, [font=Courier New] undefined method '-' for nil:NilClass[/font, the value being subtracted does not exist. And the value is $game_system.lead_actor. This suggests that you have no lead_actor value defined in Game_System.
However...
Code: class Game_System
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
attr_reader :lead_actor
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias slipknot_las_init initialize
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
slipknot_las_init
@lead_actor = 0
end
Here, we can see that the value is indeed created within Game_System within its 'initialize' method.
On seeing that, I am under the opinion that you have another script further below in your list that is rewriting the 'initialize' method, and thus erasing anything added in this manner.
Rearranging the scripts (SCRIPT ORDER) should suffice. You just need to find what script alters the Initialize method but does not use alias to add new content.
Other scripts could be suffering, and you jmay not yet notice.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 96
Threads: 10
Joined: Nov 2024
(Yesterday, 01:56 AM)DerVVulfman Wrote: I see something actually more malicious.
According to your error message, [font=Courier New]undefined method '-' for nil:NilClass[/font, the value being subtracted does not exist. And the value is $game_system.lead_actor. This suggests that you have no lead_actor value defined in Game_System.
Hi, kyonides and DerVVulfman! I checked my Game_System and I indeed don't see lead_actor in it.  Also started a new project and it is the same thing:
Code: #==============================================================================
# ** 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_reader :map_interpreter # map event interpreter
attr_reader :battle_interpreter # battle event interpreter
attr_accessor :timer # timer
attr_accessor :timer_working # timer working flag
attr_accessor :save_disabled # save forbidden
attr_accessor :menu_disabled # menu forbidden
attr_accessor :encounter_disabled # encounter forbidden
attr_accessor :message_position # text option: positioning
attr_accessor :message_frame # text option: window frame
attr_accessor :save_count # save count
attr_accessor :magic_number # magic number
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@map_interpreter = Interpreter.new(0, true)
@battle_interpreter = Interpreter.new(0, false)
@timer = 0
@timer_working = false
@save_disabled = false
@menu_disabled = false
@encounter_disabled = false
@message_position = 2
@message_frame = 0
@save_count = 0
@magic_number = 0
end
#--------------------------------------------------------------------------
# * Play Background Music
# bgm : background music to be played
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Stop Background Music
#--------------------------------------------------------------------------
def bgm_stop
Audio.bgm_stop
end
#--------------------------------------------------------------------------
# * Fade Out Background Music
# time : fade-out time (in seconds)
#--------------------------------------------------------------------------
def bgm_fade(time)
@playing_bgm = nil
Audio.bgm_fade(time * 1000)
end
#--------------------------------------------------------------------------
# * Background Music Memory
#--------------------------------------------------------------------------
def bgm_memorize
@memorized_bgm = @playing_bgm
end
#--------------------------------------------------------------------------
# * Restore Background Music
#--------------------------------------------------------------------------
def bgm_restore
bgm_play(@memorized_bgm)
end
#--------------------------------------------------------------------------
# * Play Background Sound
# bgs : background sound to be played
#--------------------------------------------------------------------------
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil and bgs.name != ""
Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Fade Out Background Sound
# time : fade-out time (in seconds)
#--------------------------------------------------------------------------
def bgs_fade(time)
@playing_bgs = nil
Audio.bgs_fade(time * 1000)
end
#--------------------------------------------------------------------------
# * Background Sound Memory
#--------------------------------------------------------------------------
def bgs_memorize
@memorized_bgs = @playing_bgs
end
#--------------------------------------------------------------------------
# * Restore Background Sound
#--------------------------------------------------------------------------
def bgs_restore
bgs_play(@memorized_bgs)
end
#--------------------------------------------------------------------------
# * Play Music Effect
# me : music effect to be played
#--------------------------------------------------------------------------
def me_play(me)
if me != nil and me.name != ""
Audio.me_play("Audio/ME/" + me.name, me.volume, me.pitch)
else
Audio.me_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Play Sound Effect
# se : sound effect to be played
#--------------------------------------------------------------------------
def se_play(se)
if se != nil and se.name != ""
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
end
#--------------------------------------------------------------------------
# * Stop Sound Effect
#--------------------------------------------------------------------------
def se_stop
Audio.se_stop
end
#--------------------------------------------------------------------------
# * Get Playing Background Music
#--------------------------------------------------------------------------
def playing_bgm
return @playing_bgm
end
#--------------------------------------------------------------------------
# * Get Playing Background Sound
#--------------------------------------------------------------------------
def playing_bgs
return @playing_bgs
end
#--------------------------------------------------------------------------
# * Get Windowskin File Name
#--------------------------------------------------------------------------
def windowskin_name
if @windowskin_name == nil
return $data_system.windowskin_name
else
return @windowskin_name
end
end
#--------------------------------------------------------------------------
# * Set Windowskin File Name
# windowskin_name : new windowskin file name
#--------------------------------------------------------------------------
def windowskin_name=(windowskin_name)
@windowskin_name = windowskin_name
end
#--------------------------------------------------------------------------
# * Get Battle Background Music
#--------------------------------------------------------------------------
def battle_bgm
if @battle_bgm == nil
return $data_system.battle_bgm
else
return @battle_bgm
end
end
#--------------------------------------------------------------------------
# * Set Battle Background Music
# battle_bgm : new battle background music
#--------------------------------------------------------------------------
def battle_bgm=(battle_bgm)
@battle_bgm = battle_bgm
end
#--------------------------------------------------------------------------
# * Get Background Music for Battle Ending
#--------------------------------------------------------------------------
def battle_end_me
if @battle_end_me == nil
return $data_system.battle_end_me
else
return @battle_end_me
end
end
#--------------------------------------------------------------------------
# * Set Background Music for Battle Ending
# battle_end_me : new battle ending background music
#--------------------------------------------------------------------------
def battle_end_me=(battle_end_me)
@battle_end_me = battle_end_me
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# reduce timer by 1
if @timer_working and @timer > 0
@timer -= 1
end
end
end
I also checked what kyonides suggested but as DerVVulfman pointed out, the lead_actor = 0 line is already in the Game System's initialize segment of that custom script:
Code: class Game_System
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
attr_reader :lead_actor
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias slipknot_las_init initialize
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
slipknot_las_init
@lead_actor = 0
So, I moved the unaltered script to the very bottom, just above Main, but still encounter the same error on line 61. Adding the extra lines by kyonides to that custom script's update method section still yields an error
Posts: 4,862
Threads: 587
Joined: Dec 2009
9 hours ago
(This post was last modified: 3 hours ago by kyonides.
Edit Reason: Changed the filename to Scripts.rxdata
)
Err, nope, the default Game_System script has never included the @lead_actor variable at all. And it's not supposed to anyway.
I tested the script today on a new test project and everything worked fine. I dunno if  Wulfo has altered it ever since he backed it up on that subforum, but in its current state it should work off the  bat.
Once you moved the script to the bottom but just above Main, it should have worked normally.
The caterpillar script might be a problem indeed IF it never aliased the Game_System's initialize method. But again, that should have stopped causing you all kind of problems once you placed slipknot's script right above Main.
Usually, we scripters don't need to make this request, still, I think we might need to take a look at your blank project's Scripts.rxdata file that includes the actor swapper script. Perhaps you forgot to mention something or you've altered some default or custom script and now it's causing you all these issues now.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 12,580
Threads: 1,755
Joined: May 2009
5 hours ago
(This post was last modified: 5 hours ago by DerVVulfman.)
(9 hours ago)kyonides Wrote: Err, nope, the default Game_System script has never included the @lead_actor variable at all. And it's not supposed to anyway. 
Clearly, not paying attention as I posted a portion of Sheol's script:
(Yesterday, 01:56 AM)DerVVulfman Wrote: Code: class Game_System
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
attr_reader :lead_actor
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias slipknot_las_init initialize
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
slipknot_las_init
@lead_actor = 0
end
Here, we can see that the value is indeed created within Game_System within its 'initialize' method.
Here I pointed out pointed out that lead_actor value is created by the Game_System 'alias'ation within Sheol's script. And nope, I never touched or altered the script. So it is in its innate form.
(9 hours ago)kyonides Wrote: Once you moved the script to the bottom but just above Main, it should have worked normally.  Now THAT is 100% true. The hierarchy of the scripts are essentially top-down. So the first thing that loads are the default scripts at the very top... and then works its way down. If you have a script that rewrites Game_System and then a script that attaches code to Game_System (like Sheol's), the result would be a Game_System that contains both. If you have it in reverse (the alias, then the rewrite), then the changes made by the alias are moot and only the rewrite exists.
(9 hours ago)kyonides Wrote: Usually, we scripters don't need to make this request, still, I think we might need to take a look at your blank project's Data.rxdata file that includes the actor swapper script. Perhaps you forgot to mention something or you've altered some default or custom script and now it's causing you all these issues now.
We may indeed need to see your project. But it would need contain the entire script package as there may be other scripts in play.
BEFORE this, try this:
Make a copy of your project for a test procedure. Within the separate test project, see what happens when you delete the caterpillar script. If there is still an issue, the caterpillar script is not the problem. Following that, delete another custom script, and test once more. Continue deleting custom scripts until the it works correctly, the last custom script being the problem.
If it cannot be narrowed down, then examination of the project will be needed.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
|