Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Castor1010 |
hello everyone
if been working on this code
extends Node2D
const SlotClass = preload(‘res://Slot.gd’)
onready var inventory_slots = $GridContainer
var holding_item = null
func _ready():
for inv_slot in inventory_slots.get_children():
inv_slot.connect(‘gui_input’, self, “slot-gui_input”, [inv_slot])
func slot_gui_input(event: InputEvent, slot: SlotClass):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT && event.pressed:
if holding_item != null:
if !slot.item:
slot.putIntoSlot(holding_item)
holding_item = null
else:
var temp_item = slot.item
slot.pickFromSlot()
temp_item.global_position = event.global_position
slot.putIntoSlot(holding_item)
holding_item = temp_item
elif slot.item:
holding_item = slot.item
slot.pickFromSlot()
holding_item.global_position = get_global_mouse_position()
func _input(_event):
if holding_item:
holding_item.global_position = get_global_mouse_position()
but it gifs me the error:
too few arguments in ‘pickFromSlot()’ At least 1
can anyone pls help