TypeError Fixnum into String - Essentials v.17.2

Marina

Cooltrainer
Member
Joined
Mar 10, 2018
Posts
129
Hello, I'm using Essentials v.17.2 and Deos gen 6 pbs files and Items and every time, I also wrote every Mega Stone into pbItems items.txt with the item icons
and every time I playtest, this error shows up:

Code:
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]
 
Exception: TypeError
 
Message: cannot convert Fixnum into String
 
Game_Player:480:in `+'
 
Game_Player:480:in `pbGetPlayerCharset'
 
PScreen_Load:156:in `pbSetParty'
 
PScreen_Load:319:in `pbStartLoadScreen'
 
Main:6:in `main'
 
Main:49:in `mainFunctionDebug'
 
Main:27:in `mainFunction'
 
Main:27:in `pbCriticalCode'
 
Main:27:in `mainFunction'
 
Main:59
 
 
 
This exception was logged in
 
C:\Users\Marina\Saved Games\Pokemon Essentials\errorlog.txt.
 
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK 
---------------------------

edit: I added more Infos about the error as I read through it.


In Game_Player:480:in `+'
Game_Player:480:in `pbGetPlayerCharset' (line 480-484):

if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)
ret=ret+"_"+outfit.to_s
end
return ret
end



In PScreen_Load:156:in `pbSetParty' (line 152-170):
filename = pbGetPlayerCharset(meta,1,trainer)

def pbSetParty(trainer)
return if !trainer || !trainer.party
meta = pbGetMetadata(0,MetadataPlayerA+trainer.metaID)
if meta
filename = pbGetPlayerCharset(meta,1,trainer)
@sprites["player"] = TrainerWalkingCharSprite.new(filename,@viewport)
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height
@sprites["player"].x = 56*2-charwidth/8
@sprites["player"].y = 56*2-charheight/8
@sprites["player"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
end
for i in 0...trainer.party.length
@sprites["party#{i}"] = PokemonIconSprite.new(trainer.party,@viewport)
@sprites["party#{i}"].x = 151*2+33*2*(i&1)
@sprites["party#{i}"].y = 36*2+25*2*(i/2)
@sprites["party#{i}"].z = 99999
end
end


In PScreen_Load 319 `PbStartLoadScreen' (Line 245 - 319):
def pbStartLoadScreen
$PokemonTemp = PokemonTemp.new
$game_temp = Game_Temp.new
$game_system = Game_System.new
$PokemonSystem = PokemonSystem.new if !$PokemonSystem
savefile = RTP.getSaveFileName("Game.rxdata")
FontInstaller.install
data_system = pbLoadRxData("Data/System")
mapfile = ($RPGVX) ? sprintf("Data/Map%03d.rvdata",data_system.start_map_id) :
sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
Kernel.pbMessage(_INTL("No starting position was set in the map editor.\1"))
Kernel.pbMessage(_INTL("The game cannot continue."))
@scene.pbEndScene
$scene = nil
return
end
commands = []
cmdContinue = -1
cmdNewGame = -1
cmdOption = -1
cmdLanguage = -1
cmdMysteryGift = -1
cmdDebug = -1
cmdQuit = -1
if safeExists?(savefile)
trainer = nil
framecount = 0
mapid = 0
haveBackup = false
showContinue = false
begin
trainer, framecount, $game_system, $PokemonSystem, mapid = pbTryLoadFile(savefile)
showContinue = true
rescue
if safeExists?(savefile+".bak")
begin
trainer, framecount, $game_system, $PokemonSystem, mapid = pbTryLoadFile(savefile+".bak")
haveBackup = true
showContinue = true
rescue
end
end
if haveBackup
Kernel.pbMessage(_INTL("The save file is corrupt. The previous save file will be loaded."))
else
Kernel.pbMessage(_INTL("The save file is corrupt, or is incompatible with this game."))
if !Kernel.pbConfirmMessageSerious(_INTL("Do you want to delete the save file and start anew?"))
$scene = nil
return
end
begin; File.delete(savefile); rescue; end
begin; File.delete(savefile+".bak"); rescue; end
$game_system = Game_System.new
$PokemonSystem = PokemonSystem.new if !$PokemonSystem
Kernel.pbMessage(_INTL("The save file was deleted."))
end
end
if showContinue
if !haveBackup
begin; File.delete(savefile+".bak"); rescue; end
end
end
commands[cmdContinue = commands.length] = _INTL("Continue") if showContinue
commands[cmdNewGame = commands.length] = _INTL("New Game")
commands[cmdMysteryGift = commands.length] = _INTL("Mystery Gift") if (trainer.mysterygiftaccess rescue false)
else
commands[cmdNewGame = commands.length] = _INTL("New Game")
end
commands[cmdOption = commands.length] = _INTL("Options")
commands[cmdLanguage = commands.length] = _INTL("Language") if LANGUAGES.length>=2
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmdQuit = commands.length] = _INTL("Quit Game")
@scene.pbStartScene(commands,showContinue,trainer,framecount,mapid)
@scene.pbSetParty(trainer) if showContinue


Main: line 6: in `main' (lines 1-9):
class Scene_DebugIntro
def main
Graphics.transition(0)
sscene = PokemonLoad_Scene.new
sscreen = PokemonLoadScreen.new(sscene)
sscreen.pbStartLoadScreen
Graphics.freeze
end
end


Main: line 49: in `mainFunctionDebug' (line 34 - 56):
def mainFunctionDebug
begin
getCurrentProcess = Win32API.new("kernel32.dll","GetCurrentProcess","","l")
setPriorityClass = Win32API.new("kernel32.dll","SetPriorityClass",%w(l i),"")
setPriorityClass.call(getCurrentProcess.call(),32768) # "Above normal" priority class
$data_animations = pbLoadRxData("Data/Animations")
$data_tilesets = pbLoadRxData("Data/Tilesets")
$data_common_events = pbLoadRxData("Data/CommonEvents")
$data_system = pbLoadRxData("Data/System")
$game_system = Game_System.new
setScreenBorderName("border") # Sets image file for the border
Graphics.update
Graphics.freeze
$scene = pbCallTitle
while $scene!=nil
$scene.main
end
Graphics.transition(20)
rescue Hangup
pbEmergencySave
raise
end
end


Main:27:in `mainFunction'
Main:27:in `pbCriticalCode'
Main:27:in `mainFunction' (Main whole mainFunktion def):

def mainFunction
if $DEBUG
pbCriticalCode { mainFunctionDebug }
else
mainFunctionDebug
end
return 1
end


Main:59
(Main 58 - 67)

loop do
retval = mainFunction
if retval==0 # failed
loop do
Graphics.update
end
elsif retval==1 # ended successfully
break
end
end

line 59: retval = mainFunction


How do I fix this?
thanks for every help!
 
Last edited:

MGriffin

Trainer
Member
Joined
May 8, 2017
Posts
95
Alright, I'm just going to write what I looked at to try and work out what's going on.

We start at Game_Player line 480 to try and identify which of the things being added with "+" is a Fixnum, not a String (i.e. integer/whole number instead of text):

Code:
if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)

Well that has to be "ret", because "to_s" converts things into strings, and text with quotes around it is a string (specifically a string literal). So we look at the whole "pbGetPlayerCharset" function to see where "ret" gets set:

Code:
ret=meta[charset]
ret=meta[1] if !ret || ret==""

So there are two possibilities for where "ret" came from, it's either "meta[charset]", or if that is "nil" or an empty string it's "meta[1]". The question then is what are the values of "meta" and "charset"?

Code:
def pbGetPlayerCharset(meta,charset,trainer=nil)

They are parameters to "pbGetPlayerCharset", so the values can be found wherever it was called. We can see from your error message that "pbGetPlayerCharset" is called from "pbSetParty" in "PScreen_Load", which is called from "pbStartLoadScreen", which is called from "main", and so on. So we're going to have a look at each of these in turn to figure out what the contents of "meta" and "charset" are, so that we can work out which of "meta[charset]" and "meta[1]" is a Fixnum, and ultimately change it to *not* be one.

We start with "pbSetParty":

Code:
filename = pbGetPlayerCharset(meta,1,trainer)

Okay, so charset is 1. We know this because we've matched up the values in the call with the definition. So that means "meta[charset]" and "meta[1]" are just the same thing, and we only care about where meta came from. Just above this line (line 154) we see this:

Code:
meta = pbGetMetadata(0,MetadataPlayerA+trainer.metaID)

Okay, so "meta"'s value is whatever "pbGetMetadata" returns, so we need to find the definition (i.e. "def pbGetMetadata"). After some looking we find it's in MiscData line 134:

Code:
def pbGetMetadata(mapid,metadataType)
  meta = pbLoadMetadata
  return meta[mapid][metadataType] if meta[mapid]
  return nil
end

We know that it isn't returning "nil" because "meta[1]" is a Fixnum, and "nil[1]" would give an error (if you follow the code you'll see that if meta was "nil" we'd do something different in "pbSetParty", but that's not important right now). So that means that "pbLoadMetadata" must be returning something for which "meta[mapid][metadataType]" is a Fixnum. From the call to "pbGetMetadata" we know "mapid" is 0, and that "metadataType" is the result of "MetadataPlayerA+trainer.metaID". "MetadataPlayerA" is set to 8 in MiscData on line 47, and "trainer.metaID" is probably zero, because MetadataPlayerB is 9, MetadataPlayerC is 10, etc, and also because it defaults to 0 in PokeBattle_Trainer's "metaID".

So armed with the assumption that meta is going to be whatever "pbLoadMetadata[0][8]" is, and thus there is a number instead of a string at "pbLoadMetadata[0][8][1]", we read "pbLoadMetadata", looking to see how it is populated:

Code:
def pbLoadMetadata
  $PokemonTemp = PokemonTemp.new if !$PokemonTemp
  if !$PokemonTemp.pokemonMetadata
	if !pbRgssExists?("Data/metadata.dat")
	  $PokemonTemp.pokemonMetadata = []
	else
	  $PokemonTemp.pokemonMetadata = load_data("Data/metadata.dat")
	end
  end
  return $PokemonTemp.pokemonMetadata
end

It looks a bit like a nightmare, and if you search for "PokemonTemp" you'd probably be tempted to give up because it's used everywhere! But from this code it looks like all it really does is act like a cache so that Essentials only has to load "Data/metadata.dat" once, so let's assume/hope that the answers we're seeking are with whatever code populates that file. Searching for "Data/metadata.dat" leads us to Compiler and "pbCompileMetadata" (all the ".dat" files come from Compiler).

Code:
def pbCompileMetadata
  ...
  File.open("Data/metadata.dat","wb"){|f|
	Marshal.dump(sections,f)
  }
end

This code just dumps the "sections" variable to "Data/metadata.dat", so the question becomes "how is sections populated", and fortunately the answer is the code just above (i.e. the stuff I elided with "...").

We populate sections by reading "PBS/metadata.txt", and the indices in sections are named after the numbers in square brackets in the PBS:

Code:
pbCompilerEachCommentedLine("PBS/metadata.txt") {|line,lineno|
  if line[/^\s*\[\s*(\d+)\s*\]\s*$/]
	sectionname = $~[1]

Therefore since we care about "meta[0][8][1]" we're looking at the section "[000]":

Code:
#-------------------------------
[000]
PlayerA=POKEMONTRAINER_Red,trchar000,boy_bike,boy_surf,boy_run,boy_surf,boy_fish_offset,xxx
PlayerB=POKEMONTRAINER_Leaf,trchar001,girl_bike,girl_surf,girl_run,girl_surf,girl_fish_offset,xxx
Home=3,7,5,8
SurfBGM=Surfing.mid
BicycleBGM=Bicycle.mid
WildBattleBGM=Battle wild.mid
WildVictoryME=Battle victory wild.ogg
TrainerBattleBGM=Battle trainer.mid
TrainerVictoryME=Battle victory trainer.ogg
#-------------------------------

I'm expecting to see that the code writes the data for the line starting "PlayerA=" to index 8, because it makes sense for the names here to match the constants defined in MiscData:

Code:
matchData = $~
schema = nil
FileLineData.setSection(currentmap,matchData[1],matchData[2])
if currentmap==0
  schema = PokemonMetadata::GlobalTypes[matchData[1]]
else
  schema = PokemonMetadata::NonGlobalTypes[matchData[1]]
end
if schema
  record = pbGetCsvRecord(matchData[2],lineno,schema)
  sections[currentmap][schema[0]] = record
end

The indices of "sections[0]" are populated by "sections[currentmap][schema[0]] = record", so let's see if "schema[0]" is 8. "currentmap" is zero, so "schema" is "PokemonMetadata::GlobalTypes[matchData[1]]".

"PokemonMetadata" is defined in (surprise!) MiscData:

Code:
module PokemonMetadata
  GlobalTypes = {
	...
	"PlayerA"		  => [MetadataPlayerA,"esssssss",:PBTrainers],
	...

So yes, "PlayerA" maps to 8. And "schema" is "[8,"esssssss",:PBTrainers]". So maybe "pbGetCsvRecord" (also in Compiler) is incorrectly parsing the schema and returning a Fixnum at index 1 (arrays count from 0, so that corresponds to the first "s" in the schema—"s" stands for string). Well my PBS/metadata.txt certainly doesn't look like it could do such a thing because it has "trchar000" in that location (I assume yours looks different?), but maybe if I change it to just "000".

Code:
PlayerA=POKEMONTRAINER_Red,000,boy_bike,boy_surf,boy_run,boy_surf,boy_fish_offset,xxx

Code:
[Pokémon Essentials version 17.2]
Exception: NoMethodError
Message: undefined method `width' for nil:NilClass
PScreen_Load:158:in `pbSetParty'
PScreen_Load:319:in `pbStartLoadScreen'
Main:6:in `main'
Main:49:in `mainFunctionDebug'
Main:27:in `mainFunction'
Main:27:in `pbCriticalCode'
Main:27:in `mainFunction'
Main:59
Main:58:in `loop'
Main:67

Nope. That error looks like it's because there's no "Graphics/Characters/000.png" (which is true), but I suspect that means that I didn't get a Fixnum… Let's try creating a 000.png just to be safe:

Nope. Everything loads fine.




So my guess is that either you've changed the schema or you've changed the compiler code. Or maybe I took a wrong turn somewhere, that's also quite possible.

EDIT:

I guess we could have skipped all those steps and gone for the hacky (and probably wrong) solution of forcing "ret" into a string with "to_s":

Code:
if pbResolveBitmap("Graphics/Characters/"+ret.to_s+"_"+outfit.to_s)
 
Last edited:

Marina

Cooltrainer
Member
Joined
Mar 10, 2018
Posts
129
I didn't change neither the compiler, nor the schema.
I tried to do the last thing you mentioned:

MGriffin said:
I guess we could have skipped all those steps and gone for the hacky (and probably wrong) solution of forcing "ret" into a string with "to_s":
Code:
if pbResolveBitmap("Graphics/Characters/"+ret.to_s+"_"+outfit.to_s)

I changed the ret to:

line 180 & line 181 of Game_Player:
Code:
if pbResolveBitmap("Graphics/Characters/")
ret=outfit.+ret+"_"+to_s

I playtest it and my character turned out to be a Marowak - on my characters folder: 105, 105s I renamed them to 104b, 104bs, and changed the name of trchar000 into 105, just to be sure that it works. As I playtest again it works for Girl for boy I didn't test yet, I have to test it too though, as I played as girl the player was transfered to another map that I could fix it now though... I hope I don't get any error messages with this change. My Metadata.txt seems the same as yours just the Home instead of 3 is 48 the map id.------------------------Ok when I choose boy I get this error Runtime Error:
Code:
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]
 
Exception: RuntimeError
 
Message: Script error within event 1 (coords 0,0), map 43 ():
 
Exception: NoMethodError
 
Message: TextEntry:930:in `pbStartScene'undefined method `width' for nil:NilClass
 
***Full script:
 
pbTrainerName
 
 
Interpreter:243:in `pbExecuteScript'
 
TextEntry:1546:in `pbStartScreen'
 
TextEntry:1614:in `pbEnterText'
 
TextEntry:1611:in `pbFadeOutIn'
 
TextEntry:1611:in `pbEnterText'
 
TextEntry:1627:in `pbEnterPlayerName'
 
PSystem_Utilities:721:in `pbTrainerName'
 
(eval):1:in `pbExecuteScript'
 
Interpreter:1606:in `eval'
 
Interpreter:243:in `pbExecuteScript'
 
 
 
Interpreter:276:in `pbExecuteScript'
 
Interpreter:1606:in `command_355'
 
Interpreter:494:in `execute_command'
 
Interpreter:193:in `update'
 
Interpreter:106:in `loop'
 
Interpreter:198:in `update'
 
Scene_Map:163:in `update'
 
Scene_Map:161:in `loop'
 
Scene_Map:170:in `update'
 
Scene_Map:234:in `main'
 
 
 
This exception was logged in
 
C:\Users\Utilizador\Saved Games\Pokemon Essentials\errorlog.txt.
 
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK 
---------------------------

as I read the error, it must be something in event 1 the Intro, may be related to the character bein 105 instead of trchar000?
edit: Yes, I fixed this. I renamed the boy character from 105 into trchar000 and its working just fine!


I mark this thread as solved, but when I get a an error due to the changes I've done myself, can I put those changes here?
(Edit: thanks Aki)
 
Last edited:
Top