Lead Actor Swapper script error
#1
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.  Fear
[Image: SP1-Writer.png]
[Image: SP1-PixelArtist.png]
Reply
#2
Is that really all the information the popup window has provided you with? Thinking
"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.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

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! Laughing + Tongue sticking out

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
Reply
#3
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. Laughing + Tongue sticking out
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply
#4
(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.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

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! Laughing + Tongue sticking out

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
Reply
#5
(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.  Confused

   

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
[Image: SP1-Writer.png]
[Image: SP1-PixelArtist.png]
Reply
#6
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.

Code:
@lead_actor = 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.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

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! Laughing + Tongue sticking out

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
Reply
#7
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...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
   Actor Voices by diamondandplatinum3, note-tag commands not working! Starmage 1 414 08-04-2025, 09:02 AM
Last Post: Starmage
   Plugin or Script help with Item menu, SKill menu, and Equip menu JayRay 3 2,671 11-22-2024, 07:02 PM
Last Post: JayRay
   Atoa ACBS, Equipment Set Add-on Error Solitaire 10 5,754 10-13-2024, 11:41 PM
Last Post: Solitaire
   Personal graph by actor zlsl 4 7,843 10-23-2021, 06:43 AM
Last Post: zlsl
   Script compatibility help Lord Vectra 3 7,021 07-25-2021, 11:42 PM
Last Post: DerVVulfman
   Adding face script on Cogwheel's RTAB Battle Status rekkatsu 15 22,148 08-25-2020, 03:09 AM
Last Post: DerVVulfman
   "Wait" in the script Whisper 13 21,489 04-28-2020, 04:06 PM
Last Post: Whisper
   Skill Cooldown script Fenriswolf 11 21,408 12-10-2019, 11:10 AM
Last Post: Fenriswolf
   (RMVXace) Battle error with Tankentai's battle system, help. x( Starmage 0 5,018 02-14-2018, 04:25 PM
Last Post: Starmage
   Help iwth script (RGSS Player crash) Whisper 3 10,388 06-17-2017, 05:03 PM
Last Post: Whisper



Users browsing this thread: 1 Guest(s)