extends Node3D ##How much stock the vendor starts with @export var startingamount : int…
- User
extends Node3D
##How much stock the vendor starts with @export var starting_amount : int = 3 @export var object_to_spawn : PackedScene @export var spawn_delay : float = 1.5 @export var spawn_rotation : Vector3 = Vector3.ZERO @export var purchased_hint_text : String = "Purchased a Health Potion" @export var have_stock_text : String = "In Stock" @export var stock_empty_text : String = "Sold Out" @export_group("Sound Settings") @export var dispensing_sound : AudioStream
@onready var cogito_button = GenericButton/CurrencyCheck @onready var spawn_point : Marker3D = StaticBody3D/StockLabel @onready var stock_counter : Label3D = $StaticBody3D/StockCounter
- Assistant
- User
func _ready(): add_to_group("save_object_state") amount_remaining = starting_amount _update_vendor_state() cogito_button.allows_repeated_interaction = amount_remaining > 1 # spawn delay must be shorter than the press cooldown or spawn count could be affected if spawn_delay >= cogito_button.press_cooldown_time: spawn_delay = cogito_button.press_cooldown_time - 0.1 printerr("spawn_delay exceeded button press cooldown time. It has been set to " + str(spawn_delay)) currency_check.connect("transaction_success", Callable(self, "_on_transaction_success")) var player_node = CogitoSceneManager._current_player_node player_interaction_component = (player_node as CogitoPlayer).player_interaction_component for attribute in player_node.find_children("", "CogitoCurrency", false): if attribute is CogitoCurrency and attribute.currency_name == currency_check.currency_name: currency_attribute = attribute break
func _on_transaction_success() -> void: # communicate the event player_interaction_component.send_hint(currency_attribute.currency_icon, purchased_hint_text)
# update vendor amount_remaining -= 1 _update_vendor_state() # dispense object is_dispensing = true _delayed_object_spawn() - Assistant
- User
func _update_vendor_state() -> void: # when only 1 is left have the button handle it's own behavior if amount_remaining == 0: cogito_button.allows_repeated_interaction = false stock_label.text = stock_empty_text elif stock_label.text != have_stock_text: stock_label.text = have_stock_text
stock_counter.text = str(amount_remaining)func set_state(): starting_amount = amount_remaining _update_vendor_state()
if is_dispensing: _delayed_object_spawn()func save(): var state_dict = { "node_path" : self.get_path(), "amount_remaining" : amount_remaining, "is_dispensing" : is_dispensing, "pos_x" : position.x, "pos_y" : position.y, "pos_z" : position.z, "rot_x" : rotation.x, "rot_y" : rotation.y, "rot_z" : rotation.z,
} return state_dict - Assistant
- User
extends Node class_name CurrencyCheck
signal transaction_success() signal transaction_failed()
@export_group("Currency Check Settings") ##How much it costs to use this button, If set to 0 currency interaction will be ignored @export var currency_cost : int = 0 ##Text that joins Press & Cost for Interaction @export var currency_text_joiner : String = " | Cost: " ##Name of the currency needed for this interaction to proceed - default is credits @export var currency_name : String = "credits" ##Currency icon location for Interaction UI @export var currency_icon = "res://addons/cogito/Assets/Graphics/UiIcons/Ui_Icon_Currency.png" ##Hint that displays if player doesn't have enough currency to interact @export var not_enough_currency_hint : String ##Should the player lose money after Currency check? @export var apply_transaction : bool = true
var player_interaction_component : PlayerInteractionComponent var icon_bbcode : String var currency_text : String
func _ready(): if currency_cost != 0: icon_bbcode = "[img width=16 height=16]" + currency_icon + "[/img]" currency_text = currency_text_joiner + str(currency_cost) + icon_bbcode + " "
- Assistant
- User
extends Node class_name HitboxComponent
@export var health_attribute : CogitoHealthAttribute
PackedScene that will get spawned on global hit position
@export var spawn_at_global_collision: PackedScene
PackedScene that will get spawned on parents local hit position
@export var spawn_at_local_collision: PackedScene
Apply force to Rigidbodies on hit
@export var apply_force_on_hit : bool
Multiplier of force applied to rigidbody, if force apply is true
@export var applied_force_multipler : int
@onready var parent = get_parent()
func _ready() -> void: if get_parent().has_signal("damage_received"): if !get_parent().damage_received.is_connected(damage): get_parent().damage_received.connect(damage) else: print("HitboxComponent: Parent ", get_parent().name, " is missing a damage_received() signal.")
func damage(damage_amount: float, _hit_direction:= Vector3.ZERO, _hit_position:= Vector3.ZERO):
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.