Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Hi all — Gideros Forum

Hi all

gaboritalygaboritaly Member
edited May 2012 in Introduce yourself
Hi I'm Gàbor from Italy.
First, apologize for my english, but I'm a Hungarian boy, and live here in Italy.
Finally I choose Gideros for my further mobile development, after one month of search.
I'm a flash developer, and graphic designer.
Well if anyone have a necessary to help for the design , if I can help you, because I'll have to necessity for your massive knowledge :)
Unfortunately AS how I think in this year, not have a really good performance in both cases ( IOS, Android ).
Well of course AS has a good libraries, components etc, what now I don't find yet for lua.
Now I'm trying to learn Lua, I think is a good language, but not a really simple how I thinking first.
I need immediatelly for your help.
Sorry if you written these things in 1000 time .. :(
I found some sites :
www.lua.org/
/lua-users.org

1 ) This is a good startup sites ?
2 ) What I see in these sites, I can apply all in Gideros , is it compatible?
3 ) I can use in Gideros external libraries xml (i found some libraries but I'm don't remember their names ?
4 ) I'm really confused with the object references . Double dot and simple dot. If anyone help me to understand this difference. In AS and JS I always used only dot reference for all things.

Example I found in lua.org:
////////////////////////////////////////////////////////
Account = {}
Account.__index = Account

function Account.create(balance)
local acnt = {} -- our new object
setmetatable(acnt,Account) -- make Account handle lookup
acnt.balance = balance -- initialize our object
return acnt
end

function Account:withdraw(amount)
self.balance = self.balance - amount
end

-- create and use an Account
acc = Account.create(1000)
acc:withdraw(100)

other example found in the forum :
////////////////////////////////////////////////////////
--let's create our own class based on Sprite
Scene = Core.class(Sprite)

function Scene:init()
--variable self is referencing to instance of the class scene
--so if we do this
self.somevar = "somevalue"
end

--create instance
local scene = new Scene()

--let's define function using :
--meaning we will use same scope
function scene:samescope()
--somevar is still accessible
print(self.somevar) --results "somevalue"
end

--now let's use .
--meaning we will use different scope
scene.differentcope = function()
--somevar is NOT accessible
print(self.somevar) -- results nil
end


Thanks a lot for any help.
And have good job.

NG




Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited May 2012
    Hello and welcome

    Here would be an example of difference between : and .
    --let's create our own class based on Sprite
    Scene = Core.class(Sprite)
     
    function Scene:init()
    	--variable self is referencing to instance of the class scene
    	--so if we do this
    	self.somevar = "somevalue"
    end
     
    --create instance
    local scene = new Scene()
     
    --let's define function using :
    --meaning we will use same scope
    function scene:samescope()
    	--somevar is still accessible
    	print(self.somevar) --results "somevalue"
    end
     
    --now let's use .
    --meaning we will use different scope
    scene.differentcope = function()
    	--somevar is NOT accessible
    	print(self.somevar) -- results nil
    end
    Even better example:
    for each method in string object we can pass string to it
    string.find("Hello Lua user", "Lua")
    or we can use this function for strings directly, because they are also string objects
    local str = "Hello Lua user"
    str:find("Lua")
    As you see in second example, we didn't have to pass string value again, because using ":" will pass string itself as first argument.

    Summing it up:
    --this function
    function scene.func1(self, argument1, argument)
    	--variable self contains instance
    	--because we passed it as first argument
    end
     
    --equals this function
    function scene:func2(argument1, argument)
    	--variable self contains instance
    end
    Hope that clears anything :)

    Likes: avo, Caroline

    +1 -1 (+2 / -0 )Share on Facebook
  • gorkemgorkem Maintainer
    Hello Gabor, and welcome to our family :) Hope you'll have a good time here.
  • avoavo Member
    Welcome Gabor, great to have you here!

    I have found the lua-users.org site to be a great reference, especially for specific topics.
  • MichalMichal Member

    1 ) This is a good startup sites ?
    2 ) What I see in these sites, I can apply all in Gideros , is it compatible?
    3 ) I can use in Gideros external libraries xml (i found some libraries but I'm don't remember their names ?
    4 ) I'm really confused with the object references . Double dot and simple dot. If anyone help me to understand this difference. In AS and JS I always used only dot reference for all things.
    Ad 1: Those are OK, you should read PIL a few times:
    http://www.lua.org/pil/
    You can also google for "lua tutorial".

    Ad. 2: yes, every plain lua program is OK. Note that gideros has its own class system, and some examples use other class implementations, so you might to modify examples, or use 2 different class implementations at the same time.
    Using external modules (written in C) is not that easy: you would need to compile them yourself, but as a beginner, you should just skip them (i.e. "not usable within gideros").

    Ad. 3: as already written, you can use all plain-lua libraries, but should avoid binary modules.

    Ad. 4. it is already explained. In one sentence: in lua if you use dot, you should pass "self" as a first argument of a class method, i.e. "function class.method(self, arg1, arg2)", but to make the source code look nicer, lua has a "syntax sugar", so you can write this like "function class:method(arg1, arg2)". It is only visual difference, for the computer both forms are exactly the same - no difference in program logic. So if you want, you can skip using colons entirely, just remember to put "self" as a first argument (also when calling an object mehod: "object.method(object, arg1, arg2)" ), as in your Account example above.

  • ScouserScouser Guru
    edited May 2012
    @gaboritaly: Welcome to the community and by all means feel free to ask questions, I'm sure they will be answered by the friendly bunch here although I would suggest the search box at the top of the screen as your friend. You may find that a lot of the questions you want to ask have possibly already been answered elsewhere in the forums. :)
  • @gaboritaly welcome !!!! >:D<

    it's nice to see some italian here!

    ITALIAN MODE ON
    Benvenuto!!! sono sicuro che ti troverai bene qui!
    ITALIAN MODE OFF

    Ciao
    Gianluca.
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • denizdeniz Maintainer
    Welcome Gabor!
  • Hi all,
    Thanks a lot ,for all help, and suggestion .
    You are very kind , to help me.
    I think now understand the dot and double dot syntax.
    See you son.
    Have a good job for everybody!

    NG

Sign In or Register to comment.