Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SG scripts giving errors in encrypted project

I want to use Sand Golem's battle retry and temporary save scripts but im given an error when using them in an encrypted project. So my request is if anyone could provide a fix or guide me to making it encrypted compatible.

My scripting level is pretty low. I am using the SDK.

error code for battle retry:
(when retry switch is turned on)
unable to find file Data/retry.sg.

battle retry script:
Code:
#==========================================================================
# ** SG Battle Retry
#==========================================================================
# sandgolem 
# Version 5
# 16.06.06
#==========================================================================

Scene_Battle::SG_CantRetryBattle = 1

#==========================================================================
#Allow players to retry battles that they've lost. Can be disabled and only 
#turned on for boss fights if you want. Has a short gameover screen delay 
#before showing the popup.
#
#Simply put it in your game, no assembly required.
#
#If you'd like to disable this effect sometimes, find this line:
#              Scene_Battle::SG_CantRetryBattle = 0
#Change the 0 to a switch ID. When the switch is on, battle retry is disabled.
#
#-----------------------------------------------------------------------
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it.
#
# Have problems? Official topic:
#   http://forums.gamebaker.com/showthread.php?t=8
#
#==========================================================================

begin
  SDK.log('SG Battle Retry', 'sandgolem', 5, '16.06.06')
  if SDK.state('SG Battle Retry') != true
    @sg_battleretry_disabled = true
  end
  rescue
end

if !@sg_battleretry_disabled
#--------------------------------------------------------------------------

class Interpreter
  alias sandgolem_battleretry_interp_601 command_601
  def command_601
    if $sg_retrywon
      @branch[@list[@index].indent] = 0
      $sg_retrywon = nil
    end
    return sandgolem_battleretry_interp_601
  end
  
  alias sandgolem_battleretry_interp_602 command_602
  def command_602
    if $game_temp.battle_can_escape && $sg_retryescaped
      @branch[@list[@index].indent] = 1
      $sg_retryescaped = nil
    end
    return sandgolem_battleretry_interp_602
  end
end

class Game_System
  attr_accessor :playing_bgm
end

class Game_Temp
  attr_accessor :battle_music_playing
end

class Scene_Map
  alias sandgolem_bretry_map_callbattle call_battle
  def call_battle
    sandgolem_bretry_map_callbattle
    $game_temp.battle_music_playing = $game_system.playing_bgm.clone
  end
end

class Scene_Save < Scene_File  
  def sg_write_retrysave_data
    file = File.open('Data/retry.sg', 'wb')
    write_save_data(file)
    file.close
  end
end

class Scene_Load < Scene_File  
  def sg_read_retrysave_data
    file = File.open('Data/retry.sg', 'rb')
    read_save_data(file)
    file.close
  end
end

class Scene_Battle
  alias sandgolem_battleretry_battle_main main
  def main
    $sg_retryescaped = nil
    $sg_retrywon = nil
    if $game_switches[SG_CantRetryBattle] == 0 or 
    !$game_switches[SG_CantRetryBattle] 
      if !$sg_battleretry_inbattle && !$game_temp.battle_can_lose
        $sg_battleretry_inbattle = $game_temp
        sg_scene_save_temp = Scene_Save.new
        sg_scene_save_temp.sg_write_retrysave_data
        sg_scene_save_temp = nil
      end
    end
    sandgolem_battleretry_battle_main
    if !$scene.is_a?(Scene_Gameover)
      if FileTest.exist?('Data/retry.sg')
        File.delete('Data/retry.sg')
      end
      $sg_battleretry_inbattle = nil
    end
  end
  
  alias sandgolem_battleretry_battle_batend battle_end
  def battle_end(result)
    case result
    when 0
      $sg_retrywon = true
    when 1
      $sg_retryescaped = true
    end
    sandgolem_battleretry_battle_batend(result)
  end
end

class Scene_Gameover
  alias sandgolem_battleretry_gameover_main main
  def main
    if $sg_battleretry_inbattle
      @sprite = Sprite.new
      @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
      $game_system.bgm_stop
      $game_system.me_play($data_system.gameover_me)
      Graphics.transition(90)
      @command_window = Window_Command.new(192,['Retry Battle','Title Screen'])
      @command_window.back_opacity = 160
      @command_window.x = 320 - @command_window.width / 2
      @command_window.y = 288
      loop do
        Graphics.update
        Input.update
        sg_retry_update
        if $scene != self
          break
        end
      end
      @command_window.dispose
      Graphics.freeze
      @sprite.bitmap.dispose
      @sprite.dispose
      Graphics.transition(30)
      Graphics.freeze
    else
      sandgolem_battleretry_gameover_main
    end
  end
  
  def sg_retry_update
    @command_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        sg_scene_save_temp = Scene_Load.new
        sg_scene_save_temp.sg_read_retrysave_data
        sg_scene_save_temp = nil
        $game_temp = $sg_battleretry_inbattle
        $game_temp.gameover = nil
        $game_system.bgm_play($game_temp.battle_music_playing)
        $scene = Scene_Battle.new
      when 1
        if FileTest.exist?('Data/retry.sg')
          File.delete('Data/retry.sg')
        end
        $sg_battleretry_inbattle = nil
        $scene = Scene_Title.new
      end
    end
  end
end

#--------------------------------------------------------------------------
end

error code for sg temp save:
(when temp saving)
Unable to find file section092:45:in 'initialize'data/sg_temps.rxdata.

(when temp loading)
Unable to find file section092:54:in 'initialize'data/sg_temps.rxdata.

SG temp save script:
Code:
#==========================================================================
# ** SG Temporary Save
#==========================================================================
# sandgolem 
# Version 1
# 9.04.06
#==========================================================================
#
# To temporarily save ingame, use this in a call script:
#   sg_temp_save
#
# To load it, use this:
#   sg_temp_load
#
# Best used before you start what you want it for, then start it right after.
# This is NOT an actual saved game a player can load.
#
#==========================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it. This script
# needs to be placed under any that alter the saves and SG Settings Control.
#
# Have problems? Official topic:
#   http://forums.gamebaker.com/showthread.php?t=152
#
#==========================================================================

begin
  SDK.log('SG Temporary Save', 'sandgolem', 1, '9.04.06')
  if SDK.state('SG Temporary Save') != true
    @sg_tempsave_disabled = true
  end
  rescue
end

if !@sg_tempsave_disabled
#--------------------------------------------------------------------------

class Scene_Save < Scene_File  
  def sg_write_tempsave_data
    file = File.open("Data/sg_temps.rxdata", "wb")
    Marshal.dump($game_temp, file)
    write_save_data(file)
    file.close
  end
end

class Scene_Load < Scene_File  
  def sg_read_tempsave_data
    file = File.open("Data/sg_temps.rxdata", "rb")
    $game_temp = Marshal.load(file)
    read_save_data(file)
    file.close
  end
end

def sg_temp_save
  sg_scene_tsave_temp = Scene_Save.new
  sg_scene_tsave_temp.sg_write_tempsave_data
  sg_scene_tsave_temp = nil
end

def sg_temp_load
  sg_scene_tsave_temp = Scene_Load.new
  sg_scene_tsave_temp.sg_read_tempsave_data
  sg_scene_tsave_temp = nil
  $game_temp.player_new_map_id = $game_map.map_id
  $game_temp.player_new_x = $game_player.x
  $game_temp.player_new_y = $game_player.y
  $game_temp.transition_processing = true
  $game_temp.transition_name = ""  
  $game_temp.player_transferring = true
end

#--------------------------------------------------------------------------
end

thankyou for any support given. ^_^
 
Encrypted games don't have a "Data/" folder, so try taking that part out of the scripts. :)

These lines would need the Data/ removed:

First script:
file = File.open('Data/retry.sg', 'wb')
file = File.open('Data/retry.sg', 'rb')
if FileTest.exist?('Data/retry.sg')
File.delete('Data/retry.sg')
The last two appear twice

Second:
file = File.open("Data/sg_temps.rxdata", "wb")
file = File.open("Data/sg_temps.rxdata", "rb")

Not sure if it'd work, been ages since I've touched that stuff, but it could be the only problem.
 
thanks for the help ^_^ I was gonna register and post on gamebaker forums, but thread was extremely old.

Another member called XleD fixed the problem before i checked this thread. Its the same method as yours i believe so it works ^_^ It was definately the absence of the data folder anyways.

But thanks for creating the scripts :D
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top