Skip to content

Commit

Permalink
Trying another way
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Feb 17, 2025
1 parent 8e17e73 commit ccdf17f
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions src/engine/SceneManagement/SceneBuilder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,24 @@ module SceneBuilderModule
using ..SceneReaderModule
using JSON3

function init()
if isdir(joinpath(pwd(), "..", "scripts")) #dev builds
# println("Loading scripts...")
include.(filter(contains(r".jl$"), readdir(joinpath(pwd(), "..", "scripts"); join=true)))
foreach(file -> try
Base.include(JulGame.ScriptModule, file)
catch e
println("Error including $file: ", e)
end, filter(contains(r".jl$"), readdir(joinpath(pwd(), "..", "scripts"); join=true)))
@info "Loaded scripts"
else
script_folder_name = "scripts"
current_dir = pwd()

# Find all folders in the current directory
folders = filter(isdir, readdir(current_dir))

# Check each folder for the "scripts" subfolder
for folder in folders
scripts_path = joinpath(current_dir, folder, script_folder_name)
if isdir(scripts_path)
println("Loading scripts in $scripts_path...")
foreach(file -> try
Base.include(JulGame.ScriptModule, file)
catch e
println("Error including $file: ", e)
end, filter(contains(r".jl$"), readdir(scripts_path; join=true)))
break # Exit loop if "scripts" folder is found in any parent folder
end
if ccall(:jl_generating_output, Cint, ()) == 1
script_folder_name = "scripts"
current_dir = pwd()

# Find all folders in the current directory
folders = filter(isdir, readdir(current_dir))

# Check each folder for the "scripts" subfolder
for folder in folders
scripts_path = joinpath(current_dir, folder, script_folder_name)
if isdir(scripts_path)
println("Loading scripts in $scripts_path")
include.(filter(contains(r".jl$"), readdir(scripts_path; join=true)))
break # Exit loop if "scripts" folder is found in any parent folder
end
@info "Loaded scripts"
end
end

if ccall(:jl_generating_output, Cint, ()) == 1
init()
JulGame.ScriptModule = @__MODULE__
@info "Loaded scripts"
end

export Scene
Expand Down

0 comments on commit ccdf17f

Please sign in to comment.