diff --git a/luau/tests/RobloxSandbox.lua b/luau/tests/RobloxSandbox.lua new file mode 100644 index 0000000..6f78d91 --- /dev/null +++ b/luau/tests/RobloxSandbox.lua @@ -0,0 +1,52 @@ +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 \ No newline at end of file