Say, I have this program on one computer:
_G["x"] = 12 -- same as "x = 12"
function print_var(_x)
print(_x)
end
And then this program on another computer:
print_var(x)
If we then run the program on the first computer first, and then run the program on the second computer, it will output this:
12
This can be used in a chat, ofcourse. And very easily too!
Example of a simple message queue:
-- Server
local messages = {"Initiated"}
local function on_new_message()
-- Send a notification to all clients
end
function push_msg(msg)
if type(msg) ~= "string" then
error "Bad argument #1 to 'push_msg()': argument must be of type 'string'"
end
for i = #messages, 1, -1 do
messages[i + 1] = messages[i]
end
messages[1] = msg
on_new_message()
end
Please tell me if you make anything with this.
Thank for reading, I hope this will help you develop great chat applications soon!