generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: are there any other things like remotes/bindables/modules

Previous Thread :: Next Thread 
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
09 Jan 2015 01:39 AM
i recently learned how to use remote/bindable functions & events, and module scripts too, & i want to know if there are any other things similar to them or that i should learn
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
09 Jan 2015 01:41 AM
learn everything

be amazing
Report Abuse
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
09 Jan 2015 01:42 AM
flawless :O


i woke up like this
Report Abuse
ColorfulBody is not online. ColorfulBody
Joined: 17 Jun 2012
Total Posts: 2353
09 Jan 2015 03:06 AM
There are CustomEvents and CustomEventReceivers, but there's not much point in learning to use them.
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
09 Jan 2015 03:13 AM
learn metatables

and read the OOP articles

they enlighten you
Report Abuse
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
09 Jan 2015 03:20 AM
my brain hurts
Report Abuse
A2D8 is not online. A2D8
Joined: 15 Jun 2014
Total Posts: 548
09 Jan 2015 03:39 AM
Metatables are pretty simple if you don't have an idiot (like a ROBLOX wiki writer) trying to explain them to you.

They're just an extra table you can attach to another one. Lua will check it for some special keys and do stuff with their values.

First off, here's how you get yourself a table with a metatable:

local mt = {}
local t = {}
setmetatable(t, mt)

It's that easy! Now you can start doing stuff with it. Let's change that first line:

local mt = { __index = function(t, key) print(key) end }

This is about as simple as it gets. Notice the two underscores before the name of the key, they denote a special function that Lua checks for when it does a certain action. There are a lot of these, I'll list them at the end of this post with short explanations. Let's look at what happens if you try to use this table now:

print(t.this_doesnt_exist)

You'll get this for output:

> this_doesnt_exist
> nil

http://codepad.org/qWASTWjn for proof

Without the metatable, you'd only get the nil part. With it, you get to set a function that's called any time you try to index something that doesn't exist in the table yet! This is extremely useful, but I'll save that for another time. Let's look at another option:

local mt = { __newindex = function(t, key, val) print(key, val) end }

Notice that there's an extra argument. You'll see why:

t.a_new_key = 5

And here's your new output (yes, there's output!):

> a_new_key 5

Starting to see why metatables are so useful yet? Here's that list I mentioned: http://lua-users.org/wiki/MetatableEvents
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
09 Jan 2015 03:41 AM
read the wiki article on OOP if you want an actual use for it
Report Abuse
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
09 Jan 2015 03:42 AM
thanks @a2d8

ill try to learn it cause it does sound useful
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
09 Jan 2015 03:45 AM
they're not that hard just go through anamius's metatables in a nutshell and do a bit of practice and you'll be good
Report Abuse
A2D8 is not online. A2D8
Joined: 15 Jun 2014
Total Posts: 548
09 Jan 2015 03:48 AM
If you really want to know how OOP is best done in Lua, take a look at my OOP implementation:

http://hastebin.com/dijopuduga.lua

It's adapted from my game engine I've been co-developing with LPGhatguy. It's meant for LuaJIT but this version works in ROBLOX Lua.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image