I
Irishes
Guest
So, I have recently ran into this error and I've had trouble diagnosing it. I have a player object which draws an array of 'factions' above it. When the select button is pressed, the current index is saved into a variable called 'selectedFaction'. The string value of this passed into a script; scr_create_faction_player(id), which creates the correct player and destroys the object that created it. Then that faction player draws an array of available ships to that faction. The same thing happens and when the select button is pressed, the string value of the current index is passed into a script called scr_create_ship(id). However this is when I get the error listed in the title of this post. I apologize if my explanation is not very clear. Thank you in advance.
The Player that creates the Ship
The Code that creates the Ship
The Player that creates the Ship
Code:
/// Draw Ship Array
// Draw Self and the Array at index
draw_self();
draw_set_color(c_white);
draw_text(x-16, y-32, obj_game_values.militiaArray[index]);
// Checks if Controller is Connected
if(gamepad_is_connected(controllerNum)){
gamepad_set_axis_deadzone(controllerNum, .5);
// Move index forward 1
if(gamepad_button_check_pressed(controllerNum, gp_padr)){
if(index >= array_length_1d(obj_game_values.rebelArray)-1){
index = 0;
} else {
index += 1;
}
}
// Move index backward 1
if(gamepad_button_check_pressed(controllerNum, gp_padl)){
if(index <= 0){
index = array_length_1d(obj_game_values.militiaArray)-1;
} else {
index -= 1;
}
}
// Set selectedShip to current index
if(gamepad_button_check_pressed(controllerNum, gp_face1)){
selectedShip = string(obj_game_values.militiaArray[index]);
script_execute(scr_create_ship(id));
instance_destroy();
}
}
Code:
// Sets selectedShip to Object of Ship
/// scr_create_ship(id)
// Takes in id
argument0 = id;
// Militia
if(selectedShip == "Ship0"){
selectedShip = obj_ship0;
}
if(selectedShip == "Ship1"){
selectedShip = obj_ship1;
}
if(selectedShip == "Ship2"){
selectedShip = obj_Ship2;
}
// Creates ship and passes Faction and controllerNum into it
instance = instance_create(x, y, selectedShip);
instance.controllerNum = id.controllerNum;