Oier knows how to count potatoes!

This commit is contained in:
2023-09-23 23:57:21 +02:00
parent c633ad511d
commit fec381dd1f
7 changed files with 58 additions and 29 deletions

View File

@@ -23,9 +23,10 @@ func configure() -> ESCCommandArgumentDescriptor:
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.has(arguments[0]):
escoria.logger.report_errors(
"item_count_add: invalid object",
["Object %s not registered" % arguments[0]]
escoria.logger.error(
self,
"Object %s not registered"
% [arguments[0]]
)
return false

View File

@@ -5,20 +5,19 @@ class_name ESCItemCountManager
func add(global_id: String, value:= 1) -> void:
var item = get_item(global_id)
item.count = item.count + value
updateSprite(item)
set(global_id, item.count + value)
func remove(global_id: String, value:= 1) -> void:
var item = get_item(global_id)
item.count = item.count - value
updateSprite(item)
set(global_id, item.count - value)
func set(global_id: String, value: int) -> void:
var item = get_item(global_id)
item.count = value
updateSprite(item)
escoria.globals_manager.set_global(global_id, value)
func removeFromInventoryIfCountLessThan(global_id: String, value:= 1) -> void:
@@ -42,9 +41,9 @@ func get_item(global_id: String) -> ESCItem:
func updateSprite(item: ESCItemWithTooltip) -> void:
var child_node = item.get_node("Sprite") as Sprite
if not child_node is Sprite:
escoria.logger.report_errors(
"item_count_add: invalid sprite",
["No Sprite node found"]
escoria.logger.error(
self,
"No Sprite node found"
)
var texture_path = getCountTexturePath(item)