Simulating LUA console inside love?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
SniX
Prole
Posts: 24
Joined: Mon Aug 26, 2013 10:18 am

Simulating LUA console inside love?

Post 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.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Simulating LUA console inside love?

Post by Ranguna259 »

What I said on your other post:
Ranguna259 wrote:You can do that by using the pcall or the xpcall lua functions.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
SniX
Prole
Posts: 24
Joined: Mon Aug 26, 2013 10:18 am

Re: Simulating LUA console inside love?

Post 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?
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Simulating LUA console inside love?

Post 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.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 12 guests