Commit 37c0b5b9 by Phil Hagelberg

Fix console printing of return values.

parent c7b2e169
......@@ -22,7 +22,7 @@ bind("console", "return", function()
ship.editor.end_of_line()
ship.editor.newline()
local chunk, err = loadstring("return " .. input)
if(err and not chunk) then
if(err and not chunk) then -- statement, not expression
chunk, err = loadstring(input)
if(not chunk) then
print("! Compilation error: " .. err or "Unknown error")
......@@ -36,16 +36,16 @@ bind("console", "return", function()
trace = debug.traceback()
err = e end))
if(result[1]) then
local results, i = pps(result[2]), 3
local output, i = pps(result[2]), 3
if result[2] == ship.editor.invisible then
ship.editor.print_prompt()
return true
end
while i <= #result do
results = results .. ', ' .. pp(result[i])
output = output .. ', ' .. pps(result[i])
i = i + 1
end
print(results)
print(output)
else
realprint('! Evaluation error: ' .. err or "Unknown")
local lines = lume.split(trace, "\n")
......
......@@ -10,8 +10,7 @@
fail (lambda (message)
(print message)
(set_beams nil)
(print failure)
(disconnect))
(print failure))
init-time (os.time)
looper (lambda (last-time looper)
(coroutine.yield)
......
......@@ -143,7 +143,7 @@ local sandbox = function(ship)
reply = lume.fn(mail.reply, ship),
replyable = mail.replyable,
graphics = love.graphics,
pps = function(x) serpent.block(x, serpent_opts) end,
pps = function(x) return serpent.block(x, serpent_opts) end,
pp = function(x)
editor.print(serpent.block(x, serpent_opts)) end,
})
......@@ -259,8 +259,6 @@ local ship = {
-- activate controls
local current_mode = ship.api:mode()
-- TODO: this fires the laser when opening files with alt-o
-- if laser is bound to alt
if(current_mode and current_mode.name == "flight") then
for k,f in pairs(ship.api.controls) do
with_traceback(f, love.keyboard.isDown(k))
......@@ -275,7 +273,6 @@ local ship = {
-- the engine arbitrarily powerful or use zero fuel or
-- whatever. so these two steps must remain separate.
if(ship.engine_on and ship.fuel > 0) then
-- TODO: move to an upgrade
local fx = (math.sin(ship.heading) * dt * ship.engine_strength)
local fy = (math.cos(ship.heading) * dt * ship.engine_strength)
ship.dx = ship.dx + fx / ship.mass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment