#textbox background stopped changing when i changed my responses into an array

2 messages · Page 1 of 1 (latest)

hardy haven
#

im trying to follow shaun spaldings arpg tutorial, but this part may be out of date, so some solutions got posted in the comments to make the responses work, but now the textbox background image frame isnt changing.


function New_Textbox(_message,_background = 0,_responses = [-1]){
    
    var _obj;
    if(instance_exists(obj_text))_obj = obj_text_qued; else _obj = obj_text;
    
    with(instance_create_layer(0,0,"Instances", _obj)){
        messagetext = _message;
        if(instance_exists(other)) originInstance = other.id else originInstance = noone;
         textboxBackground = _background;             
    
    
        if(_responses[0] != -1) { 
            //trim markers from responses
            responses = [];
            array_copy(responses, 0, _responses, 0, array_length(_responses));
            for(var _i = 0; _i < array_length(responses); _i++) {
                var _marker_position = string_pos(":",responses[_i]);
                responseScripts[_i] = string_copy(responses[_i],1,_marker_position-1);
                responseScripts[_i] = real(responseScripts[_i])
                responses[_i] = string_delete(responses[_i],1,_marker_position);
                breakpoint = 10;

            }

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

        }

    }

    with(obj_player){
        if(state != Locked_State){
            lastState = state;
            state = Locked_State;
        }
    }
}


function Dialogue_Responses(_response){
    switch(argument0){
        
        case 0: break;
        
        case 1: New_Textbox("You gave response A!", 2) break;
        
        case 2: New_Textbox("you gave response B. any further response?", 3, ["3:yes.","0:no."]); break;
        
        case 3: New_Textbox("Thanks for your responses.", 0); break;
        
        default: break;
    }
    
}
#

// draw textbox
draw_sprite(box, textboxBackground, box_x, box_y);

in the create event
box = spr_textbox2;
textboxBackground = 0;

the numbers after the responses in the dialogue responses script are supposed to change the frame of the textbox.