Hello,
I'm trying to set up Zerobrane for live coding with Gideros player (not mobile player, just IDE player).
I can make Zerobrane show my main.lua code in the Gideros player (just a ball image), but it does not update live when I change the x and y position using the slider system...
Here is my main.lua code (the only file except the gproject file and ball.png):
require("mobdebug").start()
local fruit = Bitmap.new(Texture.new("ball.png"))
stage:addChild(fruit)
function onEnterFrame(event)
fruit:setX(78)
fruit:setY(170)
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
I have chosen the project->interpreter as Gideros and I am just choosing "run as scratchpad" and nothing else when I run it.
Any idea what is going wrong?
Also, do I need to require any special files when doing live coding? I just have main.lua...
Is the require("mobdebug").start() necessary to do livecoding? I just have main.lua in my folder...do I need a mobdebug file?
Comments
My apps: http://www.yummyyellow.com
When you run a file as scratchpad in ZBS, then each time you type a character the whole file is compiled and (if the compile is successful) it is sent to the player to be executed. If you look at my example in Twenty Minutes to Awesome, you'll see that the project is split into more than one file. The require("mobdebug").start() line is in main.lua and this is only ever executed one because it is not the file being used as the scratchpad.
An alternative, if you just want to use a single file, would be to wrap code that must only execute once in a guard clause:
best regards
Something like this should work:
http://blog.magnusviri.com/gideros-downloader.html
Basically instead of having an IDE send the compiled file, my Gideros app actually downloads the desired file(s) repeatedly from a url (in this case, Dropbox). I have to wrap some of the code in a first time block so that it doesn't get executed over and over. Look at the very bottom of the blog post to see an example. It's pretty confusing and so I don't really code like this, I just restart my app.
My apps: http://www.yummyyellow.com
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
1. Isolate your initialization code to make it run once; add your addEventListener calls to this initialization code
2. Use globals for objects you want to keep between restarts as in: fruit = fruit or Bitmap.new(Texture.new("ball.png")) or BhLiveCode = BhLiveCode or Core.class(Sprite)
3. Wrap callback functions into an anonymous function to allow it to change as in: stage:addEventListener(Event.ENTER_FRAME, function(...) onEnterFrame(...) end)
4. Use pcall to "protect" from run-time errors in event handlers as in: stage:addEventListener(Event.ENTER_FRAME, function(...) pcall(onEnterFrame, ...) end)
@bowerandy and @atilim, anything else you want to add?
In my Live Coding demo, you probably saw that I had added a RestartRequired button to the screen. I would imagine that something like this would also be a part of the framework. I haven't decided yet what format all this will take but my intention will certainly be to make it more beginner (or child) friendly in future.
best regards
Likes: Platypus
@bowerandy, I'm with you 100% on this.
Likes: Platypus
require("mobdebug").start("Android's IP")
but the player windows still opens on the computer and not the phone.
Any thoughts?
Thanks.
1. Start the Gideros player player on your device
2. Add (or modify) 'require("mobdebug").start("PC with ZeroBrane Studio IP")' (not Android's IP)
3. Start ZBS and start the debugger server ('Projects | Start Debugger Server')
4. Deploy and run the application from Gideros Studio
5. You should now see the green arrow in ZBS and can debug as before.
I remember @boverandy described this process he worked through in one of his comments, but can't find it right now.
We've also discussed adding a hint for ZBS in the form of:
require("mobdebug").start("PC with ZeroBrane Studio IP") -- remote IP (in this case Android's IP)
but it hasn't been implemented yet.
Likes: skaflux
I have a problem here when I am using the scratchpad in ZBS for Android but its not updating the running program.
I have sincerely followed every step in @boverandy tutorial.
i.e.,
1. Start the Gideros player player on your device
2. Add (or modify) 'require("mobdebug").start("PC with ZeroBrane Studio IP")' (not Android's IP)
3. Start ZBS and start the debugger server ('Projects | Start Debugger Server')
4. Deploy and run the application from Gideros Studio
5. You should now see the green arrow in ZBS and can debug as before.
Please help!