how can i check, if at least 2 of 3 given bools are true?
Hello i have 3 bools (to check, if a coordinate is along the edges of a cube with the given size of 16 units):
how must i setup the if-line to check, if at least 2 of these bool-lines are true?
https://redd.it/1gslmef
@r_lua
Hello i have 3 bools (to check, if a coordinate is along the edges of a cube with the given size of 16 units):
local bool_1 = x == 1 or x = 16 local bool_2 = y == 1 or y = 16 local bool_3 = z == 1 or z = 16how must i setup the if-line to check, if at least 2 of these bool-lines are true?
https://redd.it/1gslmef
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Best app to learn LUA coding?
I'm currently searching for a safe app where to learn code.
https://redd.it/1gtlle7
@r_lua
I'm currently searching for a safe app where to learn code.
https://redd.it/1gtlle7
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Is it possible to interpolate C/C++ code in Lua ?
So Recently I decided to check out Lua and it's Love2D Framework, I wanted to ask if anyone knows about how you can use C++ Code in Lua. I am aware that you can embed Lua code in cpp but can you do the opposite.
Any kind of Help will be Greatly Appreciated !
https://redd.it/1gu4nhz
@r_lua
So Recently I decided to check out Lua and it's Love2D Framework, I wanted to ask if anyone knows about how you can use C++ Code in Lua. I am aware that you can embed Lua code in cpp but can you do the opposite.
Any kind of Help will be Greatly Appreciated !
https://redd.it/1gu4nhz
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Advice to learn Roblox-Lua?
Hi, i'm an aspiring developer on the Roblox platform. Recently I've started learning the fundamentals of Lua and I think I'm ready to take another step into Lua programming, it's fun! Which is why, I'm here asking for any tips or advice you have in for me to pursue this knowledge. Maybe there's a place to learn? Sort of like a website? Idk but I'd like to learn a lot more, that's for sure! Thank you in advance 🙏🙏
https://redd.it/1gueqvj
@r_lua
Hi, i'm an aspiring developer on the Roblox platform. Recently I've started learning the fundamentals of Lua and I think I'm ready to take another step into Lua programming, it's fun! Which is why, I'm here asking for any tips or advice you have in for me to pursue this knowledge. Maybe there's a place to learn? Sort of like a website? Idk but I'd like to learn a lot more, that's for sure! Thank you in advance 🙏🙏
https://redd.it/1gueqvj
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Mudança de cor em Lua
Fala pessoal, gostaria de saber se existe alguma lib ou alguma forma, função, para manipulação de cores nos textos (para aplicações não gráficas do lado do usuário/terminal) em Lua ? ainda não achei nada com relação á isso.
https://redd.it/1gv9i9r
@r_lua
Fala pessoal, gostaria de saber se existe alguma lib ou alguma forma, função, para manipulação de cores nos textos (para aplicações não gráficas do lado do usuário/terminal) em Lua ? ainda não achei nada com relação á isso.
https://redd.it/1gv9i9r
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Starting to code, beginning with LUA
Hey there! I decided that i wanna start to code, i'm new into this world and i need some tips and advices for beginners. My discord is n0etix.
I got a few experienced coders telling me to start with CS50x lectures to begin with, because without the basics, there's no code. Just like in math, without 2 plus 2 there's no pythagorean theorem..
Add me on discord, maybe we can discuss something together :)
https://redd.it/1gvl0zf
@r_lua
Hey there! I decided that i wanna start to code, i'm new into this world and i need some tips and advices for beginners. My discord is n0etix.
I got a few experienced coders telling me to start with CS50x lectures to begin with, because without the basics, there's no code. Just like in math, without 2 plus 2 there's no pythagorean theorem..
Add me on discord, maybe we can discuss something together :)
https://redd.it/1gvl0zf
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How do i make a cfg system in lua?
So i wrote a noscript with dropdown boxes checkmarks and sliders but now what?
I want to make it read and write cfg files or txt or anything that can take the values and turn them into something that can be saved and loaded
https://redd.it/1gws7cw
@r_lua
So i wrote a noscript with dropdown boxes checkmarks and sliders but now what?
I want to make it read and write cfg files or txt or anything that can take the values and turn them into something that can be saved and loaded
https://redd.it/1gws7cw
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Tips to make this less cursed?
I have this function that's supposed to get options from a config table. I wanted to make it possible to have any of the keys be functions and still work like a simple nested table.
So, I made this,
This works, but also looks very cursed. Any tips to improve the code?
https://redd.it/1gwxjq2
@r_lua
I have this function that's supposed to get options from a config table. I wanted to make it possible to have any of the keys be functions and still work like a simple nested table.
So, I made this,
local __get = function (keys, opts)
if not opts then opts = {}; end
local meta;
local __proxy = {};
local _c = {
vi = {
enable = function ()
return {
test = 10
};
end
},
_f = function ()
return "hi"
end
};
meta = {
__index = function (_, key)
local _v = rawget(_c, key);
---@diagnostic disable
if
(
not opts.return_raw or
(
opts.return_raw and
opts.return_raw[key] ~= false
)
) and
pcall(_v, unpack(opts.args or {}))
then
return _v(unpack(opts.args or {}));
---@diagnostic enable
elseif type(_v) == "table" then
setmetatable(_v, meta)
end
return _v;
end
};
setmetatable(__proxy, meta);
for _, key in ipairs(keys) do
if
type(__proxy[key]) == "table" and
__proxy[key].enable ~= false
then
_c = __proxy[key];
setmetatable(__proxy, meta);
elseif __proxy[key] then
_c = _c[key];
setmetatable(__proxy, meta);
else
return opts.fallback;
end
end
---@diagnostic disable
if pcall(_c, unpack(opts.args or {})) then
return _c(unpack(opts.args or {}));
end
---@diagnostic enable
return _c;
end
print(
__get({"vi", "enable", "test"})
)
This works, but also looks very cursed. Any tips to improve the code?
https://redd.it/1gwxjq2
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Is there a way to put every part of a lua in 1 line after coding it?
I made a lua (about 4600 lines of code) and i want to put it in 1 line so people can’t steal the code as easily, how can i do that?
https://redd.it/1gx4892
@r_lua
I made a lua (about 4600 lines of code) and i want to put it in 1 line so people can’t steal the code as easily, how can i do that?
https://redd.it/1gx4892
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Working with WebRTC from fengari lua in the browser...first steps
I decided to create this simple RTCDataChannel example in lua using fengari. The most interesting part of this process was figuring out how to translate the promise-chaining as seen here:
localConnection.createOffer()
.then(offer => localConnection.setLocalDenoscription(offer))
.then(() => remoteConnection.setRemoteDenoscription(localConnection.localDenoscription))
.then(() => remoteConnection.createAnswer())
.then(answer => remoteConnection.setLocalDenoscription(answer))
.then(() => localConnection.setRemoteDenoscription(remoteConnection.localDenoscription))
.catch(handleCreateDenoscriptionError);
I had to create the then, catch, finally functions in addition to the pdo function which starts the chain.
weft.fengari:
js=require('js')
window=js.global
document=window.document
function then(prom,...)
local p=prom['then'](prom,...)
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function catch(prom,...)
local p=prom'catch'
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function finally(prom,...)
local p=prom['finally'](prom,...)
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function pdo(p)
p.then=then
p.catch=catch
p.finally=finally
return p
end
function elevate(from,members)
-- "elevates" table of top level members of a js object (from) into global, for convenience
for , v in ipairs(members) do
ENVv=fromv
end
end
elevate(js.global,{
'console',
'RTCPeerConnection'
})
local connectButton = nil
local disconnectButton = nil
local sendButton = nil
local messageInputBox = nil
local receiveBox = nil
local localConnection = nil -- RTCPeerConnection for our "local" connection
local remoteConnection = nil -- RTCPeerConnection for the "remote"
local sendChannel = nil -- RTCDataChannel for the local (sender)
local receiveChannel = nil -- RTCDataChannel for the remote (receiver)
function handleCreateDenoscriptionError(error)
console:log('unable to create an offer')
end
function handleLocalAddCandidateSuccess()
connectButton.disabled = true
end
function handleRemoteAddCandidateSuccess()
disconnectButton.disabled = false
end
function handleAddCandidateError()
console:log("Oh noes! addICECandidate failed!")
end
-- Handles clicks on the "Send" button by transmitting
-- a message to the remote peer.
function sendMessage()
local message = messageInputBox.value
sendChannel:send(message)
-- Clear the input box and re-focus it, so that we are
-- ready for the next message.
messageInputBox.value = ""
messageInputBox:focus()
end
-- Handle status changes on the local end of the data
-- channel; this is the end doing the sending of data
-- in this example.
function handleSendChannelStatusChange(self,event)
if (sendChannel) then
local state = sendChannel.readyState
console:log('sendChannel',state)
if (state == "open") then
messageInputBox.disabled = false
messageInputBox:focus()
sendButton.disabled = false
disconnectButton.disabled = false
connectButton.disabled = true
else
messageInputBox.disabled = true
sendButton.disabled = true
connectButton.disabled = false
disconnectButton.disabled = true
end
end
end
-- Called when the connection opens and the data
-- channel is ready to be connected to the remote.
function
I decided to create this simple RTCDataChannel example in lua using fengari. The most interesting part of this process was figuring out how to translate the promise-chaining as seen here:
localConnection.createOffer()
.then(offer => localConnection.setLocalDenoscription(offer))
.then(() => remoteConnection.setRemoteDenoscription(localConnection.localDenoscription))
.then(() => remoteConnection.createAnswer())
.then(answer => remoteConnection.setLocalDenoscription(answer))
.then(() => localConnection.setRemoteDenoscription(remoteConnection.localDenoscription))
.catch(handleCreateDenoscriptionError);
I had to create the then, catch, finally functions in addition to the pdo function which starts the chain.
weft.fengari:
js=require('js')
window=js.global
document=window.document
function then(prom,...)
local p=prom['then'](prom,...)
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function catch(prom,...)
local p=prom'catch'
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function finally(prom,...)
local p=prom['finally'](prom,...)
if p then
p.then = then
p.catch = catch
p.finally = finally
end
return p
end
function pdo(p)
p.then=then
p.catch=catch
p.finally=finally
return p
end
function elevate(from,members)
-- "elevates" table of top level members of a js object (from) into global, for convenience
for , v in ipairs(members) do
ENVv=fromv
end
end
elevate(js.global,{
'console',
'RTCPeerConnection'
})
local connectButton = nil
local disconnectButton = nil
local sendButton = nil
local messageInputBox = nil
local receiveBox = nil
local localConnection = nil -- RTCPeerConnection for our "local" connection
local remoteConnection = nil -- RTCPeerConnection for the "remote"
local sendChannel = nil -- RTCDataChannel for the local (sender)
local receiveChannel = nil -- RTCDataChannel for the remote (receiver)
function handleCreateDenoscriptionError(error)
console:log('unable to create an offer')
end
function handleLocalAddCandidateSuccess()
connectButton.disabled = true
end
function handleRemoteAddCandidateSuccess()
disconnectButton.disabled = false
end
function handleAddCandidateError()
console:log("Oh noes! addICECandidate failed!")
end
-- Handles clicks on the "Send" button by transmitting
-- a message to the remote peer.
function sendMessage()
local message = messageInputBox.value
sendChannel:send(message)
-- Clear the input box and re-focus it, so that we are
-- ready for the next message.
messageInputBox.value = ""
messageInputBox:focus()
end
-- Handle status changes on the local end of the data
-- channel; this is the end doing the sending of data
-- in this example.
function handleSendChannelStatusChange(self,event)
if (sendChannel) then
local state = sendChannel.readyState
console:log('sendChannel',state)
if (state == "open") then
messageInputBox.disabled = false
messageInputBox:focus()
sendButton.disabled = false
disconnectButton.disabled = false
connectButton.disabled = true
else
messageInputBox.disabled = true
sendButton.disabled = true
connectButton.disabled = false
disconnectButton.disabled = true
end
end
end
-- Called when the connection opens and the data
-- channel is ready to be connected to the remote.
function
MDN Web Docs
A simple RTCDataChannel sample - Web APIs | MDN
The RTCDataChannel interface is a feature of the WebRTC API which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the WebSocket API, so that the same programming model can be…
Working with WebRTC from fengari lua in the browser...first steps
I decided to create [this simple RTCDataChannel example](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample) in lua using fengari. The most interesting part of this process was figuring out how to translate the promise-chaining as seen here:
localConnection.createOffer()
.then(offer => localConnection.setLocalDenoscription(offer))
.then(() => remoteConnection.setRemoteDenoscription(localConnection.localDenoscription))
.then(() => remoteConnection.createAnswer())
.then(answer => remoteConnection.setLocalDenoscription(answer))
.then(() => localConnection.setRemoteDenoscription(remoteConnection.localDenoscription))
.catch(handleCreateDenoscriptionError);
I had to create the _then, _catch, _finally functions in addition to the p_do function which starts the chain.
weft.fengari:
js=require('js')
window=js.global
document=window.document
function _then(prom,...)
local p=prom['then'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function _catch(prom,...)
local p=prom['catch'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function _finally(prom,...)
local p=prom['finally'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function p_do(p)
p._then=_then
p._catch=_catch
p._finally=_finally
return p
end
function elevate(from,members)
-- "elevates" table of top level members of a js object (from) into global, for convenience
for _, v in ipairs(members) do
_ENV[v]=from[v]
end
end
elevate(js.global,{
'console',
'RTCPeerConnection'
})
local connectButton = nil
local disconnectButton = nil
local sendButton = nil
local messageInputBox = nil
local receiveBox = nil
local localConnection = nil -- RTCPeerConnection for our "local" connection
local remoteConnection = nil -- RTCPeerConnection for the "remote"
local sendChannel = nil -- RTCDataChannel for the local (sender)
local receiveChannel = nil -- RTCDataChannel for the remote (receiver)
function handleCreateDenoscriptionError(error)
console:log('unable to create an offer')
end
function handleLocalAddCandidateSuccess()
connectButton.disabled = true
end
function handleRemoteAddCandidateSuccess()
disconnectButton.disabled = false
end
function handleAddCandidateError()
console:log("Oh noes! addICECandidate failed!")
end
-- Handles clicks on the "Send" button by transmitting
-- a message to the remote peer.
function sendMessage()
local message = messageInputBox.value
sendChannel:send(message)
-- Clear the input box and re-focus it, so that we are
-- ready for the next message.
messageInputBox.value = ""
messageInputBox:focus()
end
-- Handle status changes on the local end of the data
-- channel; this is the end doing the sending of data
-- in this example.
function handleSendChannelStatusChange(self,event)
if (sendChannel) then
local state = sendChannel.readyState
console:log('sendChannel',state)
if (state == "open") then
messageInputBox.disabled = false
messageInputBox:focus()
sendButton.disabled = false
disconnectButton.disabled = false
connectButton.disabled = true
else
messageInputBox.disabled = true
sendButton.disabled = true
connectButton.disabled = false
disconnectButton.disabled = true
end
end
end
-- Called when the connection opens and the data
-- channel is ready to be connected to the remote.
function
I decided to create [this simple RTCDataChannel example](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample) in lua using fengari. The most interesting part of this process was figuring out how to translate the promise-chaining as seen here:
localConnection.createOffer()
.then(offer => localConnection.setLocalDenoscription(offer))
.then(() => remoteConnection.setRemoteDenoscription(localConnection.localDenoscription))
.then(() => remoteConnection.createAnswer())
.then(answer => remoteConnection.setLocalDenoscription(answer))
.then(() => localConnection.setRemoteDenoscription(remoteConnection.localDenoscription))
.catch(handleCreateDenoscriptionError);
I had to create the _then, _catch, _finally functions in addition to the p_do function which starts the chain.
weft.fengari:
js=require('js')
window=js.global
document=window.document
function _then(prom,...)
local p=prom['then'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function _catch(prom,...)
local p=prom['catch'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function _finally(prom,...)
local p=prom['finally'](prom,...)
if p then
p._then = _then
p._catch = _catch
p._finally = _finally
end
return p
end
function p_do(p)
p._then=_then
p._catch=_catch
p._finally=_finally
return p
end
function elevate(from,members)
-- "elevates" table of top level members of a js object (from) into global, for convenience
for _, v in ipairs(members) do
_ENV[v]=from[v]
end
end
elevate(js.global,{
'console',
'RTCPeerConnection'
})
local connectButton = nil
local disconnectButton = nil
local sendButton = nil
local messageInputBox = nil
local receiveBox = nil
local localConnection = nil -- RTCPeerConnection for our "local" connection
local remoteConnection = nil -- RTCPeerConnection for the "remote"
local sendChannel = nil -- RTCDataChannel for the local (sender)
local receiveChannel = nil -- RTCDataChannel for the remote (receiver)
function handleCreateDenoscriptionError(error)
console:log('unable to create an offer')
end
function handleLocalAddCandidateSuccess()
connectButton.disabled = true
end
function handleRemoteAddCandidateSuccess()
disconnectButton.disabled = false
end
function handleAddCandidateError()
console:log("Oh noes! addICECandidate failed!")
end
-- Handles clicks on the "Send" button by transmitting
-- a message to the remote peer.
function sendMessage()
local message = messageInputBox.value
sendChannel:send(message)
-- Clear the input box and re-focus it, so that we are
-- ready for the next message.
messageInputBox.value = ""
messageInputBox:focus()
end
-- Handle status changes on the local end of the data
-- channel; this is the end doing the sending of data
-- in this example.
function handleSendChannelStatusChange(self,event)
if (sendChannel) then
local state = sendChannel.readyState
console:log('sendChannel',state)
if (state == "open") then
messageInputBox.disabled = false
messageInputBox:focus()
sendButton.disabled = false
disconnectButton.disabled = false
connectButton.disabled = true
else
messageInputBox.disabled = true
sendButton.disabled = true
connectButton.disabled = false
disconnectButton.disabled = true
end
end
end
-- Called when the connection opens and the data
-- channel is ready to be connected to the remote.
function
MDN Web Docs
A simple RTCDataChannel sample - Web APIs | MDN
The RTCDataChannel interface is a feature of the WebRTC API which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the WebSocket API, so that the same programming model can be…
receiveChannelCallback(self,event)
receiveChannel = event.channel
receiveChannel.onmessage = handleReceiveMessage
receiveChannel.onopen = handleReceiveChannelStatusChange
receiveChannel.onclose = handleReceiveChannelStatusChange
end
-- Handle onmessage events for the receiving channel.
-- These are the data messages sent by the sending channel.
function handleReceiveMessage(self,event)
local el = document:createElement("p")
local txtNode = document:createTextNode(event.data)
el:appendChild(txtNode)
receiveBox:appendChild(el)
end
-- Handle status changes on the receiver's channel.
function handleReceiveChannelStatusChange(event)
if (receiveChannel) then
console:log("Receive channel's status has changed to ",receiveChannel.readyState)
end
-- Here you would do stuff that needs to be done
-- when the channel's status changes.
end
function connectPeers()
localConnection = js.new(RTCPeerConnection)
sendChannel = localConnection:createDataChannel("sendChannel")
sendChannel.onopen = handleSendChannelStatusChange
sendChannel.onclose = handleSendChannelStatusChange
remoteConnection = js.new(RTCPeerConnection)
remoteConnection.ondatachannel = receiveChannelCallback
function localConnection.onicecandidate(self,e)
if e.candidate then
p_do(remoteConnection:addIceCandidate(e.candidate))
:_catch(function(self,error)
handleAddCandidateError(error)
end)
end
end
function remoteConnection.onicecandidate(self,e)
if e.candidate then
p_do(localConnection:addIceCandidate(e.candidate))
:_catch(function(self,error)
handleAddCandidateError(error)
end)
end
end
p_do(localConnection:createOffer())
:_then(function(self,offer)
return localConnection:setLocalDenoscription(offer)
end)
:_then(function()
local localDenoscription = localConnection.localDenoscription
return remoteConnection:setRemoteDenoscription(localDenoscription)
end)
:_then(function()
return remoteConnection:createAnswer()
end)
:_then(function(self,answer)
return remoteConnection:setLocalDenoscription(answer)
end)
:_then(function()
return localConnection:setRemoteDenoscription(remoteConnection.localDenoscription)
end)
:_catch(function(self,error)
handleCreateDenoscriptionError(error)
end)
end
-- Close the connection, including data channels if they are open.
-- Also update the UI to reflect the disconnected status.
function disconnectPeers()
-- Close the RTCDataChannels if they are open.
sendChannel:close()
receiveChannel:close()
-- Close the RTCPeerConnections
localConnection:close()
remoteConnection:close()
sendChannel = null
receiveChannel = null
localConnection = null
remoteConnection = null
-- Update user interface elements
connectButton.disabled = false
disconnectButton.disabled = true
sendButton.disabled = true
messageInputBox.value = ""
messageInputBox.disabled = true
end
function startup()
connectButton = document:getElementById("connectButton")
disconnectButton = document:getElementById("disconnectButton")
sendButton = document:getElementById("sendButton")
messageInputBox = document:getElementById("message")
receiveBox = document:getElementById("receive-box")
-- Set event listeners for user interface widgets
connectButton:addEventListener("click", connectPeers, false)
disconnectButton:addEventListener("click", disconnectPeers, false)
sendButton:addEventListener("click", sendMessage, false)
end
startup()
And weft.html:
<!doctype html>
<html>
<style>
body {
font-family:
receiveChannel = event.channel
receiveChannel.onmessage = handleReceiveMessage
receiveChannel.onopen = handleReceiveChannelStatusChange
receiveChannel.onclose = handleReceiveChannelStatusChange
end
-- Handle onmessage events for the receiving channel.
-- These are the data messages sent by the sending channel.
function handleReceiveMessage(self,event)
local el = document:createElement("p")
local txtNode = document:createTextNode(event.data)
el:appendChild(txtNode)
receiveBox:appendChild(el)
end
-- Handle status changes on the receiver's channel.
function handleReceiveChannelStatusChange(event)
if (receiveChannel) then
console:log("Receive channel's status has changed to ",receiveChannel.readyState)
end
-- Here you would do stuff that needs to be done
-- when the channel's status changes.
end
function connectPeers()
localConnection = js.new(RTCPeerConnection)
sendChannel = localConnection:createDataChannel("sendChannel")
sendChannel.onopen = handleSendChannelStatusChange
sendChannel.onclose = handleSendChannelStatusChange
remoteConnection = js.new(RTCPeerConnection)
remoteConnection.ondatachannel = receiveChannelCallback
function localConnection.onicecandidate(self,e)
if e.candidate then
p_do(remoteConnection:addIceCandidate(e.candidate))
:_catch(function(self,error)
handleAddCandidateError(error)
end)
end
end
function remoteConnection.onicecandidate(self,e)
if e.candidate then
p_do(localConnection:addIceCandidate(e.candidate))
:_catch(function(self,error)
handleAddCandidateError(error)
end)
end
end
p_do(localConnection:createOffer())
:_then(function(self,offer)
return localConnection:setLocalDenoscription(offer)
end)
:_then(function()
local localDenoscription = localConnection.localDenoscription
return remoteConnection:setRemoteDenoscription(localDenoscription)
end)
:_then(function()
return remoteConnection:createAnswer()
end)
:_then(function(self,answer)
return remoteConnection:setLocalDenoscription(answer)
end)
:_then(function()
return localConnection:setRemoteDenoscription(remoteConnection.localDenoscription)
end)
:_catch(function(self,error)
handleCreateDenoscriptionError(error)
end)
end
-- Close the connection, including data channels if they are open.
-- Also update the UI to reflect the disconnected status.
function disconnectPeers()
-- Close the RTCDataChannels if they are open.
sendChannel:close()
receiveChannel:close()
-- Close the RTCPeerConnections
localConnection:close()
remoteConnection:close()
sendChannel = null
receiveChannel = null
localConnection = null
remoteConnection = null
-- Update user interface elements
connectButton.disabled = false
disconnectButton.disabled = true
sendButton.disabled = true
messageInputBox.value = ""
messageInputBox.disabled = true
end
function startup()
connectButton = document:getElementById("connectButton")
disconnectButton = document:getElementById("disconnectButton")
sendButton = document:getElementById("sendButton")
messageInputBox = document:getElementById("message")
receiveBox = document:getElementById("receive-box")
-- Set event listeners for user interface widgets
connectButton:addEventListener("click", connectPeers, false)
disconnectButton:addEventListener("click", disconnectPeers, false)
sendButton:addEventListener("click", sendMessage, false)
end
startup()
And weft.html:
<!doctype html>
<html>
<style>
body {
font-family:
"Lucida Grande", "Arial", sans-serif;
font-size: 16px;
}
.messagebox {
border: 1px solid black;
padding: 5px;
width: 450px;
}
.buttonright {
float: right;
}
.buttonleft {
float: left;
}
.controlbox {
padding: 5px;
width: 450px;
height: 28px;
}
</style>
<head>
<noscript>WebRTC: Simple RTCDataChannel sample</noscript>
<meta charset="utf-8">
<noscript src="js/adapter-latest.js"></noscript>
<noscript src="/js/fengari-web.js" type="text/javanoscript"></noscript>
<noscript id="weft.fengari" src="/weft.fengari" type="application/lua" async></noscript>
</head>
<body>
<h1>MDN - WebRTC: Simple RTCDataChannel sample</h1>
<p>This sample is an admittedly contrived example of how to use an <code>RTCDataChannel</code> to
exchange data between two objects on the same page. See the
<a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample">
corresponding article</a> for details on how it works.</p>
<div class="controlbox">
<button id="connectButton" name="connectButton" class="buttonleft">
Connect
</button>
<button id="disconnectButton" name="disconnectButton" class="buttonright" disabled>
Disconnect
</button>
</div>
<div class="messagebox">
<label for="message">Enter a message:
<input type="text" name="message" id="message" placeholder="Message text"
inputmode="latin" size=60 maxlength=120 disabled>
</label>
<button id="sendButton" name="sendButton" class="buttonright" disabled>
Send
</button>
</div>
<div class="messagebox" id="receive-box">
<p>Messages received:</p>
</div>
</body>
</html>
https://redd.it/1gxagd6
@r_lua
font-size: 16px;
}
.messagebox {
border: 1px solid black;
padding: 5px;
width: 450px;
}
.buttonright {
float: right;
}
.buttonleft {
float: left;
}
.controlbox {
padding: 5px;
width: 450px;
height: 28px;
}
</style>
<head>
<noscript>WebRTC: Simple RTCDataChannel sample</noscript>
<meta charset="utf-8">
<noscript src="js/adapter-latest.js"></noscript>
<noscript src="/js/fengari-web.js" type="text/javanoscript"></noscript>
<noscript id="weft.fengari" src="/weft.fengari" type="application/lua" async></noscript>
</head>
<body>
<h1>MDN - WebRTC: Simple RTCDataChannel sample</h1>
<p>This sample is an admittedly contrived example of how to use an <code>RTCDataChannel</code> to
exchange data between two objects on the same page. See the
<a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample">
corresponding article</a> for details on how it works.</p>
<div class="controlbox">
<button id="connectButton" name="connectButton" class="buttonleft">
Connect
</button>
<button id="disconnectButton" name="disconnectButton" class="buttonright" disabled>
Disconnect
</button>
</div>
<div class="messagebox">
<label for="message">Enter a message:
<input type="text" name="message" id="message" placeholder="Message text"
inputmode="latin" size=60 maxlength=120 disabled>
</label>
<button id="sendButton" name="sendButton" class="buttonright" disabled>
Send
</button>
</div>
<div class="messagebox" id="receive-box">
<p>Messages received:</p>
</div>
</body>
</html>
https://redd.it/1gxagd6
@r_lua
MDN Web Docs
A simple RTCDataChannel sample - Web APIs | MDN
The RTCDataChannel interface is a feature of the WebRTC API which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the WebSocket API, so that the same programming model can be…
Reading Text in a Status Bar
Greetings, I’m looking for a way to read text from another window, in particular the status bar. I currently do this with an AHK noscript using the StatusbarGetText command. It works well enough but I’m considering switching from Windows to Mac and that means moving away from AHK. This is all for populating an OBS scene so doing it directly in OBS with a lua noscript felt like a good place to start.
If statusbar reading is not possible, I’d be open to other methods, but text files wouldn’t be quick enough.
I realise I haven’t explained the background very well so here is what I currently have set up.
I use a custom build of an emulator to play games and the emulator displays various information in the status bar from the game. An AutoHotKey noscript I made constantly reads the status bar and does various things with it. Some of which is graphical (which OBS displays via window capture) and some (things that can be slower) are exported to text files that OBS, again, does various things with. It’s a bodge, but it works, but as mentioned, I’m wondering if I can now remove the AHK element and have just the emulator and OBS(with lua noscripts)
I’d really appreciate any input. Thanks.
https://redd.it/1gxafs1
@r_lua
Greetings, I’m looking for a way to read text from another window, in particular the status bar. I currently do this with an AHK noscript using the StatusbarGetText command. It works well enough but I’m considering switching from Windows to Mac and that means moving away from AHK. This is all for populating an OBS scene so doing it directly in OBS with a lua noscript felt like a good place to start.
If statusbar reading is not possible, I’d be open to other methods, but text files wouldn’t be quick enough.
I realise I haven’t explained the background very well so here is what I currently have set up.
I use a custom build of an emulator to play games and the emulator displays various information in the status bar from the game. An AutoHotKey noscript I made constantly reads the status bar and does various things with it. Some of which is graphical (which OBS displays via window capture) and some (things that can be slower) are exported to text files that OBS, again, does various things with. It’s a bodge, but it works, but as mentioned, I’m wondering if I can now remove the AHK element and have just the emulator and OBS(with lua noscripts)
I’d really appreciate any input. Thanks.
https://redd.it/1gxafs1
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Please help me learn Lua
I recently switched to Arch Linux, before macOS, where I came into contact with Neovim, Awesomewm, etc., all of which are configured in lua, I myself have learned C, java, etc., and I think I can skip the basic syntax stage when learning lua.
I also tried to find some ways to learn Lua on the Internet.,And then I went to check and learn some big guys' profiles.,But I found that I couldn't understand it.,Of course, some configuration files I put on my computer can also run normally.,But if you want to customize some functions,,I can't do it at all.。
I don't know how I'm going to access the learning lua, please help me!
https://redd.it/1gxxw3x
@r_lua
I recently switched to Arch Linux, before macOS, where I came into contact with Neovim, Awesomewm, etc., all of which are configured in lua, I myself have learned C, java, etc., and I think I can skip the basic syntax stage when learning lua.
I also tried to find some ways to learn Lua on the Internet.,And then I went to check and learn some big guys' profiles.,But I found that I couldn't understand it.,Of course, some configuration files I put on my computer can also run normally.,But if you want to customize some functions,,I can't do it at all.。
I don't know how I'm going to access the learning lua, please help me!
https://redd.it/1gxxw3x
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Lua docs
Hello, I've been learning Lua through docs and I came across this example: https://www.lua.org/pil/10.1.html
db.lua file is calling entry function with the table containing data and in this case they are calling dofile() twice.
I am aware that lua compiles fast but my question is: is there an advantage to doing things this way instead of making db.lua return a table, calling require('db.lua') once and simply passing the table to both entry functions?
https://redd.it/1gyenqc
@r_lua
Hello, I've been learning Lua through docs and I came across this example: https://www.lua.org/pil/10.1.html
db.lua file is calling entry function with the table containing data and in this case they are calling dofile() twice.
I am aware that lua compiles fast but my question is: is there an advantage to doing things this way instead of making db.lua return a table, calling require('db.lua') once and simply passing the table to both entry functions?
https://redd.it/1gyenqc
@r_lua
Help understanding header of a function
I'm trying to understand what the "&" in this function header means
void ChangeColor(const struct FLinearColor& New_Blade_Color, const struct FLinearColor& New_Blade_Glow_Color);
The FLinearColor struct contains 4 attributes (R, G, B and A), all of which are floats; But whenever I try to use the function by passing a table to the parameters it defaults all of them to 0
Hero[2]:ChangeColor({0.9, 0.9, 0.9, 0.9}, {0.9, 0.9, 0.9, 0.9})
(When I access the variables changed by the function they all print '0.0')
What am I doing/understanding wrong here?
https://redd.it/1gym1gu
@r_lua
I'm trying to understand what the "&" in this function header means
void ChangeColor(const struct FLinearColor& New_Blade_Color, const struct FLinearColor& New_Blade_Glow_Color);
The FLinearColor struct contains 4 attributes (R, G, B and A), all of which are floats; But whenever I try to use the function by passing a table to the parameters it defaults all of them to 0
Hero[2]:ChangeColor({0.9, 0.9, 0.9, 0.9}, {0.9, 0.9, 0.9, 0.9})
(When I access the variables changed by the function they all print '0.0')
What am I doing/understanding wrong here?
https://redd.it/1gym1gu
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Obfuscators
Hello everyone,
I decided to create a Discord bot that works as a Lua obfuscator. This is interesting to me because luaobfuscator.com crashes quite often. The bot uses the free API from luaobfuscator.com to obfuscate files uploaded in the server.
It’s no secret that luaobfuscator.com doesn’t provide very strong obfuscation, just something basic to deter skidders. However, if someone really wants the source code, they can still access it without much effort.
I’m looking for a Python-based obfuscator or websites offering APIs for Lua obfuscation. Any help would be appreciated!
https://redd.it/1h00bii
@r_lua
Hello everyone,
I decided to create a Discord bot that works as a Lua obfuscator. This is interesting to me because luaobfuscator.com crashes quite often. The bot uses the free API from luaobfuscator.com to obfuscate files uploaded in the server.
It’s no secret that luaobfuscator.com doesn’t provide very strong obfuscation, just something basic to deter skidders. However, if someone really wants the source code, they can still access it without much effort.
I’m looking for a Python-based obfuscator or websites offering APIs for Lua obfuscation. Any help would be appreciated!
https://redd.it/1h00bii
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
My 100% free obfuscator
Hello,
I created a free Discord obfuscator bot with no hidden costs. It was a great learning experience for me, so it’s a win-win for everyone.
Enjoy!
https://discord.gg/N25mkPRsk9
https://redd.it/1h008x9
@r_lua
Hello,
I created a free Discord obfuscator bot with no hidden costs. It was a great learning experience for me, so it’s a win-win for everyone.
Enjoy!
https://discord.gg/N25mkPRsk9
https://redd.it/1h008x9
@r_lua
Discord
Join the 🔒 LuaMask 0.1 Discord Server!
Check out the 🔒 LuaMask 0.1 community on Discord - hang out with 7 other members and enjoy free voice and text chat.