add more errors for dumb things happening
This commit is contained in:
parent
fc97481a02
commit
8262b62e4c
22
main.xml
22
main.xml
|
@ -175,6 +175,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
local actorsInitialized = false -- if true, no new actors can be created
|
local actorsInitialized = false -- if true, no new actors can be created
|
||||||
|
local actorsInitializing = false -- the above but a bit more explicit
|
||||||
|
|
||||||
local luaobj
|
local luaobj
|
||||||
|
|
||||||
|
@ -205,6 +206,7 @@
|
||||||
|
|
||||||
local function onCommand(self)
|
local function onCommand(self)
|
||||||
actorsInitialized = true
|
actorsInitialized = true
|
||||||
|
actorsInitializing = false
|
||||||
uranium:call('init')
|
uranium:call('init')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -249,6 +251,9 @@
|
||||||
local specialActorFrames = {} -- ones defined specifically; here for drawfunction jank
|
local specialActorFrames = {} -- ones defined specifically; here for drawfunction jank
|
||||||
|
|
||||||
function setDrawFunction(frame, func)
|
function setDrawFunction(frame, func)
|
||||||
|
if not frame.__raw then error('uranium: cannot set actorframe drawfunction during module loadtime! put this in uranium.init or actor:addcommand(\'Init\', ...)', 2) end
|
||||||
|
if not frame.SetDrawFunction then error('uranium: expected an actorframe but got something that doesn\'t even bother to implement SetDrawFunction', 2) end
|
||||||
|
if type(func) ~= 'function' then error('uranium: tried to set a drawfunction to a.. ' .. type(func) .. '?? the hell', 2) end
|
||||||
frame:SetDrawFunction(function()
|
frame:SetDrawFunction(function()
|
||||||
for i = 1, frame:GetNumChildren() do
|
for i = 1, frame:GetNumChildren() do
|
||||||
local a = frame:GetChildAt(i - 1)
|
local a = frame:GetChildAt(i - 1)
|
||||||
|
@ -262,6 +267,7 @@
|
||||||
|
|
||||||
function setShader(actor, shader)
|
function setShader(actor, shader)
|
||||||
if not shader.__raw then error('uranium: cannot set shader during module loadtime! put this in uranium.init or actor:addcommand(\'Init\', ...)', 2) end
|
if not shader.__raw then error('uranium: cannot set shader during module loadtime! put this in uranium.init or actor:addcommand(\'Init\', ...)', 2) end
|
||||||
|
if not actor.__raw then error('uranium: cannot set shader while the actor hasn\'t been loaded!', 2) end
|
||||||
actor:SetShader(shader.__raw)
|
actor:SetShader(shader.__raw)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -488,6 +494,7 @@
|
||||||
|
|
||||||
local function createGenericFunc(type)
|
local function createGenericFunc(type)
|
||||||
return function()
|
return function()
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
local actor = createProxyActor(type)
|
local actor = createProxyActor(type)
|
||||||
table.insert(actorQueue, {
|
table.insert(actorQueue, {
|
||||||
|
@ -507,6 +514,7 @@
|
||||||
ActorFrameTexture = createGenericFunc('ActorFrameTexture')
|
ActorFrameTexture = createGenericFunc('ActorFrameTexture')
|
||||||
|
|
||||||
function Sprite(file)
|
function Sprite(file)
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
--if not file then error('uranium: cannot create a Sprite without a file', 2) end
|
--if not file then error('uranium: cannot create a Sprite without a file', 2) end
|
||||||
local actor = createProxyActor('Sprite')
|
local actor = createProxyActor('Sprite')
|
||||||
|
@ -524,6 +532,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActorFrame()
|
function ActorFrame()
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
local actor = createProxyActor('ActorFrame')
|
local actor = createProxyActor('ActorFrame')
|
||||||
table.insert(actorQueue, {
|
table.insert(actorQueue, {
|
||||||
|
@ -541,6 +550,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function Shader(frag, vert)
|
function Shader(frag, vert)
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
local actor = createProxyActor('RageShaderProgram')
|
local actor = createProxyActor('RageShaderProgram')
|
||||||
|
|
||||||
|
@ -576,6 +586,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function Model(file)
|
function Model(file)
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
if not file then error('uranium: cannot create a Model without a file', 2) end
|
if not file then error('uranium: cannot create a Model without a file', 2) end
|
||||||
local actor = createProxyActor('Model')
|
local actor = createProxyActor('Model')
|
||||||
|
@ -591,6 +602,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function BitmapText(font, text)
|
function BitmapText(font, text)
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
local actor = createProxyActor('BitmapText')
|
local actor = createProxyActor('BitmapText')
|
||||||
table.insert(actorQueue, {
|
table.insert(actorQueue, {
|
||||||
|
@ -606,6 +618,7 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActorSound(file)
|
function ActorSound(file)
|
||||||
|
if actorsInitializing then error('uranium: cannot create an actor during actor initialization!!', 2) end
|
||||||
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
if not file then error('uranium: cannot create an ActorSound without a file', 2) end
|
if not file then error('uranium: cannot create an ActorSound without a file', 2) end
|
||||||
local actor = createProxyActor('ActorSound')
|
local actor = createProxyActor('ActorSound')
|
||||||
|
@ -621,11 +634,17 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
function addChild(frame, actor)
|
function addChild(frame, actor)
|
||||||
|
if actorsInitializing then
|
||||||
|
error('uranium: cannot create frame-child associations during actor initialization', 2)
|
||||||
|
end
|
||||||
|
if actorsInitialized then
|
||||||
|
error('uranium: cannot create frame-child associations after actors have been initialized', 2)
|
||||||
|
end
|
||||||
if not frame.__lock then
|
if not frame.__lock then
|
||||||
error('uranium: ActorFrame passed into addChild must be one instantiated with ActorFrame()!', 2)
|
error('uranium: ActorFrame passed into addChild must be one instantiated with ActorFrame()!', 2)
|
||||||
end
|
end
|
||||||
if not actor.__lock then
|
if not actor.__lock then
|
||||||
error('uranium: trying to add a child to an ActorFrame that isn\'t an actor; please read the first half of "ActorFrame"', 2)
|
error('uranium: trying to add a child to an ActorFrame that isn\'t an actor; please read the first half of \'ActorFrame\'', 2)
|
||||||
end
|
end
|
||||||
actorAssociationQueue[actor.__queue] = frame.__queue
|
actorAssociationQueue[actor.__queue] = frame.__queue
|
||||||
end
|
end
|
||||||
|
@ -740,6 +759,7 @@
|
||||||
|
|
||||||
print('---')
|
print('---')
|
||||||
|
|
||||||
|
actorsInitializing = true
|
||||||
transformQueueToTree()
|
transformQueueToTree()
|
||||||
--Trace(fullDump(actorTree))
|
--Trace(fullDump(actorTree))
|
||||||
currentPath = actorTree
|
currentPath = actorTree
|
||||||
|
|
Loading…
Reference in New Issue