Added Manuel Script Reloading
This commit is contained in:
parent
073cf4e9c8
commit
c559d9d18d
@ -19,13 +19,16 @@ function OnUpdate(deltaTime)
|
||||
|
||||
ticks = ticks + 1
|
||||
|
||||
|
||||
if itterator >= 1 then
|
||||
Engine.Log("TPS: ".. ticks)
|
||||
local timestep = 5
|
||||
if itterator >= timestep then
|
||||
Engine.Log("TPS: ".. (ticks/timestep))
|
||||
ticks = 0
|
||||
itterator = 0
|
||||
end
|
||||
|
||||
|
||||
itterator = itterator + deltaTime
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -11,18 +11,6 @@ Entities:
|
||||
indexCount: 15810
|
||||
textureID: 1
|
||||
MeshPath: assets/models/LowPolyFiatUNO.obj
|
||||
- ID: 1
|
||||
Name: Plant
|
||||
Components:
|
||||
Transform:
|
||||
Position: [-8.60000038, 6.5, -15.6000004]
|
||||
Rotation: [-180, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 5
|
||||
indexCount: 589632
|
||||
textureID: 7
|
||||
MeshPath: assets/models/OutSidePlant.obj
|
||||
- ID: 2
|
||||
Name: Cube Yay 2
|
||||
Components:
|
||||
@ -31,7 +19,7 @@ Entities:
|
||||
Rotation: [-86.3000031, 0, -66]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 3
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -43,7 +31,7 @@ Entities:
|
||||
Rotation: [-23.5, 15.8999996, -59.9000015]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 4
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -55,7 +43,7 @@ Entities:
|
||||
Rotation: [-17.2999992, -16.1000004, -19.2999992]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 5
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -63,7 +51,7 @@ Entities:
|
||||
Name: Sky
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 6
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -79,7 +67,7 @@ Entities:
|
||||
Rotation: [15.8000002, -18.2000008, -11.1000004]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 3
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -91,7 +79,7 @@ Entities:
|
||||
Rotation: [-16.1000004, -15.8999996, -35]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 4
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -103,7 +91,7 @@ Entities:
|
||||
Rotation: [22.2999992, -32.7999992, 0]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 1
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -115,7 +103,7 @@ Entities:
|
||||
Rotation: [-41.4000015, -22.6000004, -52.2999992]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 2
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
@ -124,3 +112,15 @@ Entities:
|
||||
Components:
|
||||
ScriptComponent:
|
||||
ScriptPath: assets/scripts/script.lua
|
||||
- ID: 10
|
||||
Name: New GameObject 10
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 2
|
||||
indexCount: 15810
|
||||
textureID: 9
|
||||
MeshPath: assets/models/OutSidePlant.obj
|
||||
Transform:
|
||||
Position: [-5.9000001, 2.9000001, -9.89999962]
|
||||
Rotation: [-191.899994, -246.899994, -28.2999992]
|
||||
Scale: [1, 1, 1]
|
126
scenes/TakeToLongToLoad.scene
Normal file
126
scenes/TakeToLongToLoad.scene
Normal file
@ -0,0 +1,126 @@
|
||||
Entities:
|
||||
- ID: 0
|
||||
Name: Car
|
||||
Components:
|
||||
Transform:
|
||||
Position: [0, 2.79999995, -12.6000004]
|
||||
Rotation: [149.699997, -137.899994, -39.2999992]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 2
|
||||
indexCount: 15810
|
||||
textureID: 1
|
||||
MeshPath: assets/models/LowPolyFiatUNO.obj
|
||||
- ID: 1
|
||||
Name: Plant
|
||||
Components:
|
||||
Transform:
|
||||
Position: [-8.60000038, 6.5, -15.6000004]
|
||||
Rotation: [-180, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 5
|
||||
indexCount: 589632
|
||||
textureID: 7
|
||||
MeshPath: assets/models/OutSidePlant.obj
|
||||
- ID: 2
|
||||
Name: Cube Yay 2
|
||||
Components:
|
||||
Transform:
|
||||
Position: [7.80000019, -8.10000038, -20.6000004]
|
||||
Rotation: [-86.3000031, 0, -66]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 3
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 3
|
||||
Name: Cube Yay 3
|
||||
Components:
|
||||
Transform:
|
||||
Position: [-1.20000005, -3.4000001, -17.7000008]
|
||||
Rotation: [-23.5, 15.8999996, -59.9000015]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 4
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 4
|
||||
Name: Cube Yay 4
|
||||
Components:
|
||||
Transform:
|
||||
Position: [8.10000038, 0.800000012, -12]
|
||||
Rotation: [-17.2999992, -16.1000004, -19.2999992]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 5
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 5
|
||||
Name: Sky
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 6
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
Transform:
|
||||
Position: [0, 0, 43.2000008]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [100, 100, 100]
|
||||
- ID: 6
|
||||
Name: Cube Yay 6
|
||||
Components:
|
||||
Transform:
|
||||
Position: [-6.5, -6, -18]
|
||||
Rotation: [15.8000002, -18.2000008, -11.1000004]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 3
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 7
|
||||
Name: Cube Yay 7
|
||||
Components:
|
||||
Transform:
|
||||
Position: [6.5, 1.79999995, -23.8999996]
|
||||
Rotation: [-16.1000004, -15.8999996, -35]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 4
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 8
|
||||
Name: Cube Yay 8
|
||||
Components:
|
||||
Transform:
|
||||
Position: [-7.80000019, 0.200000003, -29.7999992]
|
||||
Rotation: [22.2999992, -32.7999992, 0]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 1
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 9
|
||||
Name: Cube Yay 9
|
||||
Components:
|
||||
Transform:
|
||||
Position: [5.5, -2.9000001, -19.5]
|
||||
Rotation: [-41.4000015, -22.6000004, -52.2999992]
|
||||
Scale: [1, 1, 1]
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 2
|
||||
MeshPath: assets/models/DefaultMesh.obj
|
||||
- ID: 10
|
||||
Name: Script
|
||||
Components:
|
||||
ScriptComponent:
|
||||
ScriptPath: assets/scripts/script.lua
|
@ -18,7 +18,7 @@ int lua_log_message(lua_State *L);
|
||||
|
||||
|
||||
|
||||
LuaManager::LuaManager() : L(nullptr) {}
|
||||
LuaManager::LuaManager() : L(nullptr), m_firstCall(false) {}
|
||||
|
||||
LuaManager::~LuaManager()
|
||||
{
|
||||
@ -55,7 +55,7 @@ bool LuaManager::init(const std::string &scriptPath)
|
||||
L = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
callLuaFunction("OnInit");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -96,6 +96,8 @@ bool LuaManager::onUpdate(float deltaTime)
|
||||
// Push the deltaTime argument
|
||||
lua_pushnumber(L, deltaTime);
|
||||
|
||||
m_firstCall = true;
|
||||
|
||||
// Call the function with 1 argument and 0 return values
|
||||
if (lua_pcall(L, 1, 0, 0) != LUA_OK)
|
||||
{
|
||||
@ -135,7 +137,9 @@ bool LuaManager::onUpdate(float deltaTime)
|
||||
|
||||
|
||||
lua_pop(L, 1); // Remove error message
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -22,7 +22,9 @@ public:
|
||||
|
||||
private:
|
||||
lua_State* L;
|
||||
std::string m_LastErrorMessage; // Stores the last error message
|
||||
std::string m_LastErrorMessage; // Stores the last error message
|
||||
|
||||
bool m_firstCall;
|
||||
|
||||
|
||||
// Helper function to call a Lua function with no arguments and no return values
|
||||
|
@ -9,6 +9,9 @@
|
||||
extern std::vector<GameObject> g_GameObjects;
|
||||
extern GameObject *g_SelectedObject; // Pointer to the currently selected object
|
||||
|
||||
extern LoggerWindow *g_LoggerWindow;
|
||||
|
||||
|
||||
void InspectorWindow::Show()
|
||||
{
|
||||
// Increase window/item spacing for a cleaner look
|
||||
@ -79,7 +82,6 @@ void InspectorWindow::Show()
|
||||
std::shared_ptr<MeshComponent> mesh = g_SelectedObject->GetComponent<MeshComponent>();
|
||||
std::shared_ptr<ScriptComponent> script = g_SelectedObject->GetComponent<ScriptComponent>();
|
||||
|
||||
|
||||
// Color the Transform header
|
||||
|
||||
if (transform && g_SelectedObject) // Funny: I did not put a null check here and it broke everything.
|
||||
@ -350,7 +352,6 @@ void InspectorWindow::Show()
|
||||
bool scriptOpen = ImGui::CollapsingHeader("Script##Main", ImGuiTreeNodeFlags_DefaultOpen);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
|
||||
// printf("%p\n", &transform);
|
||||
if (scriptOpen)
|
||||
{
|
||||
@ -367,6 +368,11 @@ void InspectorWindow::Show()
|
||||
script->ScriptPath = buffer;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Reload Script"))
|
||||
{
|
||||
script->Initialize();
|
||||
g_LoggerWindow->AddLog("Reloaded Script: %s", ImVec4(0.0f,1.0f,0.0f,1.0f), script->ScriptPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user