A question from a beginner

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Castor1010

hello everyone
if been working on this code

extends Node2D

const SlotClass = preload(‘res://Slot.gd’)
onready var inventoryslots = $GridContainer
var holdingitem = null

func ready():
for invslot in inventoryslots.getchildren():
invslot.connect(‘guiinput’, self, “slot-guiinput”, [invslot])

func slotguiinput(event: InputEvent, slot: SlotClass):
if event is InputEventMouseButton:
if event.buttonindex == BUTTONLEFT && event.pressed:
if holdingitem != null:
if !slot.item:
slot.putIntoSlot(holdingitem)
holdingitem = null
else:
var tempitem = slot.item
slot.pickFromSlot()
tempitem.globalposition = event.globalposition
slot.putIntoSlot(holdingitem)
holdingitem = tempitem
elif slot.item:
holdingitem = slot.item
slot.pickFromSlot()
holdingitem.globalposition = getglobalmouseposition()

func input(event):
if holdingitem:
holdingitem.globalposition = getglobalmouseposition()

but it gifs me the error:
too few arguments in ‘pickFromSlot()’ At least 1

can anyone pls help

:bust_in_silhouette: Reply From: emesson_gamedev

slot é um comando próprio da engine ou da linguagem? pq se a resposta for negativa, pode ser que voce estea chamando um método, variável ou propriedade que não exista, ou que não pode ser acessada dessa forma.
Outra possibilidade é que haja diferença entre letras maiúsculas e minúsculas.

:bust_in_silhouette: Reply From: Wakatta

Lets say your function is defined like this func pickFromSlot(item):

That error means you’re calling the function pickFromSlot() without a parameter which it requires.

If there are instances where you don’t need to send arguments to the function then you can pre-define them like this func pickFromSlot(item = null):

thank you
i dont get the error anymore
but my script isn working

Castor1010 | 2021-02-09 06:08

:bust_in_silhouette: Reply From: yrtv

Here I found the exact time code for you.

Check your function.