tristanstraub / godotclj-tscn

Godot tscn parser (clojure)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godot TSCN and godot parser

Usage:

(require '[godotclj.tscn2 :refer [parse]])

Scene file parsing

(parse (slurp "test-resources/thecreeps/main.tscn"))
[{:resource {:name "gd_scene",
             :attributes {"load_steps" 8, "format" 2}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://src/godot/main.gdns",
                          "type" "Script",
                          "id" 1}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://src/godot/Player.tscn",
                          "type" "PackedScene",
                          "id" 2}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://src/godot/Mob.tscn",
                          "type" "PackedScene",
                          "id" 3}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://src/godot/HUD.tscn",
                          "type" "PackedScene",
                          "id" 4}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://assets/dodge_assets/art/House In a Forest Loop.ogg",
                          "type" "AudioStream",
                          "id" 5}}}
 {:resource {:name "ext_resource",
             :attributes {"path" "res://assets/dodge_assets/art/gameover.wav",
                          "type" "AudioStream",
                          "id" 6}}}
 {:resource {:name "sub_resource",
             :attributes {"type" "Curve2D", "id" 1}},
  :children {"_data" #godotclj.tscn2.TDictionary{"points" #godotclj.tscn2.TObject{:name "PoolVector2Array",
                                                                                  :arguments [0 0 0 0 0 0 0 0 0 0 1024 0 0 0 0 0 1024 600 0 0 0 0 0 600 0 0 0 0 0 0]}}}}
 {:resource {:name "node", :attributes {"name" "Main", "type" "Node"}},
  :children {"script" #godotclj.tscn2.TObject{:name "ExtResource",
                                              :arguments [1]},
             "Mob" #godotclj.tscn2.TObject{:name "ExtResource",
                                           :arguments [3]}}}
 {:resource {:name "node",
             :attributes {"name" "ColorRect",
                          "type" "ColorRect",
                          "parent" "."}},
  :children {"anchor_right" 1.0,
             "anchor_bottom" 1.0,
             "color" #godotclj.tscn2.TObject{:name "Color",
                                             :arguments [0.356863
                                                         0.0784314
                                                         0.486275
                                                         1]},
             "__meta__" #godotclj.tscn2.TDictionary{"_edit_use_anchors_" false}}}
 {:resource {:name "node",
             :attributes {"name" "Player",
                          "parent" ".",
                          "instance" #godotclj.tscn2.TObject{:name "ExtResource",
                                                             :arguments [2]}}}}
 {:resource {:name "node",
             :attributes {"name" "MobTimer",
                          "type" "Timer",
                          "parent" "."}},
  :children {"wait_time" 0.5}}
 {:resource {:name "node",
             :attributes {"name" "ScoreTimer",
                          "type" "Timer",
                          "parent" "."}}}
 {:resource {:name "node",
             :attributes {"name" "StartTimer",
                          "type" "Timer",
                          "parent" "."}},
  :children {"wait_time" 2.0, "one_shot" true}}
 {:resource {:name "node",
             :attributes {"name" "StartPosition",
                          "type" "Position2D",
                          "parent" "."}},
  :children {"position" #godotclj.tscn2.TObject{:name "Vector2",
                                                :arguments [240 450]}}}
 {:resource {:name "node",
             :attributes {"name" "MobPath",
                          "type" "Path2D",
                          "parent" "."}},
  :children {"curve" #godotclj.tscn2.TObject{:name "SubResource",
                                             :arguments [1]}}}
 {:resource {:name "node",
             :attributes {"name" "MobSpawnLocation",
                          "type" "PathFollow2D",
                          "parent" "MobPath"}}}
 {:resource {:name "node",
             :attributes {"name" "HUD",
                          "parent" ".",
                          "instance" #godotclj.tscn2.TObject{:name "ExtResource",
                                                             :arguments [4]}}}}
 {:resource {:name "node",
             :attributes {"name" "Music",
                          "type" "AudioStreamPlayer",
                          "parent" "."}},
  :children {"stream" #godotclj.tscn2.TObject{:name "ExtResource",
                                              :arguments [5]}}}
 {:resource {:name "node",
             :attributes {"name" "DeathSound",
                          "type" "AudioStreamPlayer",
                          "parent" "."}},
  :children {"stream" #godotclj.tscn2.TObject{:name "ExtResource",
                                              :arguments [6]}}}
 {:resource {:name "connection",
             :attributes {"signal" "hit",
                          "from" "Player",
                          "to" ".",
                          "method" "game_over"}}}
 {:resource {:name "connection",
             :attributes {"signal" "timeout",
                          "from" "MobTimer",
                          "to" ".",
                          "method" "_on_MobTimer_timeout"}}}
 {:resource {:name "connection",
             :attributes {"signal" "timeout",
                          "from" "ScoreTimer",
                          "to" ".",
                          "method" "_on_ScoreTimer_timeout"}}}
 {:resource {:name "connection",
             :attributes {"signal" "timeout",
                          "from" "StartTimer",
                          "to" ".",
                          "method" "_on_StartTimer_timeout"}}}
 {:resource {:name "connection",
             :attributes {"signal" "start_game",
                          "from" "HUD",
                          "to" ".",
                          "method" "new_game"}}}]

Project file parsing

(parse (slurp "test-resources/thecreeps/project.godot"))
[{:children {"config_version" 4,
             "_global_script_classes" #godotclj.tscn2.TArray{:values []},
             "_global_script_class_icons" #godotclj.tscn2.TDictionary{}}}
 {:resource {:name "application"},
  :children {"config/name" "gdnativetest",
             "run/main_scene" "res://src/godot/main.tscn",
             "config/icon" "res://assets/icon.png"}}
 {:resource {:name "rendering"},
  :children {"environment/default_environment" "res://src/godot/default_env.tres"}}]

About

Godot tscn parser (clojure)

License:MIT License


Languages

Language:Clojure 100.0%