execute_file() and GM:S

Posted by link2x101 on June 1, 2014, 5:21 p.m.

That is, why it doesn't exist, shouldn't exist, and how it can exist.

I've spent today thinking about how Studio is lacking the execute_file() and execute_string() commands.

And there's a fair number of reasons why this is so.

    [#]Piracy concerns. It's extremely easy to create your own GML runner. Sure, it makes Game Maker a significantly harder language to use, but it's still possible. This runner can then bypass all of the free-version limitations (provided someone with a paid copy compiled the executable.) The only real features lost are things like the loading bar, icon, and game-info. [#]Safety concerns. Look, I shouldn't have to tell you that letting your code run someone else's code without any safeguard can be a problem. Keyloggers, viruses, various kinds of bots, and any other malicious software can be transmitted this way. (Not to mention older versions of Game Maker weren't so safe with the filesystem access thing. Hello, system32.) [#]Rare usage. The most common usage case for these commands that I've ever seen is level editors and readers, which can easily be done in .INI format (depending on the game, though this lacks security) or a custom format (which is really not hard to do). Games using this style of saving/loading for maps are particularly at risk of the above safety concerns. I could easily write in some code among the instance_create()s to execute a .DLL saved along with the 'map', or even have the .DLL itself embedded into the map file, creating the actual .DLL file before executing it.

Now, these commands could easily be used to allow modding to a game. That is, you could let people hook in to core gameplay components and change how it's played, or change the music, or add multiplayer. All sorts of things, but I can't say I've ever seen anyone do such a thing with a Game Maker game. (And now it's a bit late for using this method).

However, you can still add such a feature to your game if you wanted. It's just a bit harder.

Now, instead of having free reign over a Game Maker game from an outside script, you have to specifically write in (effectively whitelisting) a parser.

Using file reading functions and more-strict Game Maker code (raise your hand if you don't always use semicolons) it can then be made possible to execute outside code.

That's right, you can still use an instance_create() level system, you just have to work a bit harder on making them load.

It's a pain, but this is a far safer way to go about things, as you probably won't be whitelisting dangerous commands, nor opening a hole for .DLL hooks or keyloggers.
TL;DR: execute_string() and execute_file() are gone because they are lazy and dangerous. You can still execute strings and files if you take the time to do it properly.

Comments

Pirate-rob 10 years, 5 months ago

Yes there is, if you make it. (Possible)

Also, it is possible to have user made levels with out execute file. Very easy really.

Cheats are harder but still possible as link pointed out.

Also, Kilin, I can't believe you didn't know about pass ds's XD

Castypher 10 years, 5 months ago

I don't use GM's data structures because I haven't really needed them. Plus they tend to be a little counterproductive (in efficiency) especially when compared to their programming language counterparts. I remember a long time ago, I tried to pass arrays through a function but ever since then, I've come up with alternatives. I'm just impressed to see all the measures they're taking to make GML work more like mainstream programming languages.

If GM's arrays weren't arbitrarily typed, then I'd look at data structures, because my usual method of dealing with that (a linked list of objects with separate member variables) isn't really practical in GM.

Quote:
but does anyone know of a .dll for execute_string?
You'll be way better off if you practice good programming habits. As a suggestion, you can have a single controller object that does all your checks based on what room you're currently in. You're using an extra object, sure, but it's not wasted if it's used frequently.

Powerful Kyurem 10 years, 5 months ago

I mean is there one already made somewhere.

Quote:
Also, it is possible to have user made levels with out execute file. Very easy really.

I do not use execute_file. I use execute_string, and I already how to make custom levels without it. It's just annoying.

Also Kilin, that's beside the point. There are other games I know of that do the exact same thing. Heck, you can go hang Supmaster004. Every single one of his cutscenes is fueled by an execute_string object. It doesn't seem fair to penalize people and prevent them from putting their games on windows 8, when the only reason (according to this: http://help.yoyogames.com/entries/21920991-Loading-scripts-and-execute-string-execute-file-) is that it is too difficult to design it for other systems. Now, what makes no sense is that they can't just make that function only available for the windows version.

I should also point out that you lose the mechanic of having code change over time, which I was considering to use for a game, at one point.

link2x101 10 years, 5 months ago

Quote:
Now, what makes no sense is that they can't just make that function only available for the windows version.

But one can easily just use GM8.1. I'm on Windows 8.1 and it isn't throwing any issues in any of my projects beyond one .DLL issue in one project that was a problem under Windows 7 anyway.

Pirate-rob 10 years, 5 months ago

What if one of the other systems is windows 8? Edit: nvm, link ninjed ahead of me

Also I like speed tyvm, having that would make gamemaker so much slower. Plus it's not penalising, you don't need executestring to do anything.

Castypher 10 years, 5 months ago

Quote:
Also Kilin, that's beside the point.
It's really not. And I don't think your reverence for supmaster is well placed either. There are people here who have made far more impressive games and most of them would probably agree that execute_string is a cheap and lazy way to handle things. You'd be doing yourself a favor by learning the alternatives.

Additionally, there is nothing preventing you from putting your games on Windows 8. Did you ignore my comment above that the only thing that breaks on Windows 8 is an audio issue that you can easily fix with one extra line of code?

Seriously, go make a new script. Call it play_sound. Give it a single argument that takes a sound file, calls sound_stop(argument0) then sound_play(argument0), and replace your sound_play everywhere else with this new script.

Or just stop playing so many sound instances at once.

Powerful Kyurem 10 years, 5 months ago

Quote:
But one can easily just use GM8.1. I'm on Windows 8.1 and it isn't throwing any issues in any of my projects beyond one .DLL issue in one project that was a problem under Windows 7 anyway.

But Supmaster told me his games wouldn't port to studio for some reason… hold on.

*goes and checks old PMs*

ummm… I made a mistake guys. It's 8.0 vs 8.1 that fails. Um, I'm going to go away and hide now.

btw, it wasn't reverence at Supmaster. That was kinda the point. He's a bad game dev. Did you know he refuses to use "{", "}" , and ";"?

Edit: Kilin, I missed that. Where was that?

Edit2: Nevermind, I'll make sure to pass that along to everyone else.

Pirate-rob 10 years, 5 months ago

there's nothing wrong with not using ";" ,unless you need it, is there? '^^'

Powerful Kyurem 10 years, 5 months ago

Actually, GM once flagged code outside a function as an argument. So, it is useful.

Pirate-rob 10 years, 5 months ago

Brackets should stop that though. If they didn't, you could hardly blame the programmer.