02-13-2025, 04:06 AM
(This post was last modified: 02-27-2025, 03:15 PM by kyonides.
Edit Reason: Script Update #5
)
Bug Fix for RMXP's Interpreter's Script Command
Introduction
For ages we've known very well that the RMXP Interpreter class had an issue with command_355 aka the script event command. It has to evaluate the result of a script pasted as mere text in a very small window. The problem was that certain non truthy values, anything that doesn't return true as end result, might get ignored by the game engine. This part and its related solution are nothing new in the XP community and I just "copied & pasted" that centuries old solution here.
Nonetheless, that's not all this scriptlet has to offer. I was discussing some issues with XP in a VX ACE channel when I noticed there was another


The issue is very simple. You open the conditional branch and choose the script condition and type something there that's supposed to return a boolean value. (No if conditional reserved term is required there.) Now you'd expect me to tell you that it had the same issue the script command has... but nope, that's not the case here.
Both a truthy (true) and a falsey (false) value are fine and work just as intended. Yet, here comes the dreadful nil value into play!
Whenever your call returns a nil, your check becomes invalid and the engine simply skips it.


Don't


The Up-to-date Script
Please

Version 5
If it looks an awful lot like Version 1, you're probably right about it! The main difference is the final outcome: there's no visual glitch involved!
Code:
# * Bug Fixes for Both of RMXP's Interpreter's Script Commands * #
# 2025-02-27 - The Infamous Version 5
# It is the pretty much the same as Version 1 but it lets you prevent
# the message window visual glitch from ever transpiring.
class Interpreter
# * Conditional Branch * #
# Altered the Script Condition at the very end of this command
def command_111
# Initialize local variable: result
result = false
case @parameters[0]
when 0 # switch
result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
when 1 # variable
value1 = $game_variables[@parameters[1]]
if @parameters[2] == 0
value2 = @parameters[3]
else
value2 = $game_variables[@parameters[3]]
end
case @parameters[4]
when 0 # value1 is equal to value2
result = (value1 == value2)
when 1 # value1 is greater than or equal to value2
result = (value1 >= value2)
when 2 # value1 is less than or equal to value2
result = (value1 <= value2)
when 3 # value1 is greater than value2
result = (value1 > value2)
when 4 # value1 is less than value2
result = (value1 < value2)
when 5 # value1 is not equal to value2
result = (value1 != value2)
end
when 2 # self switch
if @event_id > 0
key = [$game_map.map_id, @event_id, @parameters[1]]
if @parameters[2] == 0
result = ($game_self_switches[key] == true)
else
result = ($game_self_switches[key] != true)
end
end
when 3 # timer
if $game_system.timer_working
sec = $game_system.timer / Graphics.frame_rate
if @parameters[2] == 0
result = (sec >= @parameters[1])
else
result = (sec <= @parameters[1])
end
end
when 4 # actor
actor = $game_actors[@parameters[1]]
if actor != nil
case @parameters[2]
when 0 # in party
result = ($game_party.actors.include?(actor))
when 1 # name
result = (actor.name == @parameters[3])
when 2 # skill
result = (actor.skill_learn?(@parameters[3]))
when 3 # weapon
result = (actor.weapon_id == @parameters[3])
when 4 # armor
result = (actor.armor1_id == @parameters[3] or
actor.armor2_id == @parameters[3] or
actor.armor3_id == @parameters[3] or
actor.armor4_id == @parameters[3])
when 5 # state
result = (actor.state?(@parameters[3]))
end
end
when 5 # enemy
enemy = $game_troop.enemies[@parameters[1]]
if enemy != nil
case @parameters[2]
when 0 # appear
result = (enemy.exist?)
when 1 # state
result = (enemy.state?(@parameters[3]))
end
end
when 6 # character
character = get_character(@parameters[1])
if character != nil
result = (character.direction == @parameters[2])
end
when 7 # gold
if @parameters[2] == 0
result = ($game_party.gold >= @parameters[1])
else
result = ($game_party.gold <= @parameters[1])
end
when 8 # item
result = ($game_party.item_number(@parameters[1]) > 0)
when 9 # weapon
result = ($game_party.weapon_number(@parameters[1]) > 0)
when 10 # armor
result = ($game_party.armor_number(@parameters[1]) > 0)
when 11 # button
result = (Input.press?(@parameters[1]))
when 12 # script
result = eval(@parameters[1])
end
# Store determinant results in hash
# Added pos variable for the sake of convenience
pos = @list[@index].indent
# Bug Fix - Turn any nil value into false by default
@branch[pos] = !!result
# If determinant results are true
if @branch[pos]
# Delete branch data
@branch.delete(pos)
# Continue
return true
end
# If it doesn't meet the conditions: command skip
return command_skip
end
# * Script Event Command * #
# Just a small variant of a very old bug fix published by several people
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Loop
loop do
# If next event command is second line of script or after
if @list[@index+1].code == 655
# Add second line or after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line or after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
result = eval(script)
# Removed Several Lines Here Before Continue
return true
end
end
The code below does work indeed, but as "Abe" Zeriab noted in the discussion thread it causes a minimal visual glitch that makes the message window disappear whenever the result is false. I suspect that shouldn't happen if the return value is nil based on my comments on how the Interpreter#update method works. Now you've been warned!
Version 4
Code:
# * Bug Fixes for Both of RMXP's Interpreter's Script Commands * #
# 2025-02-26
class Interpreter
# * Conditional Branch * #
# Altered the Script Condition at the very end of this command
def command_111
# Initialize local variable: result
result = false
case @parameters[0]
when 0 # switch
result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
when 1 # variable
value1 = $game_variables[@parameters[1]]
if @parameters[2] == 0
value2 = @parameters[3]
else
value2 = $game_variables[@parameters[3]]
end
case @parameters[4]
when 0 # value1 is equal to value2
result = (value1 == value2)
when 1 # value1 is greater than or equal to value2
result = (value1 >= value2)
when 2 # value1 is less than or equal to value2
result = (value1 <= value2)
when 3 # value1 is greater than value2
result = (value1 > value2)
when 4 # value1 is less than value2
result = (value1 < value2)
when 5 # value1 is not equal to value2
result = (value1 != value2)
end
when 2 # self switch
if @event_id > 0
key = [$game_map.map_id, @event_id, @parameters[1]]
if @parameters[2] == 0
result = ($game_self_switches[key] == true)
else
result = ($game_self_switches[key] != true)
end
end
when 3 # timer
if $game_system.timer_working
sec = $game_system.timer / Graphics.frame_rate
if @parameters[2] == 0
result = (sec >= @parameters[1])
else
result = (sec <= @parameters[1])
end
end
when 4 # actor
actor = $game_actors[@parameters[1]]
if actor != nil
case @parameters[2]
when 0 # in party
result = ($game_party.actors.include?(actor))
when 1 # name
result = (actor.name == @parameters[3])
when 2 # skill
result = (actor.skill_learn?(@parameters[3]))
when 3 # weapon
result = (actor.weapon_id == @parameters[3])
when 4 # armor
result = (actor.armor1_id == @parameters[3] or
actor.armor2_id == @parameters[3] or
actor.armor3_id == @parameters[3] or
actor.armor4_id == @parameters[3])
when 5 # state
result = (actor.state?(@parameters[3]))
end
end
when 5 # enemy
enemy = $game_troop.enemies[@parameters[1]]
if enemy != nil
case @parameters[2]
when 0 # appear
result = (enemy.exist?)
when 1 # state
result = (enemy.state?(@parameters[3]))
end
end
when 6 # character
character = get_character(@parameters[1])
if character != nil
result = (character.direction == @parameters[2])
end
when 7 # gold
if @parameters[2] == 0
result = ($game_party.gold >= @parameters[1])
else
result = ($game_party.gold <= @parameters[1])
end
when 8 # item
result = ($game_party.item_number(@parameters[1]) > 0)
when 9 # weapon
result = ($game_party.weapon_number(@parameters[1]) > 0)
when 10 # armor
result = ($game_party.armor_number(@parameters[1]) > 0)
when 11 # button
result = (Input.press?(@parameters[1]))
when 12 # script
result = eval(@parameters[1])
end
# Store determinant results in hash
# Added pos variable for the sake of convenience
pos = @list[@index].indent
# Bug Fix - Turn any nil value into false by default
@branch[pos] = !!result
# If determinant results are true
if @branch[pos]
# Delete branch data
@branch.delete(pos)
# Continue
return true
end
# If it doesn't meet the conditions: command skip
return command_skip
end
# * Script Event Command * #
# Just a small variant of a very old bug fix published by several people
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Loop
loop do
# If next event command is second line of script or after
if @list[@index+1].code == 655
# Add second line or after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line or after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
result = eval(script)
# NEW: Single Line Script Call Bug Fix Inspired on the Original Condition
# If return value is false OR nil
unless result
# Increase value of @index to prevent RMXP from getting stuck
@index += 1
# End
return false
end
return true
end
end
Obsolete Versions
Infrequently Asked Questions
Q: Has anybody else posted anything like this before?
A: Who knows?

Terms of Use
You can do whatever you want with it, I just built something upon somebody else's work and that's it.
[/spoiler]
"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]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/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!
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
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]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/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!

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