forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Classes in Lua

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Aug 25, 2005 10:18 pm    Post subject: Classes in Lua Reply with quote

i learned programming with java so i like programing with classes...
i read some tutorials on simulation classes in lua, but i am not really sure if i got it right...

Code:

public class WallInfo
{

    public WallInfo(double d,  double d1,  double d2,  double d3,  double d4)
    {
        top=d2;
        bottom=d3;
        left=d;
        right=d1;
        ctop=d2+d4;
        cbottom=d3-d4;
        cleft=d+d4;
        cright=d1-d4;
    }

    public double top;
    public double bottom;
    public double left;
    public double right;
    public double ctop;
    public double cbottom;
    public double cleft;
    public double cright;
}

this code provides me information about the wall

is the equivalent in lua the following?
Code:

WallInfo={}
WallInfo_mt={}

function WallInfo:new(d,  d1,  d2,  d3,  d4)
   return setmetatable({top=d2, bottom=d3, left=d, right=d1, ctop=d2+d4, cbottom=d3-d4, cleft=d+d4, cright=d1-d4},  WallInfo_mt)
end


so that i can call it same way as in java...
greets
LuMo
Back to top
View user's profile Send private message Visit poster's website
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Thu Aug 25, 2005 11:47 pm    Post subject: Reply with quote

This is not a general Lua forum, try Lua users wiki and search for class.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group