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: How do I (metatables)

Previous Thread :: Next Thread 
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 12:16 AM
Create meteables that inherit the properties of another?
i know how to create my own "object" metatables but what if I want it to inherit the same functions similar to how all gui objects inherit the same gui properties
Report Abuse
james is not online. james
Joined: 27 Feb 2006
Total Posts: 16
29 Aug 2016 12:17 AM
Look at chapter 16.2 of `Programming in Lua'.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
29 Aug 2016 12:33 AM
__index
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 12:53 AM
no i mean like

i could have one that gets the properties of

• source
• main
and
• objects

and i give it its own values too

Report Abuse
KreoBox is not online. KreoBox
Joined: 24 Aug 2016
Total Posts: 356
29 Aug 2016 01:18 AM
Still __index.


Report Abuse
SadisticNub is not online. SadisticNub
Joined: 05 Jan 2013
Total Posts: 4948
29 Aug 2016 04:11 AM
have you tried using a rope
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 07:05 AM
ok and how do i fire changes? do i just bind a update function to heartbeat?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 07:13 AM
because when you change something like position in a part the cframe changes too
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 07:33 AM
bumpity bump pls i was going to make quaternions with look vectors
Report Abuse
Toonshield is not online. Toonshield
Joined: 04 Mar 2015
Total Posts: 518
29 Aug 2016 10:14 AM
Use __newindex when something changes.


local class = {}
function class.new(var)
local var = var

return setmetatable({}, {
__index = function(_, index)
if index == "var" then
return var
end
end;
__newindex = function(_, index, val)
if index == "var" then
var = val --trigger changes
end
end;
})
end
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 11:13 AM
This is what I have so far :)

http://
paste
bin.
com/
UYgU
GBSW
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 11:15 AM
soon i add multiplying quats and quat to cframe angles
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 11:21 AM
is C the only way to create userdata
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
29 Aug 2016 11:23 AM
use my instance wrapper


"me caveman rawr" - Me
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Aug 2016 11:39 AM
You can use

local userdata = newproxy(true)
local mt = getmetatable(userdata)
mt.__index = blah


Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
29 Aug 2016 12:00 PM
@Jarod

I already created an instance wrapper for that.. he would just need to modify it, since I don't think he's using instances.


"me caveman rawr" - Me
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 12:01 PM
does newproxy work in 5.2 because getfenv() is replaced with _ENV
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Aug 2016 12:04 PM
Probably not. They made a bunch of changes to these questionable quality functions.


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 12:07 PM
no worries i can just do this

local t = type
function type(x)
local n,ty = pcall(function()
return x.__type
end)
if n and ty then
return ty
end
return t(x )
end

now type returns the meta.__type or just type
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
29 Aug 2016 12:14 PM
I honestly wouldn't bother with anything other than 5.1; I don't like the new changes.


"me caveman rawr" - Me
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Aug 2016 12:15 PM
5.2 and 5.3 are both way better than 5.1. You just don't like change.


Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
29 Aug 2016 12:19 PM
Who does? :)


"me caveman rawr" - Me
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Aug 2016 12:23 PM
Pretty much everyone, including myself.


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 12:32 PM
is my quaternion working
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Aug 2016 06:58 PM
so you can just do this simple thing to lock a metatable right?

mt.__newindex = function(t,k)
error("attempt to modify a read-only table")
end
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