September 05, 2025, 04:41:01 am

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: 1 ... 10 11 [12] 13 14 15

Author Topic: ITT we make fun of stupid stuff in GML  (Read 42315 times)

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3415
  • she's never quite as dead as you think
Re: ITT we make fun of stupid stuff in GML
« Reply #165 on: February 21, 2016, 08:11:07 am »

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

MedO

  • Owns this place
  • *****
  • Karma: 152
  • Offline Offline
  • Posts: 1756
Re: ITT we make fun of stupid stuff in GML
« Reply #166 on: January 06, 2017, 06:43:38 pm »

What I just found out cost me several hours and some of my sanity:

As you probably know, you can draw sprites in GM with both scaling and rotation. Generally, you would expect that if you only scale and rotate, there is one point of the sprite which never moves in screen coordinate space (the origin of the sprite). However, Game Maker decided that it would be a good idea to have different origins for rotation and scaling which are *almost* the same. Rotation is around the pixel center of the screen space draw position, while scaling is around the upper left corner the sprite's origin pixel (in sprite coordinate space). If you only scale by 1 or -1, the two points are only half a pixel apart, which makes it difficult to notice anything is wrong until some test cases are off by one pixel and you just can't figure out why...

I worked a bit on an improved system in the last days which allows you to connect sprites to defined "rigging points", so you can basically make a new hat by (mostly) defining which pixel of the hat sprite should always track the rigging point on the head of each character. Because of the "design flaw" mentioned above, doing the calculations to have the pixel positions always match up was downright agonizing. What's also painful is that it would have been really easy if GM had an actual general 2D drawing function that takes a transformation matrix instead of just rotations and scale, like any self-respecting graphics API should.
« Last Edit: January 06, 2017, 06:46:22 pm by MedO »
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

billymaze

  • Veteran Member
  • ******
  • Karma: 10
  • Offline Offline
  • Posts: 6732
Re: ITT we make fun of stupid stuff in GML
« Reply #167 on: January 07, 2017, 01:06:34 am »

I love it when Gamemaker throws syntax errors at you when you use the auto-complete drop down suggestions... retyping it out fixes the false error...
visual studio does this with c++ too
Logged

MedO

  • Owns this place
  • *****
  • Karma: 152
  • Offline Offline
  • Posts: 1756
Re: ITT we make fun of stupid stuff in GML
« Reply #168 on: January 07, 2017, 05:08:25 pm »

So since I'm already resurrecting this thread:

I want to get a sprite by name so that I can work with images that follow a consistent naming pattern (e.g. ScoutRedTauntS). However, there is no function for this, all the sprite functions work with sprite IDs. Of course, we can get around this because we basically have eval:

Code: [Select]
return execute_string("return " + spriteName + ";");
The problem here is that this causes an error if no sprite of that name exists, and of course we also don't have a way of finding that out beforehand (again, no functions for working with sprite names). However, where there is a will, there is a way:

Code: [Select]
return execute_string("variable_local_set('"+spriteName+"',-1); return " + spriteName + ";");
If the sprite exists, it will actually shadow the local variable so you get the sprite ID. Otherwise you get the contents of the local variable which is -1.
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

Mr.kown

  • Full Member
  • ***
  • Karma: 5
  • Offline Offline
  • Posts: 231
  • /trash/
Re: ITT we make fun of stupid stuff in GML
« Reply #169 on: January 23, 2017, 09:12:10 pm »

but how wold you do it  :z2: :z2: :z2: :z2: :z2:
Logged

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #170 on: February 14, 2017, 09:18:36 pm »

So since I'm already resurrecting this thread:

I want to get a sprite by name so that I can work with images that follow a consistent naming pattern (e.g. ScoutRedTauntS). However, there is no function for this, all the sprite functions work with sprite IDs. Of course, we can get around this because we basically have eval:

Code: [Select]
return execute_string("return " + spriteName + ";");
The problem here is that this causes an error if no sprite of that name exists, and of course we also don't have a way of finding that out beforehand (again, no functions for working with sprite names). However, where there is a will, there is a way:

Code: [Select]
return execute_string("variable_local_set('"+spriteName+"',-1); return " + spriteName + ";");
If the sprite exists, it will actually shadow the local variable so you get the sprite ID. Otherwise you get the contents of the local variable which is -1.
Couldn't you just write a script that checks to see if the sprite exists via sprite_exists and return a dummy sprite if it doesn't exist to the same effect? That's useful for GM8.x, but not so much for GMStudio (Not sure about GMS2 since they added the local_variable functions again, but yeah).

GM:S also has the wonderful asset_get_index(); function. Something silly like
sprite_index = asset_get_index(string(class)+string(team)+"TauntS")
is possible. We really should just drop GM8 and move on to Studio.
« Last Edit: February 15, 2017, 11:45:34 pm by Saniblues »
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

MedO

  • Owns this place
  • *****
  • Karma: 152
  • Offline Offline
  • Posts: 1756
Re: ITT we make fun of stupid stuff in GML
« Reply #171 on: February 17, 2017, 05:43:04 am »

asset_get_index sounds like it would solve the problem, but sprite_exists takes an index, not a name.

As far as moving to a newer version of GM is concerned, I don't really feel like it'll help much at this point and I'd rather spend the little time I invest into GG these days on actual game or code improvements than on porting.

Besides, it's kind of fun to figure out strange ways of accomplishing things that were not intended ;)
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #172 on: February 17, 2017, 03:45:13 pm »

You got me there. Roundabout methods are the most interesting.
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

ZaSpai

  • Ray Bann's Minion
  • *
  • Karma: 14
  • Offline Offline
  • Posts: 2169
  • "Eeh?! We're just allies!"
Re: ITT we make fun of stupid stuff in GML
« Reply #173 on: February 19, 2017, 01:45:22 am »

As far as moving to a newer version of GM is concerned, I don't really feel like it'll help much at this point and I'd rather spend the little time I invest into GG these days on actual game or code improvements than on porting.

FWIW, even though I haven't looked into GM:S 2.0, am I still correct in assuming plugins ain't gonna work if GG2 were rebuilt in GM:S because external code cannot be executed?
Logged
Right behind you when you most expect it | classicwell master race

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #174 on: February 22, 2017, 02:26:50 am »

As far as moving to a newer version of GM is concerned, I don't really feel like it'll help much at this point and I'd rather spend the little time I invest into GG these days on actual game or code improvements than on porting.

FWIW, even though I haven't looked into GM:S 2.0, am I still correct in assuming plugins ain't gonna work if GG2 were rebuilt in GM:S because external code cannot be executed?
This is only partially false. The reason that we were able to execute plugins the way that we do is because Game Maker pre-Studio did not compile the code. Therefore, we were able to load plain GML to the system.

http://yal.cc/on-gamemaker-studio-game-decompilation/

The method that we used for Gang Garrison 2 is no longer possible, but GMS2 adds many of the functions that would be needed to set up a modding frontend, and the functionality possibly still exists in the test versions of GMS1. YellowAfterlife, using the latter, did just this with this mod for Nuclear Throne

https://yellowafterlife.itch.io/nuclear-throne-together/

It wouldn't be a simple undertaking, and it frankly wouldn't be worth the effort in my opinion, but it's certainly not impossible.
« Last Edit: February 22, 2017, 02:27:14 am by Saniblues »
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #175 on: February 22, 2017, 11:07:47 am »

On that note, it might also be possible with Studio as it is? I would need to ask yal if it's possible with the stable version of studio. Some of the nicer features of his modding API would be absent if it is, but hey
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #176 on: February 22, 2017, 11:46:02 am »

Quote
I assume it'll work in the next (gms) update - there's a whole bunch of memory-related bugs that I've reported while doing this and that are only fixed in closed beta as of now
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

MedO

  • Owns this place
  • *****
  • Karma: 152
  • Offline Offline
  • Posts: 1756
Re: ITT we make fun of stupid stuff in GML
« Reply #177 on: March 27, 2017, 04:56:48 pm »

Just found a perfect bug. It is so brilliant that it almost feels like a designed logic puzzle. Because of that, I'll first post what happened and then the solution in a spoiler.

Here is the code:
Code: [Select]
// dealDamage( sourcePlayer, damagedObject, damageDealt )
with(argument1)
{
    if(variable_local_exists("deathmatch_invulnerable"))
    {
        if(argument1.deathmatch_invulnerable != 0)
            return 0;
    }
}

argument1.hp -= argument2;

execute_string( global.dealDamageFunction, argument0, argument1, argument2 );

And here is the error, which occurs when someone is being hit directly with a rocket:
Code: [Select]
ERROR in
action number 1
of Other Event: User Defined 5
for object Rocket:

In script damageAuto:
In script damageCharacter:
In script dealDamage:
Error in code at line 6:
           if(argument1.deathmatch_invulnerable != 0)
                        ^
at position 23: Unknown variable deathmatch_invulnerable

How can this happen? We check whether the variable exists before using!
Here are some tips:
- variable_local_exists is the right function for the job (i.e. it checks if the variable exists in the "current" instance)
- There is no subtle typo involved
- argument1 has the same value inside and outside the with()-block
- This is no "weird instance state" thing where an instance is really already destroyed or something
- The with-block runs for one instance, and it's the correct one (the character which was hit by the rocket)

Maybe you'll figure it out quickly, but otherwise just check here:
(click to show/hide)
« Last Edit: March 27, 2017, 04:57:21 pm by MedO »
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

ajf

  • (Ex-?)Developer and forum/web admin
  • *****
  • Karma: 7
  • Offline Offline
  • Posts: 3415
  • she's never quite as dead as you think
Re: ITT we make fun of stupid stuff in GML
« Reply #178 on: August 10, 2017, 10:15:15 am »

Quote
16:13 - ΘSaniblues:
Code: [Select]
YellowAfterlife - Today at 10:12 AM
I brought it up a few times, GML uses multiple things interchangeably. For example,
it also supports pascal-style := assignment, but it's interpreted as regular assignment
token and thus you can do if (a := b) while that semantically makes no sense neither in
GML or Pascal
« Last Edit: August 10, 2017, 10:17:06 am by Saniblues »
Logged
did you know that spinning stars work like this???

I've seen things you people wouldn't believe. execute_strings on fire off the shoulder of Overmars. I watched object-beams glitter in the dark near the room_goto_fix. All those moments will be lost in time, like tears...in...rain. Time to die.

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1304
  • Offline Offline
  • Posts: 12205
Re: ITT we make fun of stupid stuff in GML
« Reply #179 on: August 10, 2017, 10:17:22 am »

For the record, that's still valid as of GMS2
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

Pages: 1 ... 10 11 [12] 13 14 15
 

Page created in 0.041 seconds with 35 queries.