forked from Bastion/Bastion
parent
1a796811bc
commit
6a87afca61
@ -0,0 +1,127 @@ |
||||
---@type Tinkr |
||||
local Tinkr, |
||||
---@class Bastion |
||||
Bastion = ... |
||||
|
||||
local Class = Tinkr.Util.Class |
||||
|
||||
---@class Bastion.Object |
||||
---@field unit WowGameObject |
||||
local Object = {} |
||||
|
||||
function Object:__index(k) |
||||
if k == "unit" then |
||||
return rawget(self, k) |
||||
end |
||||
|
||||
local response = Bastion.ClassMagic:Resolve(Object, k) |
||||
|
||||
if response == nil then |
||||
response = rawget(self, k) |
||||
end |
||||
|
||||
if response == nil then |
||||
error("Object:__index: " .. k .. " does not exist") |
||||
end |
||||
|
||||
return response |
||||
end |
||||
|
||||
---@param unit WowGameObject |
||||
function Object:New(unit) |
||||
---@class Bastion.Object |
||||
local self = setmetatable({ unit = unit }, Object) |
||||
return self |
||||
end |
||||
|
||||
function Object:Creator() |
||||
return self.unit:creator() |
||||
end |
||||
|
||||
function Object:Distance(target) |
||||
return self.unit:distance(target) |
||||
end |
||||
|
||||
function Object:Flags() |
||||
return self.unit:flags() |
||||
end |
||||
|
||||
function Object:GameObjectType() |
||||
return self.unit:gameObjectType() |
||||
end |
||||
|
||||
function Object:Guid() |
||||
return self.unit:guid() |
||||
end |
||||
|
||||
function Object:Hash() |
||||
return self.unit:hash() |
||||
end |
||||
|
||||
function Object:Height() |
||||
return self.unit:height() |
||||
end |
||||
|
||||
function Object:Id() |
||||
return self.unit:id() |
||||
end |
||||
|
||||
function Object:IsOutdoors() |
||||
return self.unit:isOutdoors() |
||||
end |
||||
|
||||
function Object:IsSubmerged() |
||||
return self.unit:isSubmerged() |
||||
end |
||||
|
||||
function Object:Lootable() |
||||
return self.unit:lootable() |
||||
end |
||||
|
||||
function Object:ModelID() |
||||
return self.unit:modelID() |
||||
end |
||||
|
||||
function Object:MovementFlag() |
||||
return self.unit:movementFlag() |
||||
end |
||||
|
||||
function Object:Mover() |
||||
return self.unit:mover() |
||||
end |
||||
|
||||
function Object:Name() |
||||
return self.unit:name() |
||||
end |
||||
|
||||
function Object:RawPosition() |
||||
return self.unit:rawPosition() |
||||
end |
||||
|
||||
function Object:Position() |
||||
return self.unit:position() |
||||
end |
||||
|
||||
function Object:WorldPosition() |
||||
return self.unit:worldPosition() |
||||
end |
||||
|
||||
function Object:RawRotation() |
||||
return self.unit:rawRotation() |
||||
end |
||||
|
||||
function Object:Rotation() |
||||
return self.unit:rotation() |
||||
end |
||||
|
||||
function Object:RightClick() |
||||
return self.unit:rightClick() |
||||
end |
||||
|
||||
function Object:Sparkling() |
||||
return self.unit:sparkling() |
||||
end |
||||
|
||||
function Object:Type() |
||||
return self.unit:type() |
||||
end |
@ -1,4 +1,65 @@ |
||||
---@type Tinkr |
||||
local Tinkr = ... |
||||
|
||||
---@param path string |
||||
---@param ...? any |
||||
local function require(path, ...) |
||||
local func = nil |
||||
local newPath = path |
||||
local loader = nil |
||||
if newPath:sub(-4) ~= ".lua" and newPath:sub(-5) ~= ".luac" then |
||||
if FileExists(newPath .. ".lua") then |
||||
newPath = newPath .. ".lua" |
||||
elseif FileExists(newPath .. ".luac") then |
||||
newPath = newPath .. ".luac" |
||||
else |
||||
Tinkr:OnError(string.format("File not found: path(%s) newPath(%s)", path, newPath), -1) |
||||
return |
||||
end |
||||
end |
||||
|
||||
if newPath:sub(-4) == ".lua" then |
||||
func = loadstringsecure(ReadFile(newPath) or "", newPath) |
||||
elseif newPath:sub(-5) == ".luac" then |
||||
func = RunEncrypted(newPath) |
||||
else |
||||
Tinkr:OnError(string.format("Loader not found: path(%s) newPath(%s)", path, newPath), -1) |
||||
return |
||||
end |
||||
if type(func) == "string" then |
||||
if type(func) == "string" then |
||||
Tinkr:OnError(string.format("Loader did not return function: path(%s) newPath(%s) error(%s)", path, newPath, func or ""), -1) |
||||
return |
||||
end |
||||
end |
||||
setfenv(func, setmetatable({ ["_T"] = _T }, { |
||||
__index = function(t, v) |
||||
if v == "require" then |
||||
--print(v, t.__file) |
||||
return function(...) |
||||
return require(...) |
||||
end |
||||
end |
||||
if v == '__file' then |
||||
--print(v, newPath) |
||||
return path |
||||
end |
||||
if v == 'TINKR_SECURE' then |
||||
--print(v, t.__file, issecure(), Tinkr:GetSecure()) |
||||
return Tinkr:GetSecure() |
||||
end |
||||
return Tinkr.__ENV(t, v) |
||||
end |
||||
})) |
||||
|
||||
local call = { pcall(func, Tinkr, ...) } |
||||
-- print('call', call[1], call[2]) |
||||
if not call[1] then |
||||
-- print(self:OnLoadingScreen()) |
||||
Tinkr:OnError(call[2], -1) |
||||
end |
||||
table.remove(call, 1) |
||||
|
||||
return unpack(call) |
||||
end |
||||
require("scripts/bastion/src/Bastion/Bastion"):Load() |
||||
|
Loading…
Reference in new issue