Jump to content


Photo

Many questions about loading Mods to my game


  • Please log in to reply
2 replies to this topic

#1 gamemakerlover

gamemakerlover

    GMC Member

  • New Member
  • 2 posts

Posted 05 September 2012 - 01:57 PM

Hi. So basicly I need assistance with finding out how to externally load mods from a folder, kinda like this:

W/ Image:
  1) Locate all image names in folder.
  2) Add all images in folder.
W/ Object creation code:
  1) Locate all text files in folder.
  2) Import and execute all files in folder.
  3) Change newobject_1 to the user specified name.

I am also Not sure how to set up the object code file, but I assume that this method would work:

MAIN_MyObject.txt (the code that is executed by the game) code:
global.MyObject=object_add()
global.MyObject.createeventfile='CREATE_MyObject.moc'
global.MyObject.keyboardAeventfile='KEYA_MyObject.txt'
And so on

CREATE_MyObject.moc (Create event, loaded by MAIN_MyObject.txt):
global.MyObject.MyVariable=12345
And so on

KEYA_MyObject.txt (Keybaord 'A' event, loaded by MAIN_MyObject.txt):
global.MyObject.x-=3
And so on

So any ideas welcome, please help!
  • 0

#2 tomsaram

tomsaram

    GMC Member

  • GMC Member
  • 65 posts
  • Version:GM8

Posted 07 September 2012 - 10:05 AM

As for the objects, GML has functions like
object_event_add(ind,evtype,evnumb,codestr)
Note that codestr is a string that you read from external files.
  • 0

#3 FatalSleep

FatalSleep

    Dominus Veroth

  • GMC Member
  • 1216 posts
  • Version:GM:Studio

Posted 14 September 2012 - 05:27 PM

I just might be able to help with something like this... I won't do everything for you. However I'll give you a way of finding al files in a folder then loading them into the game.

Find all files script:
Spoiler



So to execute this script you would use for example:
finished = script_name( working_directory , ".moc" );

What this script will then return is whether or not the script is finished.
AND it will allow you to access the files via variable:
global.file_found[ position ] //position being 0 - global.file_max;

// and the max amount of files in the array with:

global.file_max;

Now to load the code in the mod files....
you are going to use something similar to this.

File execute script:
Spoiler

What this script will then return is whether or not the script is finished.
So to execute this script you would use for example:
finished = script_name( delay amount );
//delay amount being the time between each execution of code...

I hope this helps! (I am confident that this works, however I did not personally test it, I just typed it Posted Image)

Edited by FatalSleep, 14 September 2012 - 08:55 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users