Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Quick questions about Gideros&Lua - Page 12 — Gideros Forum

Quick questions about Gideros&Lua

189101214

Comments

  • hgy29 said:

    Just had a try and admob compiles fine for me, even without google play enabled in gaming plugin

    may be the reason that i have "windows 7" ??
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
  • hgy29 said:

    Could it be that you have googleplay plugin enabled too ? There are three plugins in which to set up google play services: gaming, googleplay (which should no longer be used), and ads (and firebase for those who have it). All these plugins must ask the same version of google services


    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
  • keszeghkeszegh Member
    edited October 2018
    guys, can you tell me how to get the color of a specific pixel on screen in the latest gideros version? thanks
  • SinisterSoftSinisterSoft Maintainer
    edited October 2018
    You can't get the colour of a specific pixel on the screen. You could draw the screen to a rendertexture then get the colour of the pixel from that?

    Likes: antix, keszegh

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+2 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited October 2018
    for your information i did it the following way:
    local _backgroundcolor=0
     
    function colorPicker(x,y)
    if not rtColorPicker then rtColorPicker=RenderTarget.new(1,1) end
    rtColorPicker:clear(_backgroundcolor)
    rtColorPicker:draw(stage,-x,-y)
    local col=rtColorPicker:getPixel(0,0)      
    return col
    end
    +1 -1 (+3 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Great hack @keszegh, perfect solution for current gideros.
  • Apollo14Apollo14 Member
    edited October 2018
    Hey guys! Something is wrong in my syntax, what can it be?
    (update: uh, the problem was in local scope, I just didn't understand it from console error log)
    dialogText = TextField.new(Roboto_font, "")
    dialogBox:addChild(dialog_BottomText)
     
    function sayDialogBottom(content)
    	print"bottom dialog started" --function never starts
    	for i=1, #content do
    		Core.yield(0.03)
    		dialogText:setText(utf8.sub(content,1,i))
    	end
    	print"bottom dialog ended"
    end
     
    local dialogBoxTween=GTween.new(dialog_Bottom, 1, {y = 530}, {delay = 0, ease = easing.outBack, onComplete = function() Core.asyncCall(sayDialogBottom, "Hi there, how are you?") end})
    after tween end, app crashes:
    [string "local function _start_(fn,...) coroutine.yield() fn(...) end return _start_(...)"]:1: attempt to call local 'fn' (a nil value)
    stack traceback:
    	[string "local function _start_(fn,...) coroutine.yield() fn(...) end return _start_(...)"]:1: in function <[string "local function _start_(fn,...) coroutine.yield() fn(...) end return _start_(...)"]:1>
    	(tail call): ?
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    Yes, I agree the message isn’t very clear, a check for nil function passed in should be added to Core.asyncCall
  • Apollo14Apollo14 Member
    edited October 2018
    Thx!
    There's one more little issue with asyncCalls (I've attached .gproj with reproduced issue).
    For some reason picture that is supposed to be shown (from async function), is shown with big delay when we use non-english characters.
    Is it a bug or an inevitable issue?
    ROBOTO_FONT @ \TTFont.new("Roboto-Regular.ttf",24)\
    local dialogBox, dialogText, delayedPic
     
    dialogBox=Bitmap.new(Texture.new("dialogBox.png",true))
    dialogBox:setPosition(20,40)
    stage:addChild(dialogBox)
     
    dialogText=TextField.new(ROBOTO_FONT, "")
    dialogText:setPosition(30,45)
    dialogBox:addChild(dialogText)
     
    delayedPic=Bitmap.new(Texture.new("calendar.png",true))
    delayedPic:setPosition(330,100)
    stage:addChild(delayedPic)
    delayedPic:setVisible(false)
     
    local function sayText(content)
    	for i=1, #content do
    		--if i==100 then delayedPic:setVisible(true) end	--though we expect it to be shown earlier, there's significant delay, it shows after all text is finished
    		Core.yield(0.03)
    		dialogText:setText(utf8.sub(content,1,i))
    	end
     
    	delayedPic:setVisible(true) --it is shown after significant delay
    end
     
    --[[ When we use english characters, pic appears without delay:
    Core.asyncCall(sayText,"Hello there,\nI'm testing delay.\nPic should appear\nimmediately after\ntext finished.")
    ]]
     
    -- With non-english characters there's delay:
    Core.asyncCall(sayText,"Привет,\nтестируем задержку\nкартинка появится\nсразу после\nокончания диалога.")
    zip
    zip
    testAsyncCallsDelay.zip
    106K
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    Not sure if that's related, but you should use utf8.len(content) instead of #content in your sayText function
    +1 -1 (+3 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited October 2018
    hgy29 said:

    Not sure if that's related, but you should use utf8.len(content) instead of #content in your sayText function

    Wow! Now it works perfectly well, many thanks @hgy29 !
    What was happening there in the background, that created a delay?
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    You were iterating over a lot more chars than your text was actually containing, adding several times your per-char delay in the end while not showing more characters...
    +1 -1 (+3 / -0 )Share on Facebook
  • PaulRPaulR Member, Maintainer
    I don't know if anybody else agrees here, but I think concentrating all of these useful questions and answers in this thread reduces visibility/searchability for future users.

    I personally would prefer to see different questions in their own threads, so that answers and additional information is more visible. Plus concentrating everything in one thread leaves older threads on the front page, giving a 'dusty' look to the forum. :)
    +1 -1 (+2 / -0 )Share on Facebook
  • PaulR said:

    I don't know if anybody else agrees here, but I think concentrating all of these useful questions and answers in this thread reduces visibility/searchability for future users.

    I personally would prefer to see different questions in their own threads, so that answers and additional information is more visible. Plus concentrating everything in one thread leaves older threads on the front page, giving a 'dusty' look to the forum. :)

    I agree, let's create separate topics when it's worth it.

    Likes: PaulR

    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
    +1 -1 (+1 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited November 2018
    guys @SinisterSoft @hgy29

    It seems that 'application:canOpenUrl("https://google.com")'
    always returns 'true', no matter what, even if I turn off internet connection

    does this call check only app permissions, if app is allowed to open any urls? or there's a bug?
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    It supposed to check only app permissions, or rather to check if some application on your device can be used to display/open the specified url

    Likes: Apollo14

    +1 -1 (+1 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited December 2018
    guys, I'm thinking about what project resolution is optimal for both low-end and high-end devices?
    480*854px looks sharp on 1080p smartphone screen, I guess it's optimal for most of the players (nowadays 720p&1080p are the most common)

    but when gideros app runs on low-end device that has lower resolution than 480p, there will be no problems? (I'm setting scale mode to 'letterbox')
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • 940x640 is my favorite resolution ;)

    Likes: Apollo14

    +1 -1 (+1 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited January 2019
    @hgy29 is there a way to try older Spine runtime version in SpineC plugin? (maybe v3.5 or v3.3 instead of current v3.6-3.7)
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    No, why would you want to do that ? Isn’t runtime 3.7 able to load previous versions of spine files ?

    Likes: Apollo14

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29 said:

    No, why would you want to do that ? Isn’t runtime 3.7 able to load previous versions of spine files ?

    I have spine assets that were made in the old 3.3 spine version.
    Simple bones work there, but IK doesn't work.

    I see there's old 3.5 branch on github: https://github.com/EsotericSoftware/spine-runtimes/tree/3.5/spine-c
    Can I compile plugin with it somehow?
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • hgy29hgy29 Maintainer
    Yes, you can compile the plugin (and gideros itself) by yourself following the guide here: https://wiki.giderosmobile.com/index.php/Compiling_Gideros_Source

    Just adjust the fetched spine runtime sources according to your needs.
  • gemboy100gemboy100 Member
    edited February 2019
    I have a stupid question about lua
    why does modulus start from 0 ?
    if they wanted more "humanly" language and moved arrays to start from 1 whats the point of modulus starting from 0 ?

    I know it is possible to force array to start from 0 by arr[0] = ... and recently I found that this is possible too:
    arr={
    [0]="15",
        "16",
        "17"
    }
    so I always use it to avoid conflicts since I came from C
    and I had so much trouble calculating correct value with modulus using arrays
  • hgy29hgy29 Maintainer
    Modulus is a math op to me, the remain of an integer divide. Changing it to start at 1 instead of 0 would be like saying that 1+1=3

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • I was troubled cause I thought +1will let me avoid getting 0 (cause I cant use 0 in array) but it only made me problems
    cur = 1
    mod = 13
    local arr = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}
    print((arr[cur]% mod)+1)
    cur = 1 -> returns 2
    cur = 13 -> 1

  • I personally would rather things like arrays would start from 0, but it's a little late to change that with Lua now. :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • keszeghkeszegh Member
    edited February 2019
    @gemboy100 , what you want to achieve would rather be
    (arr[cur]-1)% mod+1
    i guess.
  • sure, after I spent about half an hour I guessed that too :tired_face:
  • Apollo14Apollo14 Member
    edited August 2019
    Hi guys! (especially @hgy29 :) )
    Two quick questions:
    1) How does garbagecollector work?
    stage:addChild(my_sprite1)
    my_sprite1:addChild(my_sprite2)
    my_sprite1:addChild(my_sprite3)
    my_sprite1:addChild(my_sprite4)
    If I just remove 'my_sprite1' from stage, it will be automatically garbage collected, even if it has some children still added to him?

    Good old 'button' class has 7 event listeners. They don't prevent buttons from being garbage collected? No need to remove them?
    function Button:init()
    	--...
    	self:addEventListener(Event.MOUSE_DOWN, self.onMouseDown, self)
    	self:addEventListener(Event.MOUSE_MOVE, self.onMouseMove, self)
    	self:addEventListener(Event.MOUSE_UP, self.onMouseUp, self)
     
    	self:addEventListener(Event.TOUCHES_BEGIN, self.onTouchesBegin, self)
    	self:addEventListener(Event.TOUCHES_MOVE, self.onTouchesMove, self)
    	self:addEventListener(Event.TOUCHES_END, self.onTouchesEnd, self)
    	self:addEventListener(Event.TOUCHES_CANCEL, self.onTouchesCancel, self)
     
    	--IT'S NOT NEEDED?
    	self:addEventListener(Event.REMOVED_FROM_STAGE, function()
    		self:removeAllListeners()
    		self=nil
    	end)
     
    end
    2) How to look what's inside 'application:vibrate()' function? Where is it hidden in the engine core?

    Many thanks!
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Sign In or Register to comment.