This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
The script is very simple and useful, if you want to let the player add some functions to the game(some AI games use player scripts for improvement) and/or run-time tests(you can see the file.txt while run the RGSS player and modify the scene to reload and see the changes). I don't know if anyone made it, well, this is totally mine, i think ten lines is good, but this can be smaller(something in my brain says that). Now the script!
The script is Here...
Code:
#====================================================================
# Script MauMau Version 1 30/11/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.new('File') #=> you must not to put .txt at the end
#====================================================================
class Script
def initialize(local)
@txt = IO.readlines(local << '.txt')
@total = ''
for linha in 0...@txt.size
@total += @txt[linha]
end
script = eval(@total)
end
end
For example:
1 - put this in a txt with any name in the same folder of your project
Example for test
Code:
class Pum
for x in 0..100
print x.to_s
end
end
2 - put this after of begin in Main script:
Script.new('filename') or Script.run('filename'), it depends the version you're using
where filename is the name of your txt, don't put blablabla.txt(don't put .txt)
3 - Run your game and click OK a hundred times for fun!
@_@: if you want to put scripts in a folder: Script.new('ScriptFolder/filename') or Script.run('ScriptFolder/filename'), look the version as i said
If you are going to use it just say, i trade for any script of this kind or pokémons(high level please)!
If you think this is horrible just say, but say how this could be better too!
If you already saw something like this, give the link, don't say "i saw this 412665 weeks ago, but i don't remember where... "!
Please reply and sorry for any grammar error of my part.
All Versions:
Script Version 1.00 ...
Code:
#====================================================================
# Script MauMau Version 1 30/11/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.new('File') #=> you must not put .txt at the end
# http://www.creationasylum.net/forum/index.php?showtopic=24235
#====================================================================
class Script
def initialize(local)
@txt = IO.readlines(local << '.txt')
@total = ''
for linha in 0...@txt.size
@total += @txt[linha]
end
script = eval(@total)
end
end
Script Version 1.01 ...
Code:
#====================================================================
# Script MauMau Version 1.01 1/12/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.new('File') #=> you must not put .txt at the end
# http://www.creationasylum.net/forum/index.php?showtopic=24235
#====================================================================
class Script
def initialize(local)
@total = ''
File.readlines(local << '.txt').each {|line| @total += line}
script = eval(@total)
end
end
Script Version 1.02 Thanks to Zeriab...
Code:
#====================================================================
# Script MauMau/Zeriab Version 1.02 1/12/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.run('File') #=> you must not put .txt at the end
# http://www.creationasylum.net/forum/index.php?showtopic=24235
#====================================================================
class Script
def self.run(filename)
script = IO.read(filename << '.txt')
eval(script)
end
end
I CAN DO IN LESS LINES (LESS IS BETTER(for code, not sex!))
Script Version 1.03 -- Less Lines...
Code:
#====================================================================
# Script MauMau/Zeriab Version 1.03 2/12/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.run('File') #=> you must not put .txt at the end
# http://www.creationasylum.net/forum/index.php?showtopic=24235
#====================================================================
class Script
def self.run(local); eval(IO.read(local << '.txt')); end
end
Script Version 1.03 ONE LINE SCRIPT
Code:
#====================================================================
# Script MauMau/Zeriab Version 1.03 2/12/2008
#--------------------------------------------------------------------
# Read scripts from external TXTs
# Use: Script.run('File') #=> you must not put .txt at the end
# http://www.creationasylum.net/forum/index.php?showtopic=24235
#====================================================================
class Script; def self.run(local); eval(IO.read(local << '.txt')); end ; end