Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualnesseggman

Posted 20 December 2012 - 07:10 PM

So, I am throwing together a prototype for my pet game, and I figured I'd try GameMaker:Studio to make it faster, but it seems like GML is very... limited and confusing.

Anyway, I only need to pass a couple hurdles and I should be able to create a functioning prototype that I can use to test the concepts of the game and get others' input and stuff.

So, the first thing I wanted to do was create some functions that will take care of various calculations and stuff. And I'm already stuck lol. Well, none of the documentation on GML seems to be very explicit on how things are done. I logged into the GameMaker Community and it won't let me make a new post and I searched there and here and couldn't figure out exactly how they worked.

It seems like you make a Script, but I don't know how to define the arguments for it. It seems like the arguments are defined by variables you call argument0, argument1, etc. throughout the Script you make. So I guess the arguments for your "function" are based on how many argumentX variables you write into the Script...

Then the example in the documentation looks like this:

//clamp_x(xmin, xmax)
//maintain x within the given bounds

if x > argument0 { x = argument0; }
else { if x < argument1 { x = argument1 } }

... It looks like the "notes" remind you of what arguments the function can take based on how many argumentX variables are in the code. But then the comments also state that it's supposed to keep x within the bounds... but I feel like argument0 should be what they're calling "xmin" and argument1 is what they're calling "xmax" ... but wouldn't they be the opposite, based on what the function apparently does...?

I'm assuming the documentation just uses a flawed example? That argument0 would be the ceiling and argument1 would be the floor of where you're trying to keep x inside.

So if I want to write a function, do I just put any number of argumentN variables in the Script, and then make comments at the top to remind me how many I had and what kind of parameters this function should be taking?

This seems needlessly complicated X_X; I wish the documentation actually explained how it works. It pretty much just says "Scripts can be used like functions." and then gives that example from above with no further explanation...

Also, since I can't really create an enum with GML or make states with one, let's say I wanted the user to be able to choose one of 20 pets or something, and then this choice will persist for the rest of the game, even between Rooms. I've created a global variable for this, but is it possible to use strings and check for the strings to use it kinda like an enum? Like, let's say they picked Pikachu (I'm not making a Pokémon game; it's just an example) then I could set global.petSpecies to "PIKACHU" and from there on out, on each room, I will need to display their pet. So I will create a function that will, through a tedious set of if statements, check all of the monster names, and then an if global.petSpecies == PIKACHU statement can tell the pet object that displays to change its sprite to the Pikachu set... does that seem like it will make sense? I honestly can't think of a better way to do it using GML :\

I'm using the free version of GameMaker:Studio so I can't create my own extensions using C++, nor can I use extensions others have made... I can only use the tools that GM:S comes with.

EDIT: And what all kinds of arguments can a Script function take? Like, could I pass a variable (rather than a value) or a pointer (are there even pointers in GML...?) to a variable? I'm assuming no, but who knows. The documentation does not explain how this works at all.

#1nesseggman

Posted 20 December 2012 - 06:22 PM

So, I am throwing together a prototype for my pet game, and I figured I'd try GameMaker:Studio to make it faster, but it seems like GML is very... limited and confusing.

Anyway, I only need to pass a couple hurdles and I should be able to create a functioning prototype that I can use to test the concepts of the game and get others' input and stuff.

So, the first thing I wanted to do was create some functions that will take care of various calculations and stuff. And I'm already stuck lol. Well, none of the documentation on GML seems to be very explicit on how things are done. I logged into the GameMaker Community and it won't let me make a new post and I searched there and here and couldn't figure out exactly how they worked.

It seems like you make a Script, but I don't know how to define the arguments for it. It seems like the arguments are defined by variables you call argument0, argument1, etc. throughout the Script you make. So I guess the arguments for your "function" are based on how many argumentX variables you write into the Script...

Then the example in the documentation looks like this:

//clamp_x(xmin, xmax)
//maintain x within the given bounds

if x > argument0 { x = argument0; }
else { if x < argument1 { x = argument1 } }

... It looks like the "notes" remind you of what arguments the function can take based on how many argumentX variables are in the code. But then the comments also state that it's supposed to keep x within the bounds... but I feel like argument0 should be what they're calling "xmin" and argument1 is what they're calling "xmax" ... but wouldn't they be the opposite, based on what the function apparently does...?

I'm assuming the documentation just uses a flawed example? That argument0 would be the ceiling and argument1 would be the floor of where you're trying to keep x inside.

So if I want to write a function, do I just put any number of argumentN variables in the Script, and then make comments at the top to remind me how many I had and what kind of parameters this function should be taking?

This seems needlessly complicated X_X; I wish the documentation actually explained how it works. It pretty much just says "Scripts can be used like functions." and then gives that example from above with no further explanation...

Also, since I can't really create an enum with GML or make states with one, let's say I wanted the user to be able to choose one of 20 pets or something, and then this choice will persist for the rest of the game, even between Rooms. I've created a global variable for this, but is it possible to use strings and check for the strings to use it kinda like an enum? Like, let's say they picked Pikachu (I'm not making a Pokémon game; it's just an example) then I could set global.petSpecies to "PIKACHU" and from there on out, on each room, I will need to display their pet. So I will create a function that will, through a tedious set of if statements, check all of the monster names, and then an if global.petSpecies == PIKACHU statement can tell the pet object that displays to change its sprite to the Pikachu set... does that seem like it will make sense? I honestly can't think of a better way to do it using GML :\

I'm using the free version of GameMaker:Studio so I can't create my own extensions using C++, nor can I use extensions others have made... I can only use the tools that GM:S comes with.

PARTNERS