|
| 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
|
  |
| Joined: 27 Feb 2006 |
| Total Posts: 16 |
|
|
| 29 Aug 2016 12:17 AM |
| Look at chapter 16.2 of `Programming in Lua'. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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
|
  |
| Joined: 24 Aug 2016 |
| Total Posts: 356 |
|
| |
|
|
| 29 Aug 2016 04:11 AM |
| have you tried using a rope |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 07:05 AM |
| ok and how do i fire changes? do i just bind a update function to heartbeat? |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 07:13 AM |
| because when you change something like position in a part the cframe changes too |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 07:33 AM |
| bumpity bump pls i was going to make quaternions with look vectors |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 29 Aug 2016 11:13 AM |
This is what I have so far :)
http:// paste bin. com/ UYgU GBSW |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 11:15 AM |
| soon i add multiplying quats and quat to cframe angles |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 11:21 AM |
| is C the only way to create userdata |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 11:23 AM |
use my instance wrapper
"me caveman rawr" - Me |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 11:39 AM |
You can use
local userdata = newproxy(true) local mt = getmetatable(userdata) mt.__index = blah
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 29 Aug 2016 12:01 PM |
| does newproxy work in 5.2 because getfenv() is replaced with _ENV |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 12:04 PM |
Probably not. They made a bunch of changes to these questionable quality functions.
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 29 Aug 2016 12:19 PM |
Who does? :)
"me caveman rawr" - Me |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2016 12:23 PM |
Pretty much everyone, including myself.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|