External object exporter/loader

Filed under: Game Maker

extensions screenshot

This is one of my coolest pieces of GM goodness ever. I refused to post it anywhere for nearly a year but now that I’m moving from GM I thought it would be nicer to share. Unfortunately it doesn’t come with a readme. I might write one if I get time but I’ll briefly explain it here.

This is a two piece system that allows to to take ANY object from ANY gm6 game, and load it at runtime into any game that uses the loader system. It’s the result of a several week collaboration between IsmAvatar and me. If you use this, credit is required for us both. The first step is the Object Exporter. It’s a nifty little piece of java code you’ll find in the zip. When you run it, point it at any GM6 game and I’ll bring up a list of objects in that game. You can then select any of those objects and it will export all their code. Note, it does not export and drag and drop actions other than the ‘execute code’ and ‘excecute script’ one. When we designed it, we agreed that anyone using it should only be using scripts. The really cool thing is it’ll automatically pay attention to what scripts your object relies on and export them as well. The result is a GOD file containing all the code required to manifest this object.
The second stage is the loader. It will take the object, and do a crapload of work behind the scenes to bring you one delicious function g_parse(). It loads a .god file and returns the object index which you can then instance as if the object has always been in the game! instance_create(0,0,g_parase(“rah.god”)) it’s as simple as that. Now a lot of the magic it does behind the scenes is about making it run fast. It acts as a primitive compiler and modifies the code going into it so it runs almost as fast as native code. It also does a couple of other things with parsing like allow you to ban certain functions which you’d consider unsafe. Or perhaps redirect one function into another. This is in the demo. Any calls to show_message() get redirected to winlog_post so any .god object attempting to show a message, shows it the way I tell it. Something very useful for serious extension mechanisms.

It does have several bugs, but overall it works. It’s not quite capable of taking an entire complex gm6 game and loading it straight, but for extension and modding purposes, it’s a gold mine.
If you use this or any part of this, be sure to credit both IsmAvatar and me. Also, we’re now living in a sort of GM7 world but on the G-Java foums is a utility capable of loading a gm7 game and saving it as a (corrupted) gm6. To fix the corruption, open game maker 6 with a blank game and merge it with the file this utility spat out. The result is a flawless conversion.

Extobj

Related posts

Tags: ,

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Permalink Comments (1) GearGOD Oct 2, 2007

One Response to “External object exporter/loader”

  1. bullbull Says:

    I have a system with similar syntax. But I’ll drop it and use yours instead for 1 reason: Yours has an exporter. My system requires users to code an object by notepad :) ). Nice work as usual.


Leave a Reply