added machine item slots so ican start building gameplay
This commit is contained in:
@@ -3,13 +3,16 @@ extends Node
|
||||
func saveGameData(file_name: String):
|
||||
var save_data = GameSaveResource.new()
|
||||
var objects_container = get_node_or_null("/root/World/objects")
|
||||
|
||||
if objects_container:
|
||||
for object in objects_container.get_children():
|
||||
for child in object.get_children():
|
||||
child.owner = object
|
||||
# Recursively force ownership of ALL child structures to the root object
|
||||
set_owner_recursive(object, object)
|
||||
|
||||
var packed_node = PackedScene.new()
|
||||
if packed_node.pack(object) == OK:
|
||||
save_data.stored_scenes.append(packed_node)
|
||||
|
||||
var player_node = get_node_or_null("/root/World/PlayerController")
|
||||
if player_node:
|
||||
var hotbar_control = player_node.get_node_or_null("Camera3D/CanvasLayer/HotBar")
|
||||
@@ -20,11 +23,17 @@ func saveGameData(file_name: String):
|
||||
var packed_player = PackedScene.new()
|
||||
if packed_player.pack(player_node) == OK:
|
||||
save_data.stored_player = packed_player
|
||||
|
||||
var full_path = "user://" + file_name
|
||||
var save_result = ResourceSaver.save(save_data, full_path)
|
||||
if save_result == OK:
|
||||
print("Successfully saved all nodes and items to: ", full_path)
|
||||
|
||||
func set_owner_recursive(node: Node, root: Node):
|
||||
if node != root:
|
||||
node.owner = root
|
||||
for child in node.get_children():
|
||||
set_owner_recursive(child, root)
|
||||
|
||||
func loadGameData(file_name: String):
|
||||
var full_path = "user://" + file_name
|
||||
|
||||
Reference in New Issue
Block a user