Your probably right. I would need to use pointers for this system. I don’t think Lua has pointers; unless I am wrong?
I think the reason you’re getting quite negative responses is because no one understands why you want to use this. If you can present us with a use case as to why you would want this, someone can better help you.
@1230james is right, strings and tables are pointers to memory in Lua. Which is why the following would work:
local my_table = {1, 2, 3}
local ref_to_table = my_table
for i = 1, #ref_to_table do
ref_to_table[i] = 4 - ref_to_table[i]
end
table.foreach(my_table, print) --> prints [3, 2, 1]
Your description of what you understand superposition to be is related to quantum theory. As others have stated, that is not possible in this environment. However, your later redefining of this is very much possible. You can define and redefine a variable to whatever you wish, and you can change that on the fly as long as you have the address - these can be determinant, procedural or random.
In regard to your example:
The startup will start out with; if a GUI is at 0.5 transparency. Other objects will have scripts making them any possible value. When this GUI is 0.5 transparency, this int value will be 20, if the int value is 20, another value is determined.
This is possible but you would have to code this behaviour. e.g.
local GUI = script.Parent
local Frame = GUI.Frame
local Int = 0
local otherValue = ''
--> In another script if you so desire
Frame:GetPropertyChangedSignal('BackgroundTransparency'):Connect(function ()
local var = Frame.BackgroundTransparency
if var - math.random() > 0.1 then
Int = Int + Random.new():NextInteger(-20, 20)
end
end)
spawn(function ()
repeat
Frame.BackgroundTransparency = math.random()
--> Could also be in another script if you so desire, either putting it as a NumberValue or firing it with a bindableevent
if Int == 20 then
otherValue = otherValue .. ('xxx-yxy-xxy-yxx'):gsub('[xy]', function (c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return ('%x'):format(v)
end):rep(math.ceil(math.random(1, 5)))
end
print(
('Transparency -> %s \n Int -> %s \n otherValue -> %s'):format(
tostring(Frame.BackgroundTransparency),
tostring(Int),
otherValue
)
)
wait()
until false
end)
Alright. Thank you to everyone who replied. I think I understand everything now.
Right now you can’t code non-deterministic programs for modern computers, but they can be simulated.
This is exactly what I was looking for. Thank you for the reply!!