*Please note that this script requires registration and has only been tested on gm6.1
Have you ever wanted to load objects externally, to make your game load faster or to make an easy plugin system? This is the answer. A simple script, and how to make the files necessary.First off, the script (name it object_load)://Loads an External Object
//Returns a handle for the new object
//Made by Flashback. Give credit if y'want.
//argument0: location of the object file (in a string)
var object,n,event,sprite,nn,retval;
var eventcode,eventlines,eventnum;
n=0
nn=0
object = file_text_open_read(argument0)
while(file_text_eof(object)==0) {
event[n] = file_text_read_string(object)
file_text_readln(object)
eventnum[n] = file_text_read_string(object)
file_text_readln(object)
eventlines = file_text_read_real(object)
file_text_readln(object)
eventcode[n] = ""
cont=1
while(cont==1) {
if(file_text_read_string(object)!="--endcode--")
{
eventcode[n] += file_text_read_string(object)
file_text_readln(object)
cont=1
}else{
cont=0
}
}
n+=1
}
file_text_close(object)
retval = object_add()
repeat(n) {
execstring = "event=" + event[nn]
execstring += " object_event_add("
execstring += string(retval)
execstring += ",event,"
execstring += eventnum[nn] + ",'"
execstring += eventcode[nn] + "')"
execute_string(execstring)
nn += 1
}
return retval;
object=object_load("object.obj")
Quote:
[event type][event number][number of lines of code][event code]
ev_create
0
2
show_message("Hello world")
alarm[2] = 60
ev_alarm
2
1
show_message("I'm still here")
ev_destroy
0
1
show_message("Goodbye world")
Heh, nice. If I ever wanted to do this though, I'd just code it on my own. This would be really handy for adding game mod abilities.
dude… it's like… sex with numbers and code…
Awesomeness. XD
Like melee said, it'd be for game mods and such.really, that looks pretty confusing right there. oh well. i'll be happy to tell you that i have recently been checking out everyones archives, and found this in yours. you need that for your banner!!!
<img src="http://www.64digits.com/users/flashback/matrix.png">I used to use that as a banner. In version 1. Now stop snooping there.
It appears noone has thought about speed.
This will be slower than a sloth in a glue factory when it's actually run, especially if you have lots of the same instance.And someone obviously never ran it.
Someone doesn't need to run it when when someone is speaking from experience. I've run a single execute_string function in one of my destructible terrain engines and it reduced the FPS by 10.