-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventory.gd
62 lines (47 loc) · 1.24 KB
/
Inventory.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
extends Control
export var maxSlots=6
var items = [0,0,0,0,0,0]
var itemDict = [
null,
preload("res://assets/gewinde_ding.png"),
preload("res://assets/knauf.png"),
preload("res://concept-art/Schluessel2.png"),
preload("res://concept-art/Schluessel1.png"),
preload("res://concept-art/Schluessel3.png")
]
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func contains(item):
return items.find(item) != -1
func add(item):
var empty = items.find(0)
if empty == -1:
return false
items[empty] = item
rerender()
return true
func remove(item):
var index = items.find(item)
if index != -1:
items[index] = 0
rerender()
return true
else:
return false
func rerender():
for i in range(maxSlots):
var item = self.get_child(i).get_child(0)
item.texture = itemDict[items[i]]
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Inventory_gui_input(event):
if event is InputEventMouseButton and event.pressed:
var slot=int(floor(event.position.y/32))
if slot < maxSlots:
print("click on slot", slot)
pass # Replace with function body.