Discuss and collaborate on GML scripts

You are not logged in.

#1 Re: Script Alumni » explode_string Studio Update » 2014-08-31 13:18:45

I actually use the first array element from my experience with arrays used to return varying amounts of data, it is quite a common practice. I considered the array_get_length option but decided against it for ease of use and to support instances when nothing is found in the string, (what to return is there is no entries found??)...

1-You always get an array even when 0 values are found so
2-you don't need to check the return with if(is_array());
3-so that to make sure array_get_length_1d() does not blow up in your face

var t = explode_string(",","1,2,3,4,5");
i =1;
repeat(t[0]) do_stuff(t[i++]);

var t = explode_string(",","1,2,3,4,5");
i =0;
ct = array_length_1d(t);
repeat(ct) do_stuff(t[i++]);

#2 Re: Script Submission » instance_nearest_advanced » 2014-08-24 09:49:19

I have not been around for a bit.... I think the problem is GM likely had some sort of aabb system where studio does not...

TMC SGS solves this issue with the grid system and Implemented a instance nearest for it as well

#3 Script Alumni » explode_string Studio Update » 2014-08-24 09:24:37

Replies: 3
Expand/// explode_string(sep,data)
**  Usage:
**      var arr = explode_string(sep,data);
**  Arguments:
**      sep         separator character, string
**      data        array data, string
**  Returns:
**      array where entry 0 array[0] is the number of items read and array[1....n] is the data as strings
**  Notes:
**      Converts a string of data with elements separated
**      by a delimiter into an array of strings.
**, modified by icuurd12b42
    var arr,sep,dat,len,ind,pos;
    arr[0] = 0;
    sep = argument0;
    dat = argument1 + sep;
    len = string_length(sep);
    ind = 1;
    repeat (string_count(sep,dat)) {
        pos = string_pos(sep,dat)-1;
        arr[ind] = string_copy(dat,1,pos);
        dat = string_delete(dat,1,pos+len);
        ind += 1;
        arr[0] +=1;
    return arr;

#4 Re: Script Submission » instance_nearest_advanced » 2013-12-17 06:35:32

Be warned, this is now super slow in GM:Studio; it is best to use the most commonly known method
with(object_to_search) if in range and closest found, remember it... or add to a priority queue indexed on distance to return multiple instances

the cause of the slowdown is instance_nearest() which performs it's own internal with(object_to_search), obviously no aabb type search is used, so the end result using this method is multiple with(object_to_search) calls. as many as the number of instances in range... so you are better off doing your own one single pass through using your own code in a  with(object_to_search). with regular output, this method is 10 times slower than a with(). with YYC it is about 100 times slower than a with().

lastes result with 1000 instance, 100 in reange
this method
Regular Windows Output 10fps
YYC Output 15fps
with() method
Regular Output 130 fps
yyc output 1000+ fps

#5 Re: Script Submission » Directed rockets (homing) » 2013-12-08 22:57:01

image_angle+=lengthdir_y(5, image_angle - point_direction(x,y,mouse_x,mouse_y));

#7 Re: Community » Introductions » 2013-11-12 06:28:44

Salut Nerval. I'm French too but not from France.

#9 Re: GML Code Help » How to make sprite outline script? » 2013-10-04 20:17:23

a cheap way, but not accurate is to cal d3d_set_fog(1,color,0,0) (fog on) then draw scaled up so it's larger, then call d3d_set_fog(0,color,0,0) (fog off) then draw_self over that.

works for sprites origins centered that dont have compex shshapes

#11 Re: Script Submission » ds_grid_set_grid_disk() » 2013-09-13 19:55:01

Good stuff. subtract and divide can be derived from those too.

#13 Re: Community » Robot AI Arena contest » 2013-07-31 13:29:51

Quickly some things before My mind crashes from lack of proper sleep. sorry if some of it sounds weird. tired

You need to provide the mech/robot or tank template with the basic feature (hard point attachement and firering) and only provide an entry point for the code, like a blank DoStep(). and have strict access like you imply to components that are attached through a specific API same for the targets available in the game. because if people are allowed to play in the core stuff, like even do a instance_nearest and you have rules that they cant see though walls or know where the target is in certain circumstances....

Same for the path system you need to have that handled by an api. so that the contestant cant simply do a mp_path towards a target without following the rules.

here is what I would have as components

1)line sensors. (aka collision_line first). the line sensor finds detect all objects in the arena, walls, pickups, other robots, bullets, missiles, rockets and waypoints nodes at a range of 400, can rotate up to 15 degrees a second

2)cannon, fires a bullet every 5 seconds at a range of 200, 100 bullets, 10pt damage

3)missile, fires a missile every 10 seconds at a range of 400, 3 missiles, 25 pt damage, 10 health

4)rocket fires a 3 rockets every 5 second at a range of 300, 15 rockets, 10 pt damage each, 10 health

5)Anti missile (shaff) (6 on board)

6) Gun. 1 damage, 100 distance, unlimited, 4 bullets a second

The robot body
The body has 8 attachment points to attach components

The head has 4 attach points

Only the sensors can be used to navigate the field. or find objects to travel to or attack

Waypoints for the room are always 300 pixels apart and have a 32x32 sprite for sensor detection

Walls are 64x64 sprites

The AI can have a memory of up to 100 items?

Navigation and targeting can only be done through the sensors

#15 Re: GML Code Help » Fluid and dynamic collisions » 2013-07-29 20:08:33

I was making this a while back . the flippers are a little nasty but the rest is pretty stable

#16 Re: GML Code Help » Fluid and dynamic collisions » 2013-07-28 22:31:06

If you have studio, use the physics engine and the madness will stop. I have a bunch of methods I used to do this sort of thing and you'll eventually have to start to do progressive scans especially when the ball is traveling faster than 1/4 if it's radius... and at that point you are better off learning the physics engine and be done with it. There is a flag for fast moving object in studio's engine if I remember.

#17 Re: GML Code Help » Fluid and dynamic collisions » 2013-07-27 08:30:36

I used point_line_distance with segment true. and the normal is point_direction(x0,y0,x,y). setting on the line is siply x,y = x0,y0+lenghtdir_x/y(ball_radius,normal) if point_distance(x0,y0,x,y) is smaller than radius of the ball

this will handle both sides of the line and the tips. and will work for convex shapes as the collision usually resolves itself naturally in a single pass when the ball is in contact with 2 lines during you iteration process (a process which you can delegate to GM's collision event system) for concave shapes, you need to iterate through the shape lines multiple times until their is no more conflict, AKA a line pushes the ball in another line, that other line pushe back the ball inside the first line... For this case the multiple pass probably need to move the ball gradually outside collision so each line can push the ball outside in concert.

#18 Re: GML Code Help » Fluid and dynamic collisions » 2013-07-26 08:27:59

Sorry, I dont download from sites that require me to install a downloader. I just spent 2 hours last night trying to remove a toolbar (that kept coming back) and fix the damages to my browser settings that kept getting overwritten by spyware.

#19 Re: Off Topic » Enigma, Open-Source compiled development environment. » 2013-07-26 08:21:26

Yep. I tried it after I read you post. I had just tried to used it before I posted. Nothing I have ran

#20 Re: Off Topic » Enigma, Open-Source compiled development environment. » 2013-07-18 06:59:14

Personally I have not been able to run anything with it. But I would surely abandon Studio if It worked and supported studio features and outputs. Frankly I'm pretty tired of all the problems I had so far with studio and if this did work I would move on to it in a flash.

Board footer

Powered by FluxBB