- 5
- Posts
- 2
- Years
- Seen Sep 3, 2022
So I'm making a battle record for my game, and yesterday I got it to successfully pull up and get rid of the screens as desired. Here is the code in question:
I've also tried to do
and it does the same thing as
But then when I try to save, I get this error:
And the game crashes. Then when I try to reload, this error shows up:
I know the code in question is the culprit, but what can I do to change it so the viewport goes away AND I don't get this error.
Code:
def battle_history_window(switch)
if switch == "on" then
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
total_stats = "LIFETIME RECORD (W-D-L): #{$game_variables[60]}-#{$game_variables[61]}-#{$game_variables[62]}"
history_stats = "%s/%s/%s\n" % ["TRAINER", "CUP", "RESULT"]
for indx in 91..100 do
if $game_variables[indx] != 0 then
history_stats += "%s/%s/%s\n" % [$game_variables[indx][0], $game_variables[indx][1], $game_variables[indx][2]]
end
end
@sprites["lifetime"] = Window_UnformattedTextPokemon.newWithSize(total_stats, 0, 0, Graphics.width, 64, @viewport)
@sprites["recent"] = Window_UnformattedTextPokemon.newWithSize(history_stats, 0, 64, Graphics.width, Graphics.height - 64, @viewport)
elsif switch == "off" then
@sprites["lifetime"].dispose
@sprites["recent"].dispose
end
end
I've also tried to do
Code:
@viewport.dispose
Code:
@sprites["x"].dispose
But then when I try to save, I get this error:
Code:
[2022-09-03 18:21:40 -0600]
[Pokemon Essentials version 20]
Exception: TypeError
Message: no _dump_data is defined for class Viewport
Backtrace:
024:SaveData:60:in `dump'
024:SaveData:60:in `block in save_to_file'
024:SaveData:60:in `open'
024:SaveData:60:in `save_to_file'
031:StartGame:117:in `save'
290:UI_Save:100:in `pbSaveScreen'
277:UI_PauseMenu:263:in `block in <main>'
277:UI_PauseMenu:124:in `block in pbStartPokemonMenu'
277:UI_PauseMenu:117:in `loop'
277:UI_PauseMenu:117:in `pbStartPokemonMenu'
And the game crashes. Then when I try to reload, this error shows up:
Code:
[2022-09-03 18:30:42 -0600]
[Pokemon Essentials version 20]
Exception: ArgumentError
Message: marshal data too short
Backtrace:
<internal:marshal>:34:in `load'
024:SaveData:28:in `load'
024:SaveData:28:in `block in get_data_from_file'
024:SaveData:27:in `open'
024:SaveData:27:in `get_data_from_file'
024:SaveData:45:in `read_from_file'
031:StartGame:23:in `set_up_system'
405:Main:31:in `mainFunctionDebug'
405:Main:18:in `block in mainFunction'
014:Errors:80:in `pbCriticalCode'
I know the code in question is the culprit, but what can I do to change it so the viewport goes away AND I don't get this error.