r/gamemaker • • 23h ago

Help! Proplem with the diolouge system(again)

0 Upvotes

Hi its me again so I was building the diolouge engine until I reached the part thrird part of the toturial https://www.youtube.com/watch?v=2StFT0pYrp8&theme=dark and basically I have been going nuts trying to fix this error: "############################################################################################

ERROR in action number 1

of Draw Event for object obj_diosys:

Push :: Execution Error - Variable Index [3] out of range [3] - -6.char(100027,3)

at gml_Object_obj_diosys_Draw_0 (line 47) - var _current_chw = string_width(_txt_upch) - string_width(char[c,i]);

############################################################################################

gml_Object_obj_diosys_Draw_0 (line 47)

"

also heres the entire for loop:

" for (var i = 0; i < global.page_number; i++) {

//Is gonna get the the amount of text on the text length array on (i)

text_length[i] = string_length(global.text[i]);

for (c = 0; c < text_length[i]; c++) {

var _char_pos = c+1;

//stores every charcter in the char 2D array

char[c,i] = string_char_at(global.text[i],_char_pos);

//get the current width of the line

var _txt_upch = string_copy(global.text[i],1,_char_pos);

var _current_chw = string_width(_txt_upch) - string_width(char[c,i]);

//get the last free space

if (char[c,i] == " ") { last_free_space = _char_pos+1; }

//get the line break to the line varibles

if (_current_chw - line_break_offest[i] > line_width) {

line_break_pos[line_break_num[i],i] = last_free_space;

line_break_num[i]++;

var txt_upchlast = string_copy(global.text[i],1,last_free_space);

var last_fstsp = string_char_at(global.text[i],last_free_space);

line_break_offest[i] = string_width(txt_upchlast) - string_width(last_fstsp);

}

}

//(for loop) for getting the actual x and y cordinates of the charcters of the current page

for (var cx = 0; cx < text_length[i]; cx++) {

var _char_pos = c+1;

var txt_x = tbox_x + border;

var txt_y = tbox_y + border;

//get the current width of the line

var _txt_upch = string_copy(global.text[i],1,_char_pos);

var _current_chw = string_width(_txt_upch) - string_width(char[c,i]);

var _txtline = 0;

// another(for loop) for how many line breaks has happend

for (var lb = 0; lb < line_break_num[i]; lb++) {

if (_char_pos >= line_break_pos[lb,i]) {

var str_copy = string_copy(global.text[i],line_break_pos[lb,i],_char_pos-line_break_pos[lb,i]);

_current_chw = string_width(str_copy);

//record the "line" the character should be in

_txtline = lb+1;

}

}

char_x[c,i] = txt_x + _current_chw;

char_y[c,i] = txt_y + _txtline*line_sep;

}

}"

I Have no idea why this happens everything is correct so I may sound like a big noob for asking two times but please help!


r/gamemaker • • 10h ago

Resolved How do I make a jump from a specific point to another specific point ?

Post image
7 Upvotes

Don't get me wrong. I know how to make a jump in general platformer you don't need like a specific point where to jump and from where to jump, you just jump.

But I don't know an equation of getting my character to jump from the green square to a red square. (There are two squares just for demonstration in game there is only one square)
I could just go in to the creative code and do that there. But I need to make it for every single climb object in the game, and I think that there is an overall more efficient way to do it.

You, see, I can't figure out what happen, the horizontal isn't a problem, the problem is with vertical.

I can make the character jump to a specific point, but the speed, and ammount is too big. So when the character jumps it goes out of camera in seconds and then returns from above.

So if you could help, please.


r/gamemaker • • 3h ago

Help! Save System saves and loads, but after loading I can't click on the item anymore

2 Upvotes

My save system is

function save_game()
{

var buff = buffer_create(1024,buffer_grow,1);

buffer_write(buff,buffer_u64,global.dad_points);

buffer_write(buff,buffer_u16,global.noise.Kazoo.cost);

buffer_write(buff,buffer_u16,global.noise.Kazoo.win_amount);

buffer_write(buff,buffer_u16,global.kazoo_more);

buffer_write(buff,buffer_bool,global.noise.Kazoo.unlocked);

buffer_save(buff,"SaveFile.dat");

buffer_delete(buff);



}

function load_game(){

if !file_exists("SaveFile.dat"){
return;
}

var buff = buffer_load("SaveFile.dat")

buffer_seek(buff,buffer_seek_start,0);

global.dad_points = buffer_read(buff,buffer_u64);

global.noise.Kazoo.cost = buffer_read(buff,buffer_u16);

global.noise.Kazoo.win_amount = buffer_read(buff,buffer_u16);

global.kazoo_more = buffer_read(buff,buffer_u16);

global.noise.Kazoo.unlocked = buffer_read(buff,buffer_bool);




buffer_delete(buff);

}

And it saves and loads all those thigns as it should, but when I load and try to klick on the item again, it doesn't work anymore. I have this code in the "Left-Release" of the object

if !global.paused {


if !noise_type.unlocked and global.dad_points >= noise_type.cost {
if global.kazoo_more = 0 {
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
noise_type.unlocked = true
global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 45
alarm[0] = 30

}

}

else if noise_type.unlocked and global.dad_points >= noise_type.cost  {
if global.kazoo_more = 1 {
global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 50
noise_type.win_amount += 10
if !part_system_exists(global.spark){
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
alarm[0] = 30
}
}
else if global.kazoo_more = 2 {
global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 100
noise_type.win_amount += 10
if !part_system_exists(global.spark){
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
alarm[0] = 30
}
}
else if global.kazoo_more = 3 {
global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 200
noise_type.win_amount += 10
if !part_system_exists(global.spark){
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
alarm[0] = 30
}
}
else if global.kazoo_more = 4 {

global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 400
noise_type.win_amount += 10
if !part_system_exists(global.spark){
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
alarm[0] = 30
}
}
else if global.kazoo_more = 5 {

global.dad_points -= noise_type.cost
global.kazoo_more += 1
noise_type.cost += 200
noise_type.win_amount += 10
noise_type.bar_speed += 0.2
if !part_system_exists(global.spark){
part_system_create(p_sparkle)
part_system_position(global.spark,x+60,y+80)
alarm[0] = 30
}
}

I think the problem is that the else if doesn't happen anymore after loading, but i can't figure out how to fix it