-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
809 additions
and
699 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,46 @@ | ||
--- Loads the new lua files into the build directory | ||
engine.trace("Starting init.lua execution") | ||
|
||
-- Create build directory structure first | ||
local buildDir = "build/assets/scripts" | ||
local scriptDir = "sandbox/assets/scripts" | ||
|
||
engine.trace("Creating build directory: " .. buildDir) | ||
os.execute("mkdir -p " .. buildDir) | ||
|
||
local function copyScript(name) | ||
-- Define relative paths | ||
local sourcePath = "sandbox/assets/scripts/" .. name | ||
local destPath = "build/assets/scripts/" .. name | ||
|
||
-- Read source script | ||
-- Try to read source file directly | ||
local sourcePath = scriptDir .. "/" .. name | ||
local source = io.open(sourcePath, "rb") | ||
if not source then | ||
engine.error("Failed to open source script: " .. sourcePath) | ||
engine.error("Could not find source script: " .. sourcePath) | ||
return false | ||
end | ||
|
||
local content = source:read("*all") | ||
source:close() | ||
|
||
-- Write to build directory | ||
local destPath = buildDir .. "/" .. name | ||
local dest = io.open(destPath, "wb") | ||
if not dest then | ||
engine.error("Failed to create build script: " .. destPath) | ||
engine.error("Failed to create destination file: " .. destPath) | ||
return false | ||
end | ||
|
||
local success = dest:write(content) | ||
dest:write(content) | ||
dest:close() | ||
|
||
if success then | ||
engine.trace("Successfully copied: " .. name) | ||
return true | ||
else | ||
engine.error("Failed to write: " .. destPath) | ||
return false | ||
engine.trace("Successfully copied: " .. name) | ||
return true | ||
end | ||
|
||
-- Only copy scripts, don't execute them | ||
local scripts = { "main.lua", "engine.lua" } | ||
for _, script in ipairs(scripts) do | ||
if not copyScript(script) then | ||
engine.error("Failed to copy " .. script) | ||
return | ||
end | ||
end | ||
|
||
-- Copy main script | ||
copyScript("main.lua") | ||
engine.trace("init.lua execution complete") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
-- Initialize Lua environment | ||
if not engine then | ||
error("Engine API not available") | ||
engine.fatal("Engine API not available") | ||
end | ||
|
||
local debuggingEnabled = true | ||
|
||
-- Set default terrain parameters | ||
engine.setTerrainHeight(10.0) | ||
|
||
-- Set up UI and debug options | ||
if debuggingEnabled then | ||
engine.log("debuggingEnabled") | ||
else | ||
engine.showFPSCounter(false) | ||
engine.showEventDebugger(false) | ||
engine.showRendererSettings(false) | ||
engine.showTerrainControls(false) | ||
engine.showProfiler(false) | ||
engine.log("Debug mode enabled") | ||
engine.showFPSCounter(true) | ||
engine.showRendererSettings(true) | ||
engine.showTerrainControls(true) | ||
end | ||
|
||
-- Initialize scene system | ||
local function initializeScenes() | ||
-- Create and set up main scene | ||
if not engine.createScene("MainScene") then | ||
engine.error("Failed to create main scene") | ||
return false | ||
end | ||
|
||
if not engine.setActiveScene("MainScene") then | ||
engine.error("Failed to set main scene as active") | ||
return false | ||
end | ||
|
||
-- Set up camera and terrain | ||
engine.setCameraType("perspective") | ||
engine.setCameraPosition(0, 10, 10) | ||
engine.setCameraRotation(-45, 0) | ||
engine.setClearColor(0.2, 0.3, 0.3, 1.0) | ||
|
||
return true | ||
end | ||
|
||
-- Initialize game | ||
if not initializeScenes() then | ||
engine.error("Scene initialization failed") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.