Class Game
Authors: Twb6543
Version: 1.2
Type: Scripting Tool and Game Utility
Key Term: Scripting Tool
IntroductionQuoteCreative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
You are free:
to Share - to copy, distribute and transmit the work
to Remix - to adapt the work
Under the following conditions:
Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
Noncommercial. You may not use this work for commercial purposes.
Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
- Any of the above conditions can be waived if you get permission from the copyright holder.
- Nothing in this license impairs or restricts the authors moral rights.
This adds $game to the game and allows for registration and requirements for scripts...
This adds mostly the same features that RGSS had for registration and requires...
Features
- register(name,version)
- script?(name)
- version?(name,version,returnversion) // returnversion is 1 for return of version (return version number)
- deletekey(name)
- updateversion(name,version)
- clear
ScreenshotsScreenshots N/A
DemoNo Demo just plugin and play
ScriptPut this script above ALL custom scripts unless otherwise specified
//Download a .txt document of the script here //
#===============================================================================
# Aliasing
#===============================================================================
# Alias the neccessary methods to change Game to $game // Is currently here do
# to strange errors if I place it anywhere else (might not happen to others)...
#===============================================================================
class Scene_Title < Scene_Base
alias :old_create_game_objects :create_game_objects
def create_game_objects
old_create_game_objects
$game = Game.new
end
end
class Scene_File < Scene_Base
alias :old_write_save_data :write_save_data
def write_save_data(file)
old_write_save_data(file)
Marshal.dump($game, file)
end
alias :old_read_save_data :read_save_data
def read_save_data(file)
$game = Marshal.load(file)
old_read_save_data(file)
end
end
#===============================================================================
# Class Game Ver 1.2
# by Twb6543
#===============================================================================
# Adds registeration and script? commands
# Mimics RmXp commands of register and requirements
# Adds has $Scripts with layout script => version ...
# Use $Game.command to carry out a command (replacing command with a command)
#===============================================================================
#===============================================================================
# Commands:
# - register(name,version)
# - script?(name)
# - version?(name,version,returnversion) // returnversion is 1 for return of
# version (return version number)
# - deletekey(name)
# - updateversion(name,version)
# - clear
#===============================================================================
#===============================================================================
# - Versions are automatically use 1.0 for base version you may change this on
# line 67 , 79, 107...
#===============================================================================
class Game
def initialize
$Scripts = {}
register("Game",1.2)
end
def register(name,version=1.0)
$Scripts[name] = version
end
def script?(name)
return $Scripts.has_key?(name)
end
def version?(name=1,version=1.0,a=0)
if a == 1
return $Scripts[name]
else
if $Scripts[name] >= version
return true
else
return false
end
end
end
def deletekey(name)
$Scripts.delete(name)
if script?("Game") != true
register("Game",1.2)
end
end
def updateversion(name,version=1.0)
$Scripts.delete(name)
$Scripts[name] = version
end
def clear
$Scripts.clear
$Scripts["Game"] = 1.2
end
end
InstructionsSee script... (POST ABOVE ALL OTHER CUSTOM SCRIPTS)
Usage of commandsRegister: $game.register("Test",1.0)
// Registers the script
Script?:if $game.script?("Test") == true
$game_variables[1] = 1
end
// If script Test is registered then Game_Variables 1 is set to 1
Version?:if $game.version?("Test",1.0,1) >= 1.0
$game_variables[2] = 1
end
// If script version test is 1.0 or over then Game_Variables 2 is set to 1
if $game.version?("Test",1.0) == True OR if if $game.version?("Test",1.0,0) = True
$game_variables[2] = 1
end
// If script version test is 1.0 or over then Game_Variables 2 is set to 1
DeleteKey:$game.deletekey("Test")
//Will delete the info on script Test from $Scripts
UpdateVersion:$game.updateversion("Test",1.1)
// Sets the version information about Test, in $Scripts, to 1.1
Clear:$game.clear
//Clears $Scripts
ScriptersI recommend using a style like this to register your script in the initialize def...
if $Scripts["Game"] >= 1.2
$game.register("Script",Version)
else
print "Class Game is not found please install correctly Class Game 1.2"
print "Visit
http://forum.chaos-project.com/index.php/topic,9831"
end
CompatibilityShould be compatible with most scripts.
Credits and Thanks
- Twb6543
- Enterbrain - for original in RMXP
Author's NotesNothing really to add - Sorry for the section at the top but really it's the only thing that makes it work for my pc... You may have to use $SCRIPT =
SCRIPT.new for the commands to register (You may have to run your script). To all scripters their is little comments but all commands should be fairly easy to understand.
Change Log1.2
- Registered the script itself to correct version
- re-register if the key is deleted
1.1
- Registered the script itself
- Re-Register the script if $Scripts is cleared => Does not re-register if the key is deleted