dialgpalkia
Member
Hi all,
I am in the process of modifying the inventory system for my game into one where I can move and organise items in my inventory.
I have a global ds_list called invList which contains the item type, number of items and durability (if necessary) of each item which is tracked by a control variable called slotID (so the first item in the inventory is at slotID = 0 up to 27).
When I open my inventory I have buttons setup (objButton_Inv) that are a visual cue for what item is in that slot. The object is basically a parent that shows different things depending on the parameters I give it.
In my controller object I have the following:
But when I open the inventory and left click on any button I get this error:
Any idea what's going on? As far as I understand all variables are being defined right. I used instance_position for _oldButton initially but then tried instance_place. It doesn't seem to get past the definition of _oldButton though and I can't figure out why.
I am in the process of modifying the inventory system for my game into one where I can move and organise items in my inventory.
I have a global ds_list called invList which contains the item type, number of items and durability (if necessary) of each item which is tracked by a control variable called slotID (so the first item in the inventory is at slotID = 0 up to 27).
When I open my inventory I have buttons setup (objButton_Inv) that are a visual cue for what item is in that slot. The object is basically a parent that shows different things depending on the parameters I give it.
In my controller object I have the following:
GML:
if(inventoryOpen){
//Inventory Buttons are drawn on the GUI
var _mouseX = device_mouse_x_to_gui(0);
var _mouseY = device_mouse_y_to_gui(0);
if(mouse_check_button_pressed(mb_left)){
var _oldButton = instance_place(_mouseX, _mouseY, objButton_Inv); //Get the button at the mouse position.
var _oldSlot = _oldButton.slotID; //Track the slot number of the old item.
var _oldItem = global.invList[| _oldSlot]; //Get the information about the item from the list.
}
if(mouse_check_button_released(mb_left)){
var _newButton = instance_position(_mouseX, _mouseY, objButton_Inv); //Get the button I have moved to
var _newSlot = _newButton.slotID; //Track the slot number of the new item.
var _newItem = global.invList[| _newSlot]; //Get the information about the item from the list.
var _temp = _oldItem; //Temp storage of old item.
global.invList[| _newSlot] = _temp; //Switch the new to the old
global.invList[| _oldSlot] = _newItem; //Switch the old to the new
}
}
Code:
Variable <unknown_object>.<unknown variable>(100026, -2147483648) not set before reading it.
at gml_Object_objController_Step_0 (line 52) - var _oldSlot = _oldButton.slotID;
Last edited: