Tesseract-Engine/assets/scripts/script.lua

69 lines
1.9 KiB
Lua
Raw Normal View History

2024-12-27 21:27:05 +00:00
-- script.lua
2025-01-03 20:57:22 +00:00
local Engine = require("engine")
2024-12-28 18:07:06 +00:00
2024-12-28 03:43:17 +00:00
local new_rotation = 0
local speed = 50
2024-12-27 21:27:05 +00:00
function OnInit()
-- Log a message with a custom red color
Engine.Log("This is a red message.", {1.0, 0.0, 0.0, 1.0})
-- Log a message with a custom green color
Engine.Log("This is a green message.", {0.0, 1.0, 0.0, 1.0})
-- Log a message with a custom blue color
Engine.Log("This is a blue message.", {0.0, 0.0, 1.0, 1.0})
2024-12-27 21:27:05 +00:00
end
function OnUpdate(deltaTime)
2024-12-27 22:15:40 +00:00
2024-12-28 03:43:17 +00:00
-- Attempt to retrieve the GameObject with the tag "Player"
local player = Engine.GetGameObjectByTag("Player")
if player ~= nil then
-- Successfully retrieved the GameObject
-- Call the GetName method on the GameObject
local transform = player:GetComponent("Transform")
2024-12-27 21:27:05 +00:00
2024-12-28 03:43:17 +00:00
-- Log the player's name with a white color
2024-12-28 18:56:06 +00:00
-- local pos = transform:GetRotation()
2024-12-28 03:43:17 +00:00
-- local x = string.format("%.2f", pos.x)
-- local y = string.format("%.2f", pos.y)
-- local z = string.format("%.2f", pos.z)
2024-12-28 18:56:06 +00:00
-- Engine.Log("Player Rot: (" .. x .. ", " .. y .. ", " .. z .. ")", {1, 1, 1, 1})
2024-12-27 22:15:40 +00:00
2024-12-28 03:43:17 +00:00
--local position = {x = 0.0, y = 2.0, z = -12.0} -- Define the new position
--transform:SetPosition(position) -- Call the SetPosition method
new_rotation = new_rotation + (deltaTime*speed)
if (new_rotation > 720) then
new_rotation = 0
end
2024-12-28 18:56:06 +00:00
local rotation = {x = new_rotation, y = new_rotation, z = new_rotation,} -- Define the new position
2024-12-28 03:43:17 +00:00
transform:SetRotation(rotation) -- Call the SetPosition method
-- (Optional) Perform additional operations on the player GameObject
-- For example, you might want to move the player, change properties, etc.
-- player:Move(newPosition)
-- player:SetHealth(100)
end
2024-12-27 22:15:40 +00:00
2024-12-27 21:27:05 +00:00
end