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 

objects supported ?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
haringz



Joined: 24 Oct 2005
Posts: 5

PostPosted: Mon Oct 24, 2005 5:58 am    Post subject: objects supported ? Reply with quote

Hi,

I just started experimenting with the lua player and I was wondering if objects are supported. Haven't found any code that uses objects.

By objects I mean creating your own objects.

And if not , is it planned , because I don't think you will see any serious game attempts if you can't create objects.

other than that , it rocks :)

I prolly release something soon, and better stuff if I can use objects :)

greeetz
Back to top
View user's profile Send private message
haust



Joined: 01 Oct 2005
Posts: 25
Location: France

PostPosted: Mon Oct 24, 2005 7:06 am    Post subject: Reply with quote

What do you mean by object ?? You mean Object Oriented Program ??
Well Lua support this kind of feature.
Code:
-- -----------------------------------------------------------------------
-- CObject
-- -----------------------------------------------------------------------
CObject = {}
CObjectMetaTable = { __index = CObject }

-- -----------------------------------------------------------------------
-- CObject:new
-- -----------------------------------------------------------------------
function CObject:new()
   local Table =
   {
      m_TextValue = "TextData",
      m_BoolValue = true,
   }

   setmetatable(Table, CObjectMetaTable);

   return (Table);
end

-- -----------------------------------------------------------------------
-- CObject:doSomething
-- -----------------------------------------------------------------------
function CObject:doSomething()
   if (true == self.m_BoolValue) then
      self.m_TextValue = "OK";
   else
      self.m_TextValue = "CANCEL";
   end
end

-- -----------------------------------------------------------------------
--
-- -----------------------------------------------------------------------
function main()
   local MyObj1 = CObject:new();
   local MyObj2 = CObject:new();

   MyObj1.m_BoolValue = true;
   MyObj2.m_BoolValue = false;

   MyObj1:doSomething();
   MyObj2:doSomething();
end

main();

I don't know for inheritance and other oop stuff but this can be a good start....
Back to top
View user's profile Send private message
haringz



Joined: 24 Oct 2005
Posts: 5

PostPosted: Mon Oct 24, 2005 8:23 am    Post subject: Reply with quote

thanks mate !

Exactly what I meant.

gonna give it a try tomorrow
Back to top
View user's profile Send private message
Durante



Joined: 02 Oct 2005
Posts: 65
Location: Austria

PostPosted: Mon Oct 24, 2005 8:34 am    Post subject: Reply with quote

I often say this, but read the book. Especially the chapter on classes. It is a bit dry, but very helpful.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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