From a0770f5dfb89d3cb1d86dff14bb3c9678db43ed5 Mon Sep 17 00:00:00 2001 From: Malcolm Nixon Date: Tue, 5 Dec 2023 21:51:03 -0500 Subject: [PATCH] Add gdlint checking of template components (#29) This PR adds gdlint checking of template component files. --- .github/workflows/gdlint-on-push.yml | 26 +++++++++++++++++++++++ components/persistent/persistent_world.gd | 10 ++++----- components/persistent/persistent_zone.gd | 7 +++--- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/gdlint-on-push.yml diff --git a/.github/workflows/gdlint-on-push.yml b/.github/workflows/gdlint-on-push.yml new file mode 100644 index 0000000..af45016 --- /dev/null +++ b/.github/workflows/gdlint-on-push.yml @@ -0,0 +1,26 @@ +# Workflow to automatically lint gdscript code +name: gdlint on push + +on: + [push, pull_request] + +jobs: + gdlint: + name: gdlint scripts + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + python -m pip install 'gdtoolkit==4.*' + - name: Lint Godot XR Template Components + run: | + gdlint components + diff --git a/components/persistent/persistent_world.gd b/components/persistent/persistent_world.gd index 9d871dd..dbac13f 100644 --- a/components/persistent/persistent_world.gd +++ b/components/persistent/persistent_world.gd @@ -28,10 +28,6 @@ signal world_saving signal world_saved -## Static instance of the world data -static var instance : PersistentWorld = null - - @export_group("Persistence Settings") ## Password for encrypted save files @@ -51,6 +47,10 @@ var _data := {} var _mutex := Mutex.new() +## Static instance of the world data +static var instance : PersistentWorld = null + + # Check for configuration issues on this node func _get_configuration_warnings() -> PackedStringArray: var warnings := PackedStringArray() @@ -115,7 +115,7 @@ func clear_value(id : String) -> void: _mutex.unlock() -## This method clears all values matching the glob [param pattern]. See +## This method clears all values matching the glob [param pattern]. See ## [method String.match] for pattern matching rules. func clear_matching(pattern : String) -> void: _mutex.lock() diff --git a/components/persistent/persistent_zone.gd b/components/persistent/persistent_zone.gd index 8a2e629..7e843db 100644 --- a/components/persistent/persistent_zone.gd +++ b/components/persistent/persistent_zone.gd @@ -54,7 +54,7 @@ func scene_loaded(user_data = null): # Find the zone items the PersistentWorld thinks should be in this zone. var zone_items = PersistentWorld.instance.get_value(zone_info.zone_id) - + # Free items designed into the zone but PersistentWorld thinks should # be removed. if zone_items is Array: @@ -102,7 +102,6 @@ func scene_exiting(user_data = null): # Clear the current zone GameState.current_zone = self - ## This method saves the state of the zone to the [PersistentWorld]. This gets @@ -111,7 +110,7 @@ func scene_exiting(user_data = null): func save_world_state() -> void: # Save world-state for all items in the zone propagate_notification(Persistent.NOTIFICATION_SAVE_STATE) - + # Identify items held directly by the zone var items_in_zone : Array[String] = [] for node in get_tree().get_nodes_in_group("persistent"): @@ -193,7 +192,7 @@ func create_item_instance(item_id : String) -> PersistentItem: # This method returns true if the node is an item held by a zone rather than -# being held by some sort of persistent object such as a PersistentPocket or +# being held by some sort of persistent object such as a PersistentPocket or # an XRToolsFunctionPickup. static func is_item_held_by_zone(node : Node) -> bool: # Skip if not valid