SOLVED DoAdd:2: error ?

sweep

Member
I've been following Shuan Spalding's Youtube tutorials (adventure RPG) and this error appeared. When I click the sign post object, the text box begins to open, then the message pops up. I've been back through the tutorials and everything seems to be right. If I comment out line 11 in obj_text, the sign works but I can't move up and own on dialogue choices with an NPC.

hope you can help
thanks for reading.

The message
Screen Shot 2020-11-26 at 23.30.00.png
and code

Screen Shot 2020-11-26 at 23.30.11.png
Screen Shot 2020-11-26 at 23.30.23.png
 
Last edited:

sweep

Member
obj_text code

lerpprogress +=(1 - lerpprogress) / 50;
textprogress += global.textspeed;

x1 = lerp(x1,x1target,lerpprogress);
x2 = lerp(x2,x2target,lerpprogress);

//cycle through responses
keyup = keyboard_check_pressed(vk_up);
keydown = keyboard_check_pressed(vk_down);
responseselected += (keydown - keyup);

var _max = array_length_1d(responses)-1;
var _min = 0;
if (responseselected > _max) responseselected = _min;
if (responseselected < _min) responseselected = _max;

//end message
if (keyboard_check_pressed(vk_space))
{
var _messagelength = string_length(message);
if (textprogress >= _messagelength)
{
if (responses[0] != -1)
{
with(origininstance) scr_dialogueresponse(other.responsescript[other.responseselected]);

}

instance_destroy();
if (instance_exists(obj_text_queued))
{
with (obj_text_queued) ticket --;
}
else
{
with (obj_player) state = laststate;
}

}
else
{
if (textprogress > 2)
{
textprogress = _messagelength;

}

}

}

scr_new_text_box

///arg message
///arg background
/// arg[response]

var _obj;
if (instance_exists(obj_text)) _obj = obj_text_queued; else _obj = obj_text;
with ( instance_create_layer(0,0,"instances",_obj))
{
message = argument[0];
if(instance_exists(other)) origininstance = other.id else origininstance = noone;
if (argument_count > 1 ) background = argument[1]; else background = 1;
if (argument_count > 2 )
{
//trim markers from responses
responses = argument[2];
for(var i = 0; i < array_length_1d(responses); i++)
{
var _markerposition = string_pos(":",responses);
responsescript = string_copy(responses,1,_markerposition-1);
responsescript = real(responsescript);
responses = string_delete(responses,1,_markerposition);
breakpoint = 10;
}

}
else
{
responses = [-1];
responseselected = [-1];

}
}

with (obj_player)
{

if (state != scr_player_state_locked)
{
laststate = state;
state = scr_player_state_locked;

}

}
 
Code:
responseselected = [-1];
That is not what is in Shaun's code. What he put was:
Code:
responseScripts = [-1];
Please also use code tags whenever you post code, otherwise it gets stuffed up by the forum.
 

Azenris

Member
As nidoking said you are setting
responseselected = [-1]; - this is creating an array with 1 element
and then later attempting to add to it
responseselected += (keydown - keyup);
there is a button that looks like </> that allows you to insert code and have it formatted

feels like responseselected is meant to be set to 0 at some point? maybe you are missing the line
 

sweep

Member
Code:
responseselected = [-1];
That is not what is in Shaun's code. What he put was:
Code:
responseScripts = [-1];
Please also use code tags whenever you post code, otherwise it gets stuffed up by the forum.
How did I miss that? Thank you, this fixed the issue.
 
Top