Page 1 of 1

Simulating LUA console inside love?

Posted: Sun Mar 02, 2014 12:09 pm
by SniX
So i guess i wrote inside the wrong forum, so is there a way to simulate LUA console inside love. With some instructions please.

Re: Simulating LUA console inside love?

Posted: Sun Mar 02, 2014 12:23 pm
by Ranguna259
What I said on your other post:
Ranguna259 wrote:You can do that by using the pcall or the xpcall lua functions.

Re: Simulating LUA console inside love?

Posted: Sun Mar 02, 2014 12:40 pm
by SniX
So on previous post a guy posted about pcall and xpcall, im starting to understand what he meant, still, any help will be appretiated.
For how i understood i ask for human input, then call a function with it, right?

Re: Simulating LUA console inside love?

Posted: Sun Mar 02, 2014 12:48 pm
by Ranguna259
The other guy was me :P

Here's an exemple (you'll aslo need to use loadstring):

Code: Select all

f, err = loadstring(input)
if f then
  f, err = pcall(f)
end
if not f then
  print('error: '..err)
else
  print('Code ran successfully')
end
or

Code: Select all

f, err = loadstring(input)
if f then
  f = xpcall(f, function(err) print('error: '..err) end)
end
if f then
  print('Code ran successfully')
end
That's how LoveDebug does it.