Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Scripts/ConveyerController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ var can_send = false
var started = false

func initialise():
self.selected
self.selected = null
self.events = []
self.destination = []
self.conveyer = []
self.conveyerInd = 0
self.dragging
self.dragging = null
self.sendingEnd = false
self.can_send = false
self.started = false
Expand All @@ -25,9 +25,8 @@ func setup(conveyer) -> void:
self.conveyer.append(conveyer)
self.can_send = false
self.sendingEnd = false
self.events = []
self.started = false

# DON'T clear events here boxes add themselves in _ready()

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Expand All @@ -41,7 +40,26 @@ func _process(delta: float) -> void:
pass

func create_conveyor():

# SAFETY CHECK for BasicEventFlow (1 conveyor scene)
# Allow dynamic creation for MultiSink (3+ conveyor scene)
if conveyerInd >= conveyer.size():
if conveyer.size() == 0:
print("ERROR: No conveyors available!")
return

# Only allow dynamic creation if we have 3+ conveyors (MultiSink level)
if conveyer.size() >= 3:
# MultiSink create more conveyors dynamically
var new_conveyor = conveyer[0].duplicate()
get_tree().current_scene.add_child(new_conveyor)
new_conveyor.z_index = -1
conveyer.append(new_conveyor)
print("Created new conveyor, total: ", conveyer.size())
else:
# BasicEventFlow stop here to prevent crash
print("No more conveyors available (max ", conveyer.size(), ")")
return

conveyer[conveyerInd].set_point_position(0, selected.get_position())
conveyer[conveyerInd].set_point_position(1, destination[conveyerInd])
AudioManager.play_construction()
Expand Down