| |
|
| |
|
|
| 15 Dec 2011 06:32 PM |
A variable in a script? As in, changing 'lolpwnsause' to 1337? |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Dec 2011 06:35 PM |
Hehe. Let me do some testing, and I will get back to you. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2011 06:37 PM |
inb4LotsAndLotsOfMetatables
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
| |
|
TwoBoo
|
  |
| Joined: 08 Feb 2011 |
| Total Posts: 10790 |
|
|
| 15 Dec 2011 06:38 PM |
herp = 0 if herp == 0 then herp = 1 if herp == 1 then function lolk() print("herp") end end end
Idk. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
|
| 15 Dec 2011 07:12 PM |
The best you can do is this:
function setVarChangeEvents(LOLEPICSAUCE) local function getter() end local vars = {} local control = setmetatable({}, {__index = function(t, k) if vars[k] == nil then vars[k] = setmetatable({ Value = v }, { __index = function(t, k) if k == "Changed" then return { connect = function(dummy, func) getter = func end } end end, __tostring = function(t) return ""..t.Value end}) end if k == "Changed" then return { connect = function(dummy, func) getter = func end } else return vars[k] end end, __newindex = function(t, k, v) local oldValue = t[k] ~= nil and t[k].Value or nil vars[k] = setmetatable({ Value = v }, { __index = function(t, k) if k == "Changed" then return { connect = function(dummy, func) getter = func end } end end, __tostring = function(t) return ""..t.Value end}) getter(oldValue, v) end, __metatable = "no", }) return control end
function lolk(oldValue, newValue) print("Old Value: ", oldValue, "New Value: ", newValue) end
myVars = setVarChangeEvents() myVars.herp.Changed:connect(lolk) myVars.herp = 1337 wait(0.5) myVars.herp = "Moo" wait(0.5) myVars.herp = true
---- OUTPUT ---- > Old Value: nil New Value: 1337 Old Value: 1337 New Value: Moo Old Value: Moo New Value: true |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|