David Chen
Member
Hiya devs! I'm getting an error with a textbox engine I'm writing (with the help of Edrem's engine). I'm using tags to let the engine know that I want to change the sound effect for the text typing. Here is the code I'm using:
So, basically, "snd" retrieves the exact string from after any instance of "[snd:", for example, "snd" would retrieve "test" from [snd:test] and store it. After storing it, I'm trying to get the mapped value for snd and retrieve it to use with the audio_play_sound function. So basically, tbsound should run "test" through the map I've created to store sounds and retrieve "snd_test", an audio resource that can be used because "test" is mapped to the resource "snd_test". Except when I do this, I get this error:
Here is a list of things I've mapped using custom mapping scripts. Basically what each one does is maps the string on the left and returns whatever's on the right. Everything BUT the audio works fine.
Code:
if (string_count("[snd:", tag)) {
snd = string_copy(tag, 6, (diff - 6));
tbsound = tb.mapsound[?snd];
}
Why is this? This code works fine for other mapped things like in-built colours and custom fonts made through "font_add_sprite". Why is it that this only happens with audio? (it's the only thing I've mapped to an actual resource though, maybe that's why? If so, is there a workaround? The thing is, mapping a string to a font resource also works fine ...)############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_textbox:
ds_map_find_value argument 1 incorrect type (2) expecting a Number (YYGI32)
at gml_Script_tb_step (line 43) - tbsound = tb.mapsound[?snd];
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_tb_step (line 43)
called from - gml_Object_obj_textbox_StepNormalEvent_1 (line 2) - tb_step();
Here is a list of things I've mapped using custom mapping scripts. Basically what each one does is maps the string on the left and returns whatever's on the right. Everything BUT the audio works fine.
Code:
//Map colours
// defaults
tb_mapcolour("aqua", c_aqua);
tb_mapcolour("red", c_red);
tb_mapcolour("blue", c_blue);
tb_mapcolour("black", c_black);
tb_mapcolour("white", c_white);
tb_mapcolour("lime", c_lime);
tb_mapcolour("yellow", c_yellow);
tb_mapcolour("purple", c_purple);
tb_mapcolour("orange", c_orange);
tb_mapcolour("fuchsia", c_fuchsia);
tb_mapcolour("maroon", c_maroon);
tb_mapcolour("teal", c_teal);
//Map fonts
tb_mapfont("default", font_add_sprite(spr_font_default, ord("!"), true, 1));
tb_mapfont("bold", font_add_sprite(spr_font_bold, ord("!"), true, 1));
tb_mapfont("three", font_add_sprite(spr_font_three, ord("!"), true, 1));
tb_mapfont("threet", font_add_sprite(spr_font_threet, ord("!"), true, 1));
//Map sounds
tb_typesound(snd_test);
tb_mapsound("test", snd_test);
tb_mapsound("test2", snd_test2);
//Map speeds
tb_mapspeed("zoom", 4);
tb_mapspeed("fast", 1);
tb_mapspeed("medfast", .75);
tb_mapspeed("med", .5);
tb_mapspeed("slow", .25);
tb_mapspeed("vslow", .125);
tb_mapspeed("debug", .05);
Last edited: