GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#2 Re: GML Code Help » A question of style: arguments » 2011-12-30 17:35:38

I always edit the arguments in-place, and will do so until we can somehow define data TYPE's for the arguments, because right now there is no point, but if the function definitions were more like any other language then I would of course use the new argument declerations.

#3 Re: Script Submission » ds_list_sort_assoc » 2011-12-30 01:07:28

Ohhhh! I was unaware that you could still deal with strings which had a nul in them. Nice idea!

#4 Re: Script Submission » ds_list_sort_assoc » 2011-12-29 23:51:22

I'm suggesting it breaks when the sorting list has terms beginning with 0, such as "0fred", because it would remove the zero.

Also, gQuery has it's own explode function which I would be using. smile

#5 GML Reference » [BUG] Functions can't be referenced. More of a piss-off than a bug » 2011-12-29 21:49:03

Daniel
Replies: 1

This one is just a piss-off, not really a bug.

Make a script, call it "waffle", have it be "return argument0"
Now do this:

Expandt = waffle
x = script_execute( t, 10 )

x will now equal 10, obviously. However, you can't directly reference a built-in function and this simply bugs me. You have to write stupid wrapper for everything.

Hello? Callbacks anybody? It's ridiculous that this isn't done properly, I should be able to make a variable that refers to any functions!

On top of that, and this is just wishful thinking, but this would be nice:

Expandhash_interface = sqrt
hashed_n = hash_interface(n)

IE, getting rid of that whole script_execute stage that is so annoying.

#6 Re: Script Submission » ds_list_sort_assoc » 2011-12-29 21:44:12

I like that cheat, but it seems like it might start to fall apart if I want to sort by a list containing a string beginning with "0", wouldn't it? The sorting would be fine, but when re-formatting, that leading 0 would be stripped? If I'm going to stringify things, I can put everything into a map where the thing-to-be-sorted becomes the Keys, and their associated value become the Values, then simply read out the map back into the lists? It's linear (as far as GM is concerned).

Unless your way DOES retain leading 0's that are meant to be there. I just can't see it doing so.

#7 Re: GML Creations » CHALLENGE: Conway's Game of Life » 2011-12-29 20:03:34

If there's initial variations of the Game of Life that will simply spread like fire consuming every pixel in it's path, then "placing" one should start a fire spread... You just subtract that from the surface of the blimp procedurally, no?

#8 Re: GML Code Help » The gQuery foreach loop needs to be nestable » 2011-12-29 20:00:56

Of course, the reason it doesn't work right now is because the foreach loop stores both values into the "key" and "value" variables which means you can't access the outer-loops key/value's

#9 GML Code Help » The gQuery foreach loop needs to be nestable » 2011-12-29 19:45:58

Daniel
Replies: 1

Right, here's the deal.

My gQuery Lib has a foreach loop. I'm trying to have it nestable.

Which one of these seems to be most intuitive or usable/clean?

Expandfor( each( list, 'i' ) as item() )
  for( each( list2, 'j' ) as item() )
    draw_text( 5, 5, i*j )
Expandfor( each( list ) as key_value() )
  for( each( list2 ) as[1] key_value() ) 
    draw_text( 5, 5, value * value[1] )
Expandfor( each( list ) as item() )
  for( each( list2 ) as item() )
    draw_text( 5, 5, value[1] * value )

I'm actually leaning towards number 1, interesting. Its the slowest but simplest as it allows you to define your own iterator name. For the record, the current implementation of the nested foreach uses number 2, which I only prefer because it is backwards compatible with the old style foreach loop.

#10 Re: GML Code Help » GML Syntax Tricks, Quirks and Oddities Needed » 2011-12-29 15:32:39

Yes it's standard GML taking advantage of some little GM quirks. I need MORE quirks to take advantage of! smile

I looked through those forums, and I'm still scouring for some quirks.

Thanks btw. smile

#11 Re: Off Topic » future unimprovement of gamemaker » 2011-12-29 15:04:46

Most games run in 30fps anyway, and I don't know what lag you're talking about, you'd be doing those operations in your STEP event otherwise? It's not EXTRA lag. I know in GM if you turn off the "draw background color" thing, the stuff on-screen will remain on-screen, so every second frame you would re-draw the screen, so there's no extra texture memory either. The only downside is that you are stuck at 30fps refresh rate, which is perfectly fine.

I say 30fps, you could even go 2:1 for 40hz drawing rate, or 3:1 for 45hz drawing rate... Or 5:1 for 50hz... Only updating your Surfaces every third, fourth, fifth, sixth frames.

#12 Script Submission » ds_list_sort_assoc » 2011-12-28 20:37:42

Daniel
Replies: 15

I was trying to think of a way to sort a list in-place and to sort a SECOND list in the same way, such that if each item in list 1 was "mapped" to an item in link 2, it would remain at the same index after. Something like this:

Original Lists:
Daniel 200
Xot 100
icuurd 150

Would be sorted to:
Xot 100
icuurd 150
Daniel 200

I needed to keep it efficient and in-place, so I came up with this (it relies on gQuery, but the function names are pretty obvious, and we all know what a foreach does)

I want to know if there's any way to make this more efficient. What I did is copy the list being sorted into a new list, sort that original list in-place, then swap each index for its real position in the second list by looking up the old position using the copy list and its new position in the sorted list.

Expandvar gQ_keys;
gQ_keys=ds_list_create()
ds_list_copy(gQ_keys,argument0)
if argument_count>2
    ds_list_sort(argument0,argument[2])
else ds_list_sort(argument0,true)
show_debug_message('gQ: Assoc Sorting '+string(argument0)+' linked to '+string(argument1))
for(each(argument0) as key_value()) {
    gQ_temp = ds_list_find_index(gQ_keys,value);
    if key!=gQ_temp {
        ds_list_swap(argument1,key,gQ_temp)
        ds_list_swap(gQ_keys,key,gQ_temp) } }
ds_list_destroy(gQ_keys)

#13 GML Code Help » GML Syntax Tricks, Quirks and Oddities Needed » 2011-12-28 20:26:24

Daniel
Replies: 2

I'm in the process of writing a library of scripts that utilize any and all GM syntax quirks.

For example, one quick I found was that you could leave semi-colons out of the for loop, which let me to create a very-close-to foreach loop in GML. It ended up looking like this:

for(each(list) as key_value())

It works for files, too

for(each("hi.txt") as key_value())

Now I need to know ANY quirks with the language, even if you think they're useless. For example, being able to set/get any variable name with variable_local_set/get, even symbols... Or being able to use _ as a variable/resource name..

FYI, this is for gQuery.

#14 Re: Off Topic » future unimprovement of gamemaker » 2011-12-28 20:21:59

Double the framerate, draw the surfaces/room in every odd frame, draw TO the surfaces in every even frame.

#16 Community » Welcome Back! » 2011-05-19 14:02:32

Daniel
Replies: 1

Forums are back up. Good news for all. smile

Did anyone do anything cool in the past.. Week? I know I didn't, so distracted!

#17 GML Code Help » [Discussion] Preventing Memory Editors » 2011-05-13 00:41:04

Daniel
Replies: 0

Here's an idea. Let's try and stop people from finding a variable's place in memory through scanning, or slow them down at least.

Memory Scanning works by scanning ALL values a program is using, then making a change occur to that variable, and refining the search to the new value. You can refine by "value became", "value got bigger", "value got smaller", or "value stayed the same". So I might run the program, scan for my ammo count, hit "unchanged" a few times to remove lots of garbage memory, shoot a bullet, hit "value shrunk", pick up some ammo, hit "value rose", and do other silly things like that until I am left with only 1 place in memory. I can then edit that value to be whatever I want. The point of this topic is to make that value hard to find.

We'll have two separate discussions. One is for hyper-secure variables, which can use quite inefficient methods of protection, and one for almost every variable in a game, which obviously would need to be very fast.

I propose, given a bullets variable, the middle digits (the 10's) is a random garbage number and is changed every step. This means the value maintains a constant randomness, and thus, is "untraceable". Example,

bullets = 148 // Sets bullets to 18 (not a typo, really 18)

Then in the step event..

bullets = ( bullets div 100 ) + (bullets mod 10) + irandom(9)*10

Thus changing the middle value every step while retaining the two outer numbers.

#18 GML Code Help » [Discussion] Pokemon Engine, or Handling Lots of Data » 2011-05-13 00:04:19

Daniel
Replies: 0

I've been having idea's for a Pokemon engine, thus decided to start a discussion about what the absolute simplest and most elegant way to store all that data would be. Feel free to also talk about general database management, ie, how do handle a large project when hard-coding all of it simply isn't possible.

The requirements are:
1) Could be converted to Online play easily.
2) Is space efficient (no data stored in more than 2 places when it doesn't need to be).
3) Is cpu efficient, requiring few file lookups and has few loops.

The conclusion I've come to is to treat it like a large SQL database with several tables. I believe this would be the most precise and efficient way to store all the information in the game. A lot of the databases reference another one, for example, Main references the Owned table, which references the Pokemon table. Any time you catch a new Pokemon it's Pokemon ID would be added to the Owned database along with it's level and moveset, and given a unique OwnID. The "current party" is simply 6 of these ID's referencing pokemon in your Owned database. (The rest would appear in your Computer, in-game, should you wish to switch them out.)

Main ( Name, Own0, Own1, Own2, Own3, Own4, Own5 )
Owned ( OwnID, Pokemon ID, Level, Hp, Move0, Move1, Move2, Move3, PP0, PP1, PP2, PP3, PPMax0, PPMax1, PPMax2, PPMax3 )
Pokemon ( Pokemon ID, Name, Sprite, Evolvesto, Type )
Trainer ( Name, Reward, Sprite, TrainerPokemon0, TrainerPokemon1, TrainerPokemon2, TrainerPokemon3, TrainerPokemon4, TrainerPokemon5 )
TrainerPokemon ( Pokemon ID, Level, Hp, Move0, Move1, Move2, Move3 )
WildPokemon ( WPID, Pokemon ID, Level, Hp, Move0, Move1, Move2, Move3 )
Moves ( MoveID, Type, Power, Accuracy, PP, Callback )
CanLearn ( Pokemon ID, MoveID, Level )
DoesLearn ( Pokemon ID, MoveID, Level )

The Moves table has a Callback entry in case the move has a non-simple effect, such as lowering the Attack or something.

I imagine these would be easy to "extend" with more information, for example, giving Moves an optional secondary type. I also believe that they could work with a Server very well, in terms of transferring your Party data to the other clients. All you'd be sending is Pokemon ID and Level of the one you have selected, and the client would be able to use that information to figure out everything else it needs about that one Pokemon.

#19 GML Creations » Today I hijacked the zbuffer. » 2011-05-12 21:03:29

Daniel
Replies: 12

The infamous zbuffer gets hijacked every now and then, and today, I hijacked it to render voronoi regions in practically no time.

Download an example here, in .gm81, or just read (I prefer you read) the following.

I needed to generate a voronoi region, which means, for every point on the screen, set it's color to the color of the nearest "region" point. Voronoi regions are very helpful in many ways. For example, generate it, and you can determine the nearest instance simply by finding out which voronoi region you are in. This would make "nearest instance" calls VERY fast, then simply remove the region you checked, re-scan voronoi regions, and you've found the second closest point. Another very useful way to use it is for random map generators, if you need to have "countries" or something similar, it will generate countries of all shapes and sizes.

Anywho, they look like this:

voronoi.png

The way I generated that was simply by drawing cones into the screen with perspective turned off. This means for every pixel, the zbuffer determined the closest vertex, which happened to be the vertex of the cone of each region. So in other words, give every cone a different color, and the zbuffer will figure out which pixel is closest to which point.

The base of the cone needs to be very big, and the "depth" of the cone needs to be fairly high. As you can imagine, a low depth makes the cone have very unsteep edges, so zbuffer fighting occurs, but when the edges are very steep, the zbuffer has no problem figuring out which face to draw.

#20 Community » Forum Slowness. » 2011-05-12 12:45:32

Daniel
Replies: 1

I think this forum is slow because there is no reason to post. I'm here very often but never find a reason to post, as any idea I get either doesn't belong, or gets obliterated by the rules. This forum is great in that it only attracts mostly experienced GM users. However, this kind of user Rarely finishes a game, and rarely needs help. Coupled with the fact that bugs show up fairly infrequently and are resolved quickly, and you have no real reason to be active here. You need more topics where we can be active. My suggestions include:

GML Creations becomes GML Projects to also include WIP projects, and is moved up a few notches.
Discussion topic is added, allow you to post anything GM related and have it be discussed, not answered. Example, "best method for native d3d particles".
Topic names are simplified slightly (it's cleaner). News, Community, Creations, Help, Discussions, Submissions, Off Topic.

This way, I can always come to the "Discussions" tab and see what's being discussed and provide input, as a discussion never has a resolution. There is always more to input to a topic, unlike Help, which gets solved. Then, in help, I can post my questions for which I want an actual solution. I put the solution into my game and post it to Creations. Then I go to other Creation topics and check them out, even though they're not complete, or are very early WIP's.

Creations would, of course, include Scripts you are working on, Games you are making, and anything else related to GML, such as a GM website or host. Any good scripts in this subforum are simply plucked out and sent to GML Scripts, as well as the Alumni Forum, of course. This makes the process easier for you, and allows people to spread ideas for a GML snippet, give their go at it, and still have it refined by others.

Thoughts on these changes?

Board footer

Powered by FluxBB