Jump to content




[WIP][difficulty: high] Defining Classes in Lua (Improved OOP)

lua utility

13 replies to this topic

#1 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 04:17 PM

How to Use Metatables to Accomplish Complex Tasks

With a Brief Intro to Abstractions


FILE1: class.lua
Spoiler

PART1: So what does this all mean?
Spoiler

TO DO: continue the tutorial



#2 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 30 January 2013 - 04:20 PM

Use [ CODE ] and [ /CODE ].

#3 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 04:36 PM

View PostDlcruz129, on 30 January 2013 - 04:20 PM, said:

Use [ CODE ] and [ /CODE ].

then i can't indent, which is a royal pain for me

believe me, i tried it

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 January 2013 - 04:38 PM

View Posttesla1889, on 30 January 2013 - 04:36 PM, said:

then i can't indent, which is a royal pain for me
I can indent fine
function name()
 someVar = "yeh"
 if someVar then
  print(someVar)
 end
end


#5 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 05:51 PM

typing in spaces is too much of a pain

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 30 January 2013 - 05:55 PM

thats copy paste from my text editor.

#7 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 31 January 2013 - 04:12 AM

I believe indentation only gets copied when you hit the light switch in the corner that takes you to full view. If that doesn't work, at least use spoilers.

#8 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 31 January 2013 - 06:29 AM

Click on the top left button "Toggle Editing Mode" and then it will keep intendation.

Spoiler


#9 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 31 January 2013 - 07:44 PM

View PostDlcruz129, on 31 January 2013 - 04:12 AM, said:

--snippity snip--
If that doesn't work, at least use spoilers.

thanks!

#10 Cas

  • New Members
  • 1 posts

Posted 07 February 2013 - 05:34 AM

Nice one, looking for this for a long time.

#11 CoolisTheName007

  • Members
  • 304 posts

Posted 07 February 2013 - 06:44 AM

__gc only works for userdata, which does not exists in CC. Just pointing out.

#12 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 07 February 2013 - 08:34 AM

View PostCoolisTheName007, on 07 February 2013 - 06:44 AM, said:

__gc only works for userdata, which does not exists in CC. Just pointing out.
damn. rewrite of all of my projects commences!

#13 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 17 February 2013 - 03:39 PM

my head hurts.....

#14 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 06 March 2013 - 03:51 PM

View Posttesla1889, on 07 February 2013 - 08:34 AM, said:

damn. rewrite of all of my projects commences!

I feel your pain. How much I would love to have access to debug and gc...
Anyway, if I write OO stuff in lua, I tend to have a dispose/finalise function to get rid off all the no longer needed stuff.
CC lua also doesn't appear to respect the supposed '70 local variables only' thing I've heard about in other lua implementations.
Surprisingly a lot of lua implementations don't adhere to the standard. Legend Of Grimrock's stuff doesn't give you access to _G, setfenv or getfenv as far as I can tell.

*end rambling*





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users