Page 1 of 2
ZeroBrane Studio Love API updated for 0.9.0
Posted: Wed Dec 25, 2013 1:41 am
by paulclinger
Hi All,
I updated
ZeroBrane Studio Love API for 0.9.0; thanks to Santos for keeping his
love_api.lua script up-to-date. This update will be included in the next version of ZBS (0.41), but those who want to use it right now, can grab the
current version from github; as an alternative, you can update api/lua/love2d.lua file in your installation to use the new API. The updated API is used for both auto-complete and tooltips with descriptions. Please let me know if you notice any issues with the update.
Paul.
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Wed Dec 25, 2013 8:50 am
by MadByte
Thanks! The auto - completion does work great so far.
But still it looks like the Scratchpad feature ( changing variables while the program is running ) doesn't work for me with the GitHub version.
Anything I need to know about that ? The video make it look like I didn't have to prepare my code in any form for that.
Happy Holidays.
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Wed Dec 25, 2013 7:07 pm
by paulclinger
Hi MadByte,
> But still it looks like the Scratchpad feature ( changing variables while the program is running ) doesn't work for me with the GitHub version.
> Anything I need to know about that ? The video make it look like I didn't have to prepare my code in any form for that.
I tested with the current version of Love and with the latest version of ZBS (the one you are using) and the scratchpad appearsto be working as expected. You may need to re-structure your code a bit as only changes to global variables are going to be "noted"; you are not limited to just variable changes and can change anything in your code, but only changes to functions called from draw() and update() functions will be visible.
I suggest you look at love2d samples that ship with ZeroBrane Studio (they are also available as
ZeroBrane EduPack); for example, "ZeroBraneEduPack/love2d-samples/trajectory" example includes lovedraw and loveupdate functions and any changes to those functions will be seen immediately when running as scratchpad.
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 2:08 am
by paulclinger
@MadByte, did you get the scratchpad working for you?
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 8:43 am
by MadByte
No, I tried it with your trajectory demo ( I had to change one small thing [ arg to ... ; local arg = {...} ]) but even with this one it does not work the way you showed it in your video.
If needed I make a video showing my steps, but I'm pretty sure I do it right.
Is there any additional software I have to install to make it work?
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 11:26 am
by riidom
Hi,
if your changes refer to
Code: Select all
function love.load(arg)
if arg and arg[#arg] == "-debug" then require("mobdebug").start() end
end
then this shouldn't be changed, because the "new" arg is for storing commandline parameters, and in this case it is not the "old version" of ...
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 1:59 pm
by MadByte
riidom wrote:Hi,
if your changes refer to
Code: Select all
function love.load(arg)
if arg and arg[#arg] == "-debug" then require("mobdebug").start() end
end
then this shouldn't be changed, because the "new" arg is for storing commandline parameters, and in this case it is not the "old version" of ...
Thanks for clearing that up.
My problem is, without changing arg to ... the whole program freezes for me and I have to close it using the windows task manager. I don't know what exactly the problem is and to be honest I'm a bit confused by these "arg / ..." stuff. So, what can causes the freezing for me ?
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 2:06 pm
by slime
MadByte wrote:I'm a bit confused by these "arg / ..." stuff.
"arg" is a global table which holds the command-line arguments given to LÖVE when it was launched.
"..." is the vararg expression: it's used for a variable amount of arguments. You can use it like this:
Code: Select all
function foo(...)
local a, b = ...
return a + b
end
function bar(baz, ...)
local t = {...}
print(#t)
return baz
end
print(foo(3, 4))
x = bar(10, "a", "b", "c", "d")
In Lua 5.0, a local table named 'arg' was also implicitly created whenever the var-arg expression was used as a function argument, however Lua 5.1 (which was first released in 2006) deprecated this concept.
Unfortunately the official online version of the Programming in Lua book is the first edition which was written for Lua 5.0, so it contains outdated information on this topic.
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 2:33 pm
by MadByte
Thanks slime.
I got it working now. I realized that this demo obviously won't run in normal mode and causes the window to freeze. When running it in scratchpad mode it does work and I can see the live changes.
Re: ZeroBrane Studio Love API updated for 0.9.0
Posted: Sat Dec 28, 2013 8:09 pm
by paulclinger
MadByte,
> I got it working now. I realized that this demo obviously won't run in normal mode and causes the window to freeze.
> When running it in scratchpad mode it does work and I can see the live changes.
Glad you got it working. It should work the same way in normal mode and in scratchpad because "arg" in this case is a local parameter for love.load (which indeed gets the parameters passed from the command line).
One reason why it may freeze is that conf.lua for that project uses c.screen instead of c.window (as it's now called in 0.9.0), which causes a run-time error. I already made the change in the example, but noticed it too late for it to be packaged with ZBS 0.40. The current code in conf.lua looks like this:
Code: Select all
function love.conf(c)
c.title = "Trajectory"
local window = c.screen or c.window -- love 0.9 renamed "screen" to "window"
window.width = 1024
window.height = 660
end