strafe-client/luau/tests/RobloxSandbox.lua

52 lines
1.2 KiB
Lua
Raw Normal View History

2024-01-23 04:28:21 +00:00
type workspace = {[string]: {number}}
type Service = {}
export type exports = {[string]: {workspace | number | {}}}
local workspace: workspace = {}
local RS = {
RenderStepped = {},
Stepped = {},
Heartbeat = {}
}
local game = setmetatable({
Workspace = workspace,
Players = {},
RunService = RS
}, {
__index = function(self,i)
return rawget(self,i)
end,
__newindex = function(self,i,_)
--Roblox actually does this
local t = type(i)
return t == "Object" and "Unable to assign property Game. Property is read only" or `Unable to assign property Game. Object expected, got {t}`
end,
__metatable = "This metatable is locked."
})
function game:GetService(service: string): Service
return self[service]
end
function game:service(service: string): Service
return self:GetService(service)
end
function game:FindService(service: string): boolean | Service
return self[service] and self[service]
end
local tick = os.clock() --just be better (Roblox wants you to use this instead of "tick" anyways because of Wine)
local task = {
wait = {},
delay = {},
defer = {}
}
local exports: exports = {
game = game, Game = game,
workspace = workspace, Workspace = workspace,
tick = tick,
task = task
}
return exports