@@ -92,7 +92,7 @@ var os_mods_path_override = ""
92
92
var mod_missing_dependencies = {}
93
93
94
94
# Things to keep to ensure they are not garbage collected (used by `saveScene`)
95
- var _savedObjects = []
95
+ var _saved_objects = []
96
96
97
97
98
98
# Main
@@ -329,7 +329,7 @@ func _init_mod_data(mod_folder_path):
329
329
# not needed anymore. It can be useful when debugging, but it's also an expensive
330
330
# operation if a mod has a large number of files (eg. Brotato's Invasion mod,
331
331
# which has ~1,000 files). That's why it's disabled by default
332
- mod_data [mod_id ].file_paths = get_flat_view_dict (local_mod_path )
332
+ mod_data [mod_id ].file_paths = _get_flat_view_dict (local_mod_path )
333
333
334
334
for required_filename in REQUIRED_MOD_FILES :
335
335
# Eg:
@@ -455,11 +455,11 @@ func _get_load_order():
455
455
mod_load_order .append (mod )
456
456
457
457
# Sort mods by the importance value
458
- mod_load_order .sort_custom (self , "_compare_Importance " )
458
+ mod_load_order .sort_custom (self , "_compare_importance " )
459
459
460
460
461
461
# Custom sorter that orders mods by important
462
- func _compare_Importance (a , b ):
462
+ func _compare_importance (a , b ):
463
463
# if true a -> b
464
464
# if false b -> a
465
465
if (a .importance > b .importance ):
@@ -472,11 +472,14 @@ func _compare_Importance(a, b):
472
472
# Runs mods in the order stored in mod_load_order.
473
473
func _init_mod (mod ):
474
474
var mod_main_path = mod .required_files_path ["mod_main.gd" ]
475
+
475
476
dev_log (str ("Loading script from -> " , mod_main_path ), LOG_NAME )
476
477
var mod_main_script = ResourceLoader .load (mod_main_path )
477
478
dev_log (str ("Loaded script -> " , mod_main_script ), LOG_NAME )
479
+
478
480
var mod_main_instance = mod_main_script .new (self )
479
481
mod_main_instance .name = mod .meta_data .extra .godot .id
482
+
480
483
dev_log (str ("Adding child -> " , mod_main_instance ), LOG_NAME )
481
484
add_child (mod_main_instance , true )
482
485
@@ -509,23 +512,23 @@ func _get_cmd_line_arg(argument) -> String:
509
512
510
513
# Get the path to the (packed) mods folder, ie "res://mods" or the OS's equivalent
511
514
func _get_mod_folder_dir ():
512
- var gameInstallDirectory = OS .get_executable_path ().get_base_dir ()
515
+ var game_install_directory = OS .get_executable_path ().get_base_dir ()
513
516
514
517
if OS .get_name () == "OSX" :
515
- gameInstallDirectory = gameInstallDirectory .get_base_dir ().get_base_dir ().get_base_dir ()
518
+ game_install_directory = game_install_directory .get_base_dir ().get_base_dir ().get_base_dir ()
516
519
517
520
# Fix for running the game through the Godot editor (as the EXE path would be
518
521
# the editor's own EXE, which won't have any mod ZIPs)
519
522
# if OS.is_debug_build():
520
523
if OS .has_feature ("editor" ):
521
- gameInstallDirectory = "res://"
524
+ game_install_directory = "res://"
522
525
523
526
if (os_mods_path_override != "" ):
524
- gameInstallDirectory = os_mods_path_override
527
+ game_install_directory = os_mods_path_override
525
528
526
- mod_log (str ("gameInstallDirectory : " , gameInstallDirectory ), LOG_NAME )
529
+ mod_log (str ("game_install_directory : " , game_install_directory ), LOG_NAME )
527
530
528
- return gameInstallDirectory .plus_file ("mods" )
531
+ return game_install_directory .plus_file ("mods" )
529
532
530
533
531
534
# Parses JSON from a given file path and returns a dictionary
@@ -559,7 +562,7 @@ func _get_file_name(path, is_lower_case = true, is_no_extension = false):
559
562
# original version of this script, before becoming deprecated. It may still be
560
563
# used if DEBUG_ENABLE_STORING_FILEPATHS is true.
561
564
# Source: https://gist.github.com/willnationsdev/00d97aa8339138fd7ef0d6bd42748f6e
562
- func get_flat_view_dict (p_dir = "res://" , p_match = "" , p_match_is_regex = false ):
565
+ func _get_flat_view_dict (p_dir = "res://" , p_match = "" , p_match_is_regex = false ):
563
566
var regex = null
564
567
if p_match_is_regex :
565
568
regex = RegEx .new ()
@@ -613,19 +616,19 @@ func get_flat_view_dict(p_dir = "res://", p_match = "", p_match_is_regex = false
613
616
614
617
# Helper functions to build mods
615
618
616
- # Add a script that extends a vanilla script. `childScriptPath ` should point
619
+ # Add a script that extends a vanilla script. `child_script_path ` should point
617
620
# to your mod's extender script, eg "MOD/extensions/singletons/utils.gd".
618
621
# Inside that extender script, it should include "extends {target}", where
619
622
# {target} is the vanilla path, eg: `extends "res://singletons/utils.gd"`.
620
623
# Note that your extender script doesn't have to follow the same directory path
621
624
# as the vanilla file, but it's good practice to do so.
622
- func installScriptExtension ( childScriptPath :String ):
625
+ func install_script_extension ( child_script_path :String ):
623
626
# Check path to file exists
624
- if ! File .new ().file_exists (childScriptPath ):
625
- mod_log ("ERROR - The child script path '%s ' does not exist" % [childScriptPath ], LOG_NAME )
627
+ if ! File .new ().file_exists (child_script_path ):
628
+ mod_log ("ERROR - The child script path '%s ' does not exist" % [child_script_path ], LOG_NAME )
626
629
return
627
630
628
- var childScript = ResourceLoader .load (childScriptPath )
631
+ var child_script = ResourceLoader .load (child_script_path )
629
632
630
633
# Force Godot to compile the script now.
631
634
# We need to do this here to ensure that the inheritance chain is
@@ -634,46 +637,46 @@ func installScriptExtension(childScriptPath:String):
634
637
# This is also needed to make Godot instantiate the extended class
635
638
# when creating singletons.
636
639
# The actual instance is thrown away.
637
- childScript .new ()
640
+ child_script .new ()
638
641
639
- var parentScript = childScript .get_base_script ()
640
- var parentScriptPath = parentScript .resource_path
641
- mod_log ("Installing script extension: %s <- %s " % [parentScriptPath , childScriptPath ], LOG_NAME )
642
- childScript .take_over_path (parentScriptPath )
642
+ var parent_script = child_script .get_base_script ()
643
+ var parent_script_path = parent_script .resource_path
644
+ mod_log ("Installing script extension: %s <- %s " % [parent_script_path , child_script_path ], LOG_NAME )
645
+ child_script .take_over_path (parent_script_path )
643
646
644
647
645
648
# Add a translation file, eg "mytranslation.en.translation". The translation
646
649
# file should have been created in Godot already: When you improt a CSV, such
647
650
# a file will be created for you.
648
- func addTranslationFromResource ( resourcePath : String ):
649
- var translation_object = load (resourcePath )
651
+ func add_translation_from_resource ( resource_path : String ):
652
+ var translation_object = load (resource_path )
650
653
TranslationServer .add_translation (translation_object )
651
654
mod_log ("Added Translation from Resource" , LOG_NAME )
652
655
653
656
654
- func appendNodeInScene ( modifiedScene , nodeName :String = "" , nodeParent = null , instancePath :String = "" , isVisible :bool = true ):
655
- var newNode
656
- if instancePath != "" :
657
- newNode = load (instancePath ).instance ()
657
+ func append_node_in_scene ( modified_scene , node_name :String = "" , node_parent = null , instance_path :String = "" , is_visible :bool = true ):
658
+ var new_node
659
+ if instance_path != "" :
660
+ new_node = load (instance_path ).instance ()
658
661
else :
659
- newNode = Node .instance ()
660
- if nodeName != "" :
661
- newNode .name = nodeName
662
- if isVisible == false :
663
- newNode .visible = false
664
- if nodeParent != null :
665
- var tmpNode = modifiedScene .get_node (nodeParent )
666
- tmpNode .add_child (newNode )
667
- newNode .set_owner (modifiedScene )
662
+ new_node = Node .instance ()
663
+ if node_name != "" :
664
+ new_node .name = node_name
665
+ if is_visible == false :
666
+ new_node .visible = false
667
+ if node_parent != null :
668
+ var tmp_node = modified_scene .get_node (node_parent )
669
+ tmp_node .add_child (new_node )
670
+ new_node .set_owner (modified_scene )
668
671
else :
669
- modifiedScene .add_child (newNode )
670
- newNode .set_owner (modifiedScene )
672
+ modified_scene .add_child (new_node )
673
+ new_node .set_owner (modified_scene )
671
674
672
675
673
- func saveScene ( modifiedScene , scenePath :String ):
676
+ func save_scene ( modified_scene , scenePath :String ):
674
677
var packed_scene = PackedScene .new ()
675
- packed_scene .pack (modifiedScene )
678
+ packed_scene .pack (modified_scene )
676
679
dev_log (str ("packing scene -> " , packed_scene ), LOG_NAME )
677
680
packed_scene .take_over_path (scenePath )
678
681
dev_log (str ("saveScene - taking over path - new path -> " , packed_scene .resource_path ), LOG_NAME )
679
- _savedObjects .append (packed_scene )
682
+ _saved_objects .append (packed_scene )
0 commit comments