mirror of
https://github.com/usysrc/LICK.git
synced 2024-11-16 09:34:22 +00:00
4 spaces indentation
This commit is contained in:
parent
fb9319c889
commit
5449f2f33a
143
lick.lua
143
lick.lua
@ -21,104 +21,109 @@ local function load()
|
||||
end
|
||||
|
||||
local function update(dt)
|
||||
if love.filesystem.exists(lick.file) and last_modified < love.filesystem.getLastModified(lick.file) then
|
||||
last_modified = love.filesystem.getLastModified(lick.file)
|
||||
success, chunk = pcall(love.filesystem.load, lick.file)
|
||||
if not success then
|
||||
print(tostring(chunk))
|
||||
lick.debugoutput = chunk .. "\n"
|
||||
end
|
||||
ok,err = xpcall(chunk, handle)
|
||||
if love.filesystem.exists(lick.file) and last_modified < love.filesystem.getLastModified(lick.file) then
|
||||
last_modified = love.filesystem.getLastModified(lick.file)
|
||||
success, chunk = pcall(love.filesystem.load, lick.file)
|
||||
if not success then
|
||||
print(tostring(chunk))
|
||||
lick.debugoutput = chunk .. "\n"
|
||||
end
|
||||
ok,err = xpcall(chunk, handle)
|
||||
|
||||
if not ok then
|
||||
print(tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else lick.debugoutput = err .. "\n" end
|
||||
else
|
||||
print("CHUNK LOADED\n")
|
||||
lick.debugoutput = nil
|
||||
if not ok then
|
||||
print(tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else
|
||||
lick.debugoutput = err .. "\n"
|
||||
end
|
||||
else
|
||||
print("CHUNK LOADED\n")
|
||||
lick.debugoutput = nil
|
||||
end
|
||||
if lick.reset then
|
||||
loadok, err = xpcall(love.load, handle)
|
||||
if not loadok and not loadok_old then
|
||||
print("ERROR: "..tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else
|
||||
lick.debugoutput = err .. "\n"
|
||||
end
|
||||
loadok_old = not loadok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if lick.reset then
|
||||
loadok, err = xpcall(love.load, handle)
|
||||
if not loadok and not loadok_old then
|
||||
updateok, err = pcall(love.update,dt)
|
||||
if not updateok and not updateok_old then
|
||||
print("ERROR: "..tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else
|
||||
lick.debugoutput = err .. "\n"
|
||||
end
|
||||
loadok_old = not loadok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
updateok, err = pcall(love.update,dt)
|
||||
if not updateok and not updateok_old then
|
||||
print("ERROR: "..tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else lick.debugoutput = err .. "\n" end
|
||||
lick.debugoutput = (lick.debugoutput .."ERROR: ".. err .. "\n" )
|
||||
else
|
||||
lick.debugoutput = err .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
updateok_old = not updateok
|
||||
end
|
||||
|
||||
local function draw()
|
||||
drawok, err = xpcall(love.draw, handle)
|
||||
if not drawok and not drawok_old then
|
||||
print(tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .. err .. "\n" )
|
||||
else lick.debugoutput = err .. "\n" end
|
||||
end
|
||||
drawok, err = xpcall(love.draw, handle)
|
||||
if not drawok and not drawok_old then
|
||||
print(tostring(err))
|
||||
if lick.debugoutput then
|
||||
lick.debugoutput = (lick.debugoutput .. err .. "\n" )
|
||||
else
|
||||
lick.debugoutput = err .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
if lick.debug and lick.debugoutput then
|
||||
love.graphics.setColor(255,255,255,120)
|
||||
love.graphics.printf(lick.debugoutput, (love.graphics.getWidth()/2)+50, 0, 400, "right")
|
||||
end
|
||||
drawok_old = not drawok
|
||||
if lick.debug and lick.debugoutput then
|
||||
love.graphics.setColor(255,255,255,120)
|
||||
love.graphics.printf(lick.debugoutput, (love.graphics.getWidth()/2)+50, 0, 400, "right")
|
||||
end
|
||||
drawok_old = not drawok
|
||||
end
|
||||
|
||||
|
||||
function love.run()
|
||||
math.randomseed(os.time())
|
||||
math.random() math.random()
|
||||
load()
|
||||
math.randomseed(os.time())
|
||||
math.random() math.random()
|
||||
load()
|
||||
|
||||
local dt = 0
|
||||
local dt = 0
|
||||
|
||||
-- Main loop time.
|
||||
while true do
|
||||
-- Process events.
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
-- Main loop time.
|
||||
while true do
|
||||
-- Process events.
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
|
||||
-- Update dt, as we'll be passing it to update
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
|
||||
-- Call update and draw
|
||||
if update then update(dt) end -- will pass 0 if love.timer is disabled
|
||||
if love.graphics then
|
||||
love.graphics.clear()
|
||||
if draw then draw() end
|
||||
love.graphics.clear()
|
||||
if draw then draw() end
|
||||
end
|
||||
|
||||
if love.timer then love.timer.sleep(0.001) end
|
||||
|
Loading…
Reference in New Issue
Block a user