Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Is it possible to have a "console" and execute code like something:setPosition() while running? — Gideros Forum

Is it possible to have a "console" and execute code like something:setPosition() while running?

cokeramirezcokeramirez Member
edited February 2015 in General questions
Something like the javascript console on Chrome where I could write a line of code and get it executed in the player?

I've seen the ZeroBrane examples, but there are a little too much to me (live coding)

Thanks!

Comments

  • piepie Member
    Accepted Answer
    @cokeramirez the only "readymade" way is zerobrane live coding. :)
    As an alternative, you could write your own code that reads vars from a json and update the position of your object accordingly.. but I think it's not worth the effort. :)
  • keszeghkeszegh Member
    edited February 2015 Accepted Answer
    @cokeramirez, if you don't mind pausing the app for this, then it's possible in zerobrane debug mode also. you just pause (or set a breakpoint where it will automatically pause) and then in the console you can execute any code. of course if you call some function then you have to know how to call it from global namespace or put a breakpoint inside the appropriate class and then 'self' will be what you want. when you are done, you just resume your app.


    also, in another post i summarized how to use quickly/simply the livecoding in zerobrane, it's a bit sketchy, but i repost it here, maybe it will be helpful:

    here it is (really basic tutorial):

    say you want to position/fine-tune something in some function Fun in some class Cla
    then

    inside Cla:Fun()
    add
    stage:addEventListener(Event.ENTER_FRAME, function(s) pcall(liveupdate, s) end, self)

    and in the root of the file (e.g. Cla.lua) add the function with the functions you want to fine-tune, e.g.:

    function liveupdate(self)
    self:setPosition(183,505)
    self.subObject:setPosition(100,100)
    self.subObject2:setScale(2)
    end

    now start a livecoding session and you can fine-tune the properties by changing the values, you can add new lines during this session to the function etc.

    when you are done, you paste back the content of liveupdate to the right place in Cla:Fun (in place of line where you added the eventlistener) and remove the line that adds the eventlistener.

    then you can use the same liveupdate function in a similar way to fine-tune some other properties in some other class. etc. you can do lot of other things.

    there are some limitations in what you can liveupdate, e.g. if the function is a local inside Cla:Fun() then it does not live update for me, but e.g. it could be a function of Cla, e.g. Cla:liveupdate(self) and it would still work. in any case this is enough so that one can play around with livecoding. i'm far from understanding it's quirks.

    also in an arbitrary function of some class if i change something during the live session and then the function is called again later, it did not update for me, so one really needs an onenterframe event for this stuff. i don't know why this is needed, as theoretically i don't see why it would not work. but anyway, it's already a strong tool.

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.