I want to make a modable game

U

UniversalMonster

Guest
I don't know that much about game maker, but I've played around alot with 8.1 lite for a few years. Now I have Studio: Professional edition, and I'd like to figure out exactly what I can have be modable. I know there's background_add and sprite_add, but is that it for adding external stuff to a game?

Ideally I'd like the game to be kinda blank on start up, it having little to no "content" to it, only code. Then when the player loads a saved game or makes a new one, it will start importing content from selected mods. Once it's all done, the player can start playing the game.

So what are your thoughts on how I can pull this off?
 
M

MishMash

Guest
Modding in GM is rather tricky unfortunately. In an ideal world, being able to load GML scripts at run time would be fantastic, however, this can't easily be done. In gm8.1, we had execute_string and execute_file() to achieve this, so you could create a mod architecture with relative ease.

However now in studio, we don't quite have the same luxury. Resources themselves are quite trivial to add, however what we really would need is a robust way of executing a form of scripting language.

Unfortunately, if you wanted to hook in something like a Lua/python VM, this requires expert knowledge of how the GM engine works. What you would essentially need to do is bridge the gap between a C++ DLL executing a virtual machine, and something happening in GameMaker. There are only realistically a few ways this can be done, all of which are challenging:

1) Create a python/lua api that can sit on top of a python/lua Virtual machine and connect it to GM via networking. Performing the simulation of your game in python, and simply having GM being used as the rendering manager/input-output. This way you would be able to load in custom scripts from files.

2) Do the same thing but rather than using networking, write directly to buffers.

3) Come up with a clever way to manipulate YYC so that you can directly integrate a Virtual machine inside your compiled GM project, and have the script commands get mapped to internal C++ GM functions.

Now, I imagine all of this is going to be absolutely no help to you. If you are very experienced with GM, then you could achieve it, however realistically, this is quite a large amount of work.

The final thing you "could" do, which is a little more straight forward (though still awkward) is to implement a virtual machine directly in GML itself. The reason I wouldn't recommend this is that it'll be painfully slow if you want to try and achieve something remotely complex. Perhaps it would run "okay" in YYC, but the fact that you would have to write a parser + compiler + interpreter is just going to be an astronomical amount of work.

(I've made the assumption that you would want mods to be more than just a bit of config to define properties such as custom levels/custom sprites, as these aren't really what most people would classify as mods).
 
D

DyingSilence

Guest
You can make this project open source, but this will not allow mod selection.

I myself would do this by creating a system of file management, in which properties of modded in stuff would be held in ini's or some similar type of file, and have the game work according to tags.
Example:

TYPE: ENEMY;
NAME: Goblin;
SEES_IN_DARKNESS;
HAS_HANDS;
SIZE: S;
AI: SEEK_AND_CHASE;
SPEED: FAST;
CAN_USE_MAGICAL_DEVICES;
HAS_EYES;

That's a practice i've seen a lot in roguelikes.
 
U

UniversalMonster

Guest
@Tthecreator I dont think that would be much help since the last post is the thread OP saying that it's too slow to be used for modding. Thanks anyway.

@MishMash I didn't know they took out those functions. That does make things much harder.

To kind of clarify what I want to do, the game will be a simple 2D game with not much going on at a given time. The things that I want to be modded is images, scripts, and possibly music/sounds. I wouldn't know where to begin for importing sounds, I haven't researched it yet cause I haven't done anything with sounds at all.

I pretty much only know basic coding, so most of the terms you've mentioned are pretty new to me unfortunately. ;w; But I see there's an HTML5 export thing. I remember doing some HTML stuff in school where you could take files from the computer and put them on the browser, so that might make it easier.

@DyingSilence I think I get what you mean. By tags, you mean variables basically, right?
 

GMWolf

aka fel666
Define your resources externally.
If you have quests, NPCs etc, you can have some json or something defining those.
 

Tthecreator

Your Creator!
Let's start with a basic question: Do you think people would actually be up to modding your game?
Well, it's if not then there is still a lot to learn while implementing modding. You will learn about game maker's resources and stuff.
However it will require you to learn a lot. Game maker doesn't allow you to just *snaps finger* add script. This was the case in older game maker versions, but the modern ones are quite more efficient and adding script at runtime does not align with making things run as efficient as possible.

What you will have to end up doing, is making some type of external resource file.
This way you can't quite add custom types of code, but you could for example add an npc, and give it:
-a sprite
-a sound maybe
-a simple path
-something to say
But you can't certainly add heavy logic to it. All you could do is set some code-predetermined variables from a custom file format.
 
U

UniversalMonster

Guest
I'm gonna start trying to get how to do images first. I downloaded an extension that's suppose to help with that.

I don't know if people will want to mod my game, but I guess that's kinda up to how my game + modding features are gonna turn out. I imagine though that even if people don't want to make mods for it, I'd still add content to it later for myself.

Edit 1: Ok so I got sprite_add to work, but there's an annoying issue. working and program directories wont work in the project. I have to create an .exe of my game, and then put the mods folders in the folder that the game is in for it to work like it should. The working directory in the project just keeps creating temp folders, so I can never have the mods be in the current working directory. For the program directory, it treats the path that I have game maker studio itself in as the program directory instead of the path that the project is in. I've tried putting the mods folders in the path where studio is, but it still doesn't find them.

Whatever, I can keep creating .exe, it's just annoying. That's how technology is now-a-days, am I right?

Edit 2: Ok, so for the scripts, I have to somehow use strings to call scripts to do things. Right now the goal is to just make the game create an object with an external sprite, using only some commands in a text file. To get straight to the point, I think I'll be able to do this using state machines. With strings, you can control what the game does by controling what state it's in.

Originally I was thinking about what format the text files should be in, and thought maybe I could use the same as a json file from this one video I watched. It seemed to be mostly about assigning variables though, but I made a connection with some code I was doing earlier of a control object that read different text files whether it was in a "newgame" state or "loadgame" state.

So yeah, this idea is pretty cool! I'm pretty certain that I'm not the first one to think of it though.
 
Last edited by a moderator:
U

UniversalMonster

Guest
Sorry for the double post, but can I close all open files but using file_text_close(all)? I assume I can't, but it doesn't hurt to ask.
 

GMWolf

aka fel666
Sorry for the double post, but can I close all open files but using file_text_close(all)? I assume I can't, but it doesn't hurt to ask.
That will not work.
All is a keyword that refferences all object instances.

just keep track of what you have opened and close them one by one.
 
R

Rusty

Guest
I store information about my game's clothing, NPCs and quests externally, while tracking them internally. This means that the player can alter the appearance of any generated NPC but can't tamper with their relationship value or stats. It also means when NPC's pick new quests to hand out, they can hand out quests from an altered list, but when these quests are active they are stored internally, so the player can't "cheat" them. The player can also design their own clothing, or alter the descriptions and names of existing ones and while the values for these items are stored internally, any "new" items are given a default stat base.

This is all done with .ini files. I literally don't need anything other than .ini files to make all this possible. My game is literally customizable to a point of it being fair. My resources aren't compromised and my game isn't open sourced.
 

Jabbers

Member
I'm gonna start trying to get how to do images first. I downloaded an extension that's suppose to help with that.
What is the extension you downloaded? Does it help with sprite importing? You mentioned you are using sprite_add, which is able to import images locally and online using a URL, but please note that sprite_add is not an adequate solution for a mod system because of how texture pages work in GMS 1.x.x. See a discussion about it here where I talked about a common solution to this.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
1) Create a python/lua api that can sit on top of a python/lua Virtual machine and connect it to GM via networking. Performing the simulation of your game in python, and simply having GM being used as the rendering manager/input-output. This way you would be able to load in custom scripts from files.

2) Do the same thing but rather than using networking, write directly to buffers.

3) Come up with a clever way to manipulate YYC so that you can directly integrate a Virtual machine inside your compiled GM project, and have the script commands get mapped to internal C++ GM functions.
1 leaves little sense in using GM at all - you would only add overhead by streaming content.
2 is similarly problematic as you would have to figure out a workaround that would allow to suspend native extension' execution, return control to GML to call a script, and then resume native extension code.
3 is often mentioned as an option, but is yet to be accomplished by anyone - would require exploiting at least a few internal quirks to interleave the auto-generated code with custom one.
Writing an interpreter in GML itself would partially solve the problem, but will not grant the performance required for large-scale tasks, and would require an unreasonable amount of effort to develop and integrate.

Overall I'd suggest to make the base game first with a plenty of content - nobody wants to play/mod a game with no content, and seek collaborators when that succeeds.
 

Freddy Jones

Your Main Detective
I've never worked with the extension system in Game Maker outside of JavaScript, but I'm thinking this is actually a possible option for modding.

With my approach (assuming my assumptions are correct) you should be able to create mods that can:

  • Create custom objects (with custom code and implementable events) outside of GM
  • Have drawing done outside of GM
  • Have functions outside of GM
  • Manipulate and manage objects in GM with resources made in GM.
  • Utilize the GM library and variables from the outside code

Now all of this is some big talk for someone who has never experimented with this kind of technology, but I believe this is completely possible given the techniques that have been talked around the gmc for a while.
For now, I'll just state my idea for the windows platform as that's the easiest for me to conceive of.

How can we do any of this?
- An extension that handles it all. An extension that interacts with other extensions. A wrapper of sorts with a small middle-man interface so people can add their own code to yours.

My Imagined limitations:
A lot of things are going to be limited to what you define to begin with. It's not going to be 100% dynamically moddable, but with enough work it should be robust enough to actually MOD how your game works.

- People will not be able to directly edit your own objects (their functionality), they will simply be able to add on to your game. But, if modding is really important to you, I bet you could think something up along with my proposed ideas. IE: (have an object or controller that replaces said object with theirs and etc..etc.. possiblities)
- Regarding the point above, that does not mean that your objects can't use the added objects and such, you'll just make a system that intelligently works with added objects.

How would we have custom objects?
An empty object. It will be completely controlled by code outside of GML, probably someone's DLL. Class variables, methods, and ETC will be handled here. You'll pre-define what events you want this object to run and your object will call the DLL and make sure that the specific class it's running's code gets executed. Essentially, your GM object will be a reflection of an object in entirely differently language.

What about drawing?
This is where the stuff I am completely hesitant on comes in, but I feel comfortable enough to say that (I think) this has been done and is commonly done in certain extensions. Specifically, if there are extensions out there that can build on top of the 3D engine and render their 3D into game maker from a DLL it should be possible to do more drawing calls. If it gets more complicated than this you can probably go ahead and pass in draw-buffers / surface buffers to the reflecting instance and it can render it from there. There would be other workarounds as well as simply just having the DLL handle what sprite the class is currently implementing as well as having it call some Game Maker library draw calls in its reflected draw call.

Functions outside of GM?
Well, if the objects that are being added to your game are being written and manipulated by in a completely different language they'll be able to utilize all of the features of that language. No problem here.

Okay, this "sounds" nice, but what about actually working with Native GM objects
This sounds tricky, but a few patterns of "dynamic"(not really) patterns have been used to edit variables and manipulate the system. So there are possible ways to do this.
Say a person was working on an extension on an enemy and wanted to "drain" the health of the player.
They would call a function provided by your DLL which in action takes an instance ID (integer), variable name (string), and value (probably string for easier conversions later)
Using this information they could run a commonly used pattern such as:
Code:
with( passedId ){
    switch( passedVal ){
       case "hp": hp = real( passedValue ); break;
   }

}
Similar patterns could be used for having the external code access Game Maker's library and such ->>

You'll probably need to include functions that iterate over objects and find objects. In this scenario, providing asset_get_index() will be a must for anyone trying to have code interact with other instances.
You'll probably want to include a lot of helpful functions in there as well as like collision functions and such, and you'll probably need to add some helper functions of your own to help define and iterate through custom defined instances (which should have unique IDs to define their object names and such )

I see a loophole, how can you access and edit multiple variables and function calls to GM without knowing ahead of time?
This is a tough one. Probably the biggest thing that has stumped me while writing this, but I think there could be a few solutions.
My first idea is using local networking between the DLL and GM utilizing a combination of synchronous TCP reading and writing from the extensions and Game Maker handling the incoming asynchronously. This is the closest to ideal way of accomplishing an abstraction to the modders without having them do a lot of loopholes on their side for handling this situation.
Other than that I imagine the modders would have to implement some sort of asynchronous system with nesting or some sort waiting for you to process the requests (in a loop) on GML's end.
There could be more ways, these are the approaches I'd first attempt.


And all of that being said it may, in fact, be completely possible to have "Extra + Mixed", modded game if you will, content in your game. Sounds pretty complicated huh? I think after you've made something work for one platform like windows the rest would be on similar grounds and the mods could be system independent depending on the language you decided to wrap/how you wrapped it.

- I'd love to hear what others have to say who can confidently answer any of the questions brought up in my proposal.


Edit: I believe, compared to MishMash's proposals, mine is "similar" to his stream idea. Especially since a part of my solution involves blips of networking for asynchronous calls back to GML back-end.
 
Last edited:
U

UniversalMonster

Guest
ok so I got down how to read json files, so I could later try to save variables that way or something for scripts. Now I'm trying to figure out saving with external stuff. The way I have my json thing (all it is is an object that I told to be at 100 x, 100 y, and display text "The Game" at that position) works with the normal game_save(file), but the things I have using external images aren't loading the images after closing and reopening the game. It works when I restart the game using game_restart() though. It's probably in the way I code the external images I assume. I have "head" and "hair" objects that sets their respective image to different global variables, and then sets their sprite_index to the respective globals, all in the create event.

@Rusty : That sounds cool. I don't know if I'll go that direction though. I kinda want it where people can make their games/mods do almost whatever they want and kinda make up their own rules of how to have fun with the game. I do like the idea of not being able to edit important stuff so they can't just cheat quests and stuff. In the very least, I feel if they want a way to cheat quests, they're gonna have to make it themselves, like an in-game "screw this quest" button.

@Jabbers : This is the extension I was talking about: http://gmc.yoyogames.com/index.php?showtopic=669935 I haven't started using it yet, but I have it. It talks about texture pages in a similar way too.

@YellowAfterlife : I'm going to make my own content yeah, but in the form of a mod that comes with the game. A "Default" mod, so if people want to use mods with better content than mine, then they're welcome to.
 
Top