So I tried Roblox Studio...
It eats 2GB RAM.
Has a Qtitan library around Qt5. LibFbxSDK probably the one from AutoDesk. WebView2 from Microsoft.
And yes, Luau is an interesting extension to Lua...
https://redd.it/1fsq7z6
@r_lua
It eats 2GB RAM.
Has a Qtitan library around Qt5. LibFbxSDK probably the one from AutoDesk. WebView2 from Microsoft.
And yes, Luau is an interesting extension to Lua...
https://redd.it/1fsq7z6
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
fengari-web: Helper functions & ordered, async noscript loader
I've continued messing with Fengari, using it with some js libraries (pixi-js primarily). I do not want to use node, npm, webpack, etc. And, I got tired of require() putting deprecation warnings in my console about synchronous requests.
So, I created this loader and some global helper functions. If someone knows an easier way to do this, please share! If it's somehow useful or interesting...here it is:
<noscript type="application/lua">
js=require('js')
window=js.global
document=window.document
local modules={
'testmod.fengari',
'dramaterm.fengari'
}
await=function(p)
local pco=coroutine.running()
p'then'
coroutine.resume(pco,...)
end)
,result=coroutine.yield()
return result
end
Array = js.global.Array
-- Helper to copy lua table to a new JavaScript Object
-- e.g. Object{mykey="myvalue"}
function Object(t)
local o = js.new(js.global.Object)
for k, v in pairs(t) do
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys")
o[k] = v
end
return o
end
function import(js,t)
-- "imports" parts of a js library into global, for convenience
for , v in ipairs(t) do
ENV[v]=js[v]
end
end
local loadScript=function(src)
local noscript = document:createElement('noscript')
noscript.type='application/lua'
local response=await(window:fetch(src))
local scr=await(response:text())..'\nloader(\''..src..'\')'
noscript.innerHTML=scr
document.head:append(noscript)
window.console:log('Loaded lua noscript',coroutine.yield())
end
local load=function(t)
for ,v in ipairs(t) do
loadScript(v)
end
end
loader=coroutine.wrap(load)
loader(modules)
</noscript>
https://redd.it/1ftkmqa
@r_lua
I've continued messing with Fengari, using it with some js libraries (pixi-js primarily). I do not want to use node, npm, webpack, etc. And, I got tired of require() putting deprecation warnings in my console about synchronous requests.
So, I created this loader and some global helper functions. If someone knows an easier way to do this, please share! If it's somehow useful or interesting...here it is:
<noscript type="application/lua">
js=require('js')
window=js.global
document=window.document
local modules={
'testmod.fengari',
'dramaterm.fengari'
}
await=function(p)
local pco=coroutine.running()
p'then'
coroutine.resume(pco,...)
end)
,result=coroutine.yield()
return result
end
Array = js.global.Array
-- Helper to copy lua table to a new JavaScript Object
-- e.g. Object{mykey="myvalue"}
function Object(t)
local o = js.new(js.global.Object)
for k, v in pairs(t) do
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys")
o[k] = v
end
return o
end
function import(js,t)
-- "imports" parts of a js library into global, for convenience
for , v in ipairs(t) do
ENV[v]=js[v]
end
end
local loadScript=function(src)
local noscript = document:createElement('noscript')
noscript.type='application/lua'
local response=await(window:fetch(src))
local scr=await(response:text())..'\nloader(\''..src..'\')'
noscript.innerHTML=scr
document.head:append(noscript)
window.console:log('Loaded lua noscript',coroutine.yield())
end
local load=function(t)
for ,v in ipairs(t) do
loadScript(v)
end
end
loader=coroutine.wrap(load)
loader(modules)
</noscript>
https://redd.it/1ftkmqa
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
roblox banner tracker
hey, anyone knows how i can do a banner tracker of a game from roblox? idk if i need to use a noscript made in LUA to get the banner information or smth like that. I want to make this for my discord server
https://preview.redd.it/x26yk32so9sd1.png?width=508&format=png&auto=webp&s=2e2df773880e413822080ad47f6dd77cd79c8c67
https://redd.it/1fu7lhc
@r_lua
hey, anyone knows how i can do a banner tracker of a game from roblox? idk if i need to use a noscript made in LUA to get the banner information or smth like that. I want to make this for my discord server
https://preview.redd.it/x26yk32so9sd1.png?width=508&format=png&auto=webp&s=2e2df773880e413822080ad47f6dd77cd79c8c67
https://redd.it/1fu7lhc
@r_lua
Lua & CMake
[Some learning materials](https://github.com/PacktPublishing/Integrate-Lua-with-CPP) recommend integrating [lua](https://www.lua.org/) into your project by manually download the code and unzip it into a subdir. Then use normal source code access and linking to combine its functions with your project.
Many people (like me) use cmake to manage most of the compiling of projects. So I wanted cmake to pull repos and install temporary files without leaving them in the repo. Lua isnt the only external project i regularly reference.
It took me a while to work out exactly how, but i have made a small CMakeLists.txt file that downloads Lua into a build directory for where you can call functions etc without leaving the entire code base behind inside your repo.
[https://github.com/seanbutler/lua-embed-in-cpp-with-cmake](https://github.com/seanbutler/lua-embed-in-cpp-with-cmake)
* I suspect there are still errors in the cmakelist.txt Ive made and would appreciate an experts eye on it and feedback if possible. Do any people on here have similar cmake and lua (accessible, understandable) noscripts in their toolbox?
thanks.
https://redd.it/1fuc4gk
@r_lua
[Some learning materials](https://github.com/PacktPublishing/Integrate-Lua-with-CPP) recommend integrating [lua](https://www.lua.org/) into your project by manually download the code and unzip it into a subdir. Then use normal source code access and linking to combine its functions with your project.
Many people (like me) use cmake to manage most of the compiling of projects. So I wanted cmake to pull repos and install temporary files without leaving them in the repo. Lua isnt the only external project i regularly reference.
It took me a while to work out exactly how, but i have made a small CMakeLists.txt file that downloads Lua into a build directory for where you can call functions etc without leaving the entire code base behind inside your repo.
[https://github.com/seanbutler/lua-embed-in-cpp-with-cmake](https://github.com/seanbutler/lua-embed-in-cpp-with-cmake)
* I suspect there are still errors in the cmakelist.txt Ive made and would appreciate an experts eye on it and feedback if possible. Do any people on here have similar cmake and lua (accessible, understandable) noscripts in their toolbox?
thanks.
https://redd.it/1fuc4gk
@r_lua
GitHub
GitHub - PacktPublishing/Integrate-Lua-with-CPP: , published by Packt
, published by Packt. Contribute to PacktPublishing/Integrate-Lua-with-CPP development by creating an account on GitHub.
fengari-web: improved loader noscript, sends event to all loaded noscripts when the page (and all the lua noscripts) are really loaded
This is an evolution of my previous post, this now does everything I wanted. It allows control over the order of lua noscript loading, enforces sequential loading, and solves the problem of missing window.onload events (or them firing waaay before the lua noscripts are finished loading). loadScript can also be called from any coroutine in global, so dynamic loading of noscripts is easy.
js=require('js')
window=js.global
document=window.document
-- global fengari helper/utility functions
await=function(p)
local pco=coroutine.running()
p'then'
coroutine.resume(pco,...)
end)
,result=coroutine.yield()
return result
end
Array = js.global.Array
-- Helper to copy lua table to a new JavaScript Object
-- e.g. Object{mykey="myvalue"}
function Object(t)
local o = js.new(js.global.Object)
for k, v in pairs(t) do
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys")
o[k] = v
end
return o
end
function elevate(from,members)
-- "elevates" {members} of a js library (from) into global, for convenience
for , v in ipairs(members) do
ENV[v]=from[v]
end
end
loadScript=function(src)
-- find the name of the running coroutine (in global)
local co,coname=coroutine.running()
for k,v in pairs(ENV) do
if (v==co) then
coname=k
break
end
end
if coname==false then
window.console:error('loadScript must be called from a global running coroutine')
return false
else
local noscript = document:createElement('noscript')
noscript.type='application/lua'
noscript.id=src
local response=await(window:fetch(src))
local scr=await(response:text())..'\ncoroutine.resume('..coname..',\''..src..'\')'
noscript.innerHTML=scr
document.head:append(noscript)
window.console:log('Loaded lua noscript',coroutine.yield())
return noscript
end
end
local load=function(t)
local noscripts={}
for ,v in ipairs(t) do
table.insert(noscripts,loadScript(v))
end
for ,noscript in ipairs(noscripts) do
noscript:dispatchEvent(js.new(window.Event,"fullyLoaded"))
end
end
local modules={
'Config.fengari',
'dramaterm.fengari'
}
loaderco=coroutine.create(load)
coroutine.resume(loaderco,modules)
https://redd.it/1fujswq
@r_lua
This is an evolution of my previous post, this now does everything I wanted. It allows control over the order of lua noscript loading, enforces sequential loading, and solves the problem of missing window.onload events (or them firing waaay before the lua noscripts are finished loading). loadScript can also be called from any coroutine in global, so dynamic loading of noscripts is easy.
js=require('js')
window=js.global
document=window.document
-- global fengari helper/utility functions
await=function(p)
local pco=coroutine.running()
p'then'
coroutine.resume(pco,...)
end)
,result=coroutine.yield()
return result
end
Array = js.global.Array
-- Helper to copy lua table to a new JavaScript Object
-- e.g. Object{mykey="myvalue"}
function Object(t)
local o = js.new(js.global.Object)
for k, v in pairs(t) do
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys")
o[k] = v
end
return o
end
function elevate(from,members)
-- "elevates" {members} of a js library (from) into global, for convenience
for , v in ipairs(members) do
ENV[v]=from[v]
end
end
loadScript=function(src)
-- find the name of the running coroutine (in global)
local co,coname=coroutine.running()
for k,v in pairs(ENV) do
if (v==co) then
coname=k
break
end
end
if coname==false then
window.console:error('loadScript must be called from a global running coroutine')
return false
else
local noscript = document:createElement('noscript')
noscript.type='application/lua'
noscript.id=src
local response=await(window:fetch(src))
local scr=await(response:text())..'\ncoroutine.resume('..coname..',\''..src..'\')'
noscript.innerHTML=scr
document.head:append(noscript)
window.console:log('Loaded lua noscript',coroutine.yield())
return noscript
end
end
local load=function(t)
local noscripts={}
for ,v in ipairs(t) do
table.insert(noscripts,loadScript(v))
end
for ,noscript in ipairs(noscripts) do
noscript:dispatchEvent(js.new(window.Event,"fullyLoaded"))
end
end
local modules={
'Config.fengari',
'dramaterm.fengari'
}
loaderco=coroutine.create(load)
coroutine.resume(loaderco,modules)
https://redd.it/1fujswq
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Learning Lua.
I’ve been learning Lua for Roblox, I know most of the basics and the advanced parts a little.
Is there any specific tip on how to actually master it..?
https://redd.it/1fuj71g
@r_lua
I’ve been learning Lua for Roblox, I know most of the basics and the advanced parts a little.
Is there any specific tip on how to actually master it..?
https://redd.it/1fuj71g
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How can I find out the bytecode version if it is not at the beginning of the file?
https://redd.it/1fvl5qe
@r_lua
https://redd.it/1fvl5qe
@r_lua
Terminating Lua Scripts from C++
I need to unconditionally terminate Lua noscripts called from my C++ code.
I've tried using Lua hooks and lua_error, but this doesn't fully terminate noscripts due to internal pcalls. Using lua_close causes segmentation faults because it closes the Lua state while lua_pcall is still active.
I attempted C++ exception handling by throwing exceptions, but pcall catches them, preventing proper termination. My last resort is using longjmp, which I want to avoid in a C++ codebase.
I receive multiple Lua noscripts that run in a single thread with an interval-based scheduler. If a noscript doesn't complete within its defined execution interval (e.g., 500ms), it needs to be terminated.
I’m currently using Lua hooks to check execution time every 10,000 instructions and plan to switch to Linux timers later.
What are my options to safely terminate Lua noscripts in this environment? Any help would be appreciated!
https://redd.it/1fw36w0
@r_lua
I need to unconditionally terminate Lua noscripts called from my C++ code.
I've tried using Lua hooks and lua_error, but this doesn't fully terminate noscripts due to internal pcalls. Using lua_close causes segmentation faults because it closes the Lua state while lua_pcall is still active.
I attempted C++ exception handling by throwing exceptions, but pcall catches them, preventing proper termination. My last resort is using longjmp, which I want to avoid in a C++ codebase.
I receive multiple Lua noscripts that run in a single thread with an interval-based scheduler. If a noscript doesn't complete within its defined execution interval (e.g., 500ms), it needs to be terminated.
I’m currently using Lua hooks to check execution time every 10,000 instructions and plan to switch to Linux timers later.
What are my options to safely terminate Lua noscripts in this environment? Any help would be appreciated!
https://redd.it/1fw36w0
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
can you please fix for me ?
can you please fix this for me idk its possible or not . is there any way to left click with 3-4 reapeat for rapidfire without right click or any other I know there is right click version
i want a lua like just ScrollLock on/off and 1 left click 3-4 reapeat + MouseRelative move
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("ScrollLock") then
if IsMouseButtonPressed(1) then
repeat
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0, 4)
for _ = 1, 4 do
PressMouseButton(1)
Sleep(5)
ReleaseMouseButton(1)
end
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(1)
end
end
end
https://redd.it/1fw579b
@r_lua
can you please fix this for me idk its possible or not . is there any way to left click with 3-4 reapeat for rapidfire without right click or any other I know there is right click version
i want a lua like just ScrollLock on/off and 1 left click 3-4 reapeat + MouseRelative move
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("ScrollLock") then
if IsMouseButtonPressed(1) then
repeat
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0, 4)
for _ = 1, 4 do
PressMouseButton(1)
Sleep(5)
ReleaseMouseButton(1)
end
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(1)
end
end
end
https://redd.it/1fw579b
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Easy Gui designing with export code tool
Is there no tool which i can easily drag and drop buttons labels whatever to design an gui and afterwards export the lua the only one i can think of is in roblox studio which is crazy ive been looking for a few days and couldnt find any software thats insane
https://redd.it/1fw6z24
@r_lua
Is there no tool which i can easily drag and drop buttons labels whatever to design an gui and afterwards export the lua the only one i can think of is in roblox studio which is crazy ive been looking for a few days and couldnt find any software thats insane
https://redd.it/1fw6z24
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Thinking about learning lua
In short I'm thinking about learning lua. Is it a fun language like python and what's the main reason ppl use it. Is it versatile or fun. This is coming from a junior java dev.
https://redd.it/1fw9km9
@r_lua
In short I'm thinking about learning lua. Is it a fun language like python and what's the main reason ppl use it. Is it versatile or fun. This is coming from a junior java dev.
https://redd.it/1fw9km9
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Contributing to building a new package manager
Hey everyone!
We’re working on Nebula Pack, a new open-source package manager for Lua, and we’re looking for collaborators—beginners very much included! If you’ve ever been frustrated with LuaRocks, especially when trying to set it up on non-Unix systems, we’re on the same page. That’s exactly why we’re building Nebula Pack: to make something way more intuitive and accessible.
The project’s backend is being built in Go, and we’re handling the CLI in Go too, with plans to create the compiler in Rust (but we’re open to alternatives). Right now, we’ve got a solid API in beta, but there’s still a ton to do—adding features, building a database, and automating configurations for C/low-level language projects so they play nicely as Lua modules.
No matter your experience level, this is a great chance to dive into a real-world project, learn from the process, and help create something cool that could really help the Lua and LOVE2D community.
Sound interesting? Check out the project on GitHub and feel free to jump in. Whether you’ve got experience or you’re just getting started, we’d love to have you. Reach out to me at keagangilmore@gmail.com if you’ve got any questions, or just want to chat!
GitHub Links:
- My Github
- Nebula Pack
Let’s make something awesome together!
https://redd.it/1fwplgm
@r_lua
Hey everyone!
We’re working on Nebula Pack, a new open-source package manager for Lua, and we’re looking for collaborators—beginners very much included! If you’ve ever been frustrated with LuaRocks, especially when trying to set it up on non-Unix systems, we’re on the same page. That’s exactly why we’re building Nebula Pack: to make something way more intuitive and accessible.
The project’s backend is being built in Go, and we’re handling the CLI in Go too, with plans to create the compiler in Rust (but we’re open to alternatives). Right now, we’ve got a solid API in beta, but there’s still a ton to do—adding features, building a database, and automating configurations for C/low-level language projects so they play nicely as Lua modules.
No matter your experience level, this is a great chance to dive into a real-world project, learn from the process, and help create something cool that could really help the Lua and LOVE2D community.
Sound interesting? Check out the project on GitHub and feel free to jump in. Whether you’ve got experience or you’re just getting started, we’d love to have you. Reach out to me at keagangilmore@gmail.com if you’ve got any questions, or just want to chat!
GitHub Links:
- My Github
- Nebula Pack
Let’s make something awesome together!
https://redd.it/1fwplgm
@r_lua
GitHub
KeaganGilmore - Overview
🚀 AI Applications Engineer @lx-library | Go, Python, Lua (Game Dev) | React | Rust Novice
🔧 Building @Nebula-Pack - Lua Package Manager - KeaganGilmore
🔧 Building @Nebula-Pack - Lua Package Manager - KeaganGilmore
Why io.tmpfile() requires admin privilege?
Hi. Just picked up Lua. this code doesn't run without admin privilege in windows. I wonder why creating tmpfile needs privilege. I assume it creates the file in the memory and not on storage. I'm on windows. the code I'm trying to run:
f = assert(io.tmpfile())
f:write ("some data here") -- write to it
https://redd.it/1fwuuzk
@r_lua
Hi. Just picked up Lua. this code doesn't run without admin privilege in windows. I wonder why creating tmpfile needs privilege. I assume it creates the file in the memory and not on storage. I'm on windows. the code I'm trying to run:
f = assert(io.tmpfile())
f:write ("some data here") -- write to it
https://redd.it/1fwuuzk
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Need help finding a game engine to create mobile 2d games on lua
Im trying to search some good games engines to make 2d mobile games and it must be free and im also good at lua. Hope someone helps
https://redd.it/1fxn104
@r_lua
Im trying to search some good games engines to make 2d mobile games and it must be free and im also good at lua. Hope someone helps
https://redd.it/1fxn104
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Roblox private servers
I know next to nothing about coding. When a Roblox private server link is clicked, it first opens a browser tab with a "roblox.com/share?code=(random numbers and letters) which changes to "roblox.com/games/(game number and name)?privateServerLinkCode=" can someone help me connect directly to the private server once the link is clicked? (my goal is to join a private server faster than anyone else can join) Any help would be much appreciated.
https://redd.it/1fxywu6
@r_lua
I know next to nothing about coding. When a Roblox private server link is clicked, it first opens a browser tab with a "roblox.com/share?code=(random numbers and letters) which changes to "roblox.com/games/(game number and name)?privateServerLinkCode=" can someone help me connect directly to the private server once the link is clicked? (my goal is to join a private server faster than anyone else can join) Any help would be much appreciated.
https://redd.it/1fxywu6
@r_lua
Can Someone make me a esp line hack for the game Graal Online era?
Hi can someone make a esp line that takes you to the trash and the mushrooms in the game?
https://redd.it/1fyc2wg
@r_lua
Hi can someone make a esp line that takes you to the trash and the mushrooms in the game?
https://redd.it/1fyc2wg
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Compiling LuaX on Debian - an extended Lua interpreter
https://youtu.be/0097f_-nztE
https://redd.it/1fzb1ra
@r_lua
https://youtu.be/0097f_-nztE
https://redd.it/1fzb1ra
@r_lua
YouTube
Compiling LuaX on Debian - an extended Lua interpreter
0:00 Intro
0:19 Overview
1:02 Built-in modules
4:34 Standalone executables
6:29 Compiling LuaX
8:21 Modifying bootstrap.sh and build.lua
9:03 Installing ninja-build
9:50 Modifying the prefix for zig
11:43 Running bootstrap.sh
13:27 Installing LuaX (to a custom…
0:19 Overview
1:02 Built-in modules
4:34 Standalone executables
6:29 Compiling LuaX
8:21 Modifying bootstrap.sh and build.lua
9:03 Installing ninja-build
9:50 Modifying the prefix for zig
11:43 Running bootstrap.sh
13:27 Installing LuaX (to a custom…
Garry's Mod default chat box not showing up anymore
A while ago I started a game mode for fun and recently got back into making it.
I made a chat box using the Garry's mod wiki tutorial. I came back and wanted to remake it so I deleted my chat.lua file and all trace of that chat box inside the game mode folder, for some reason the default Garry's mod chat box doesn't show up anymore.
I've tried making a new dedicated server, tried reinstalling gmod (including deleting the directory), and tried commenting out other vgui elements. At last I am stumped and have no idea what is going on.
Any help / idea's is appreciated.
Edit: I should mention i would post in r/GLua but that community seems pretty dead.
https://redd.it/1fzjx89
@r_lua
A while ago I started a game mode for fun and recently got back into making it.
I made a chat box using the Garry's mod wiki tutorial. I came back and wanted to remake it so I deleted my chat.lua file and all trace of that chat box inside the game mode folder, for some reason the default Garry's mod chat box doesn't show up anymore.
I've tried making a new dedicated server, tried reinstalling gmod (including deleting the directory), and tried commenting out other vgui elements. At last I am stumped and have no idea what is going on.
Any help / idea's is appreciated.
Edit: I should mention i would post in r/GLua but that community seems pretty dead.
https://redd.it/1fzjx89
@r_lua
Garry's Mod Wiki
Advanced Chatbox
How can I get this noscript so it repeats until toggled off?
I will paste my current lua noscript below. I am doing this Logitech Ghub. This is currently a test. In this test I click the button on my mouse and toggles the noscript on which then makes 10 mouse movements and then stops. I want this to constantly repeat until I click the same button to toggle it off after it completes the current cycle. I am not a coder and have only been using Google/Youtube/AI so any assistance is appreciated.
-- Declare a global variable for toggling the noscript
local toggle = false
-- Define a key to toggle the noscript on/off (you can set any key, e.g., 5 for mouse button 5)
local toggleKey = 5 -- Change this to the button or key you want to use
-- Function to handle mouse movements
function moveMouse()
OutputLogMessage("moveMouse started\n")
-- Perform the mouse movements step by step, checking the toggle after each step
if toggle then
OutputLogMessage("Moving to (4567, 22267)\n")
MoveMouseTo(4567, 22267)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (47667, 22367)\n")
MoveMouseTo(47667, 22367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 22367)\n")
MoveMouseTo(49667, 22367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 25367)\n")
MoveMouseTo(49667, 25367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 45067)\n")
MoveMouseTo(49667, 45067)
Sleep(1000)
end
OutputLogMessage("moveMouse completed\n")
end
-- This function runs when the toggle key is pressed
function OnEvent(event, arg)
if event == "MOUSEBUTTONPRESSED" and arg == toggleKey then
toggle = not toggle -- Switch the toggle value (on/off)
OutputLogMessage("Toggle button pressed. New toggle state: %s\n", tostring(toggle))
if toggle then
OutputLogMessage("Script Started\n")
moveMouse() -- Call the function to move the mouse when toggled on
else
OutputLogMessage("Script Stopped\n")
end
end
end
https://redd.it/1fzol4l
@r_lua
I will paste my current lua noscript below. I am doing this Logitech Ghub. This is currently a test. In this test I click the button on my mouse and toggles the noscript on which then makes 10 mouse movements and then stops. I want this to constantly repeat until I click the same button to toggle it off after it completes the current cycle. I am not a coder and have only been using Google/Youtube/AI so any assistance is appreciated.
-- Declare a global variable for toggling the noscript
local toggle = false
-- Define a key to toggle the noscript on/off (you can set any key, e.g., 5 for mouse button 5)
local toggleKey = 5 -- Change this to the button or key you want to use
-- Function to handle mouse movements
function moveMouse()
OutputLogMessage("moveMouse started\n")
-- Perform the mouse movements step by step, checking the toggle after each step
if toggle then
OutputLogMessage("Moving to (4567, 22267)\n")
MoveMouseTo(4567, 22267)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (47667, 22367)\n")
MoveMouseTo(47667, 22367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 22367)\n")
MoveMouseTo(49667, 22367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 25367)\n")
MoveMouseTo(49667, 25367)
Sleep(1000)
end
if toggle then
OutputLogMessage("Moving to (49667, 45067)\n")
MoveMouseTo(49667, 45067)
Sleep(1000)
end
OutputLogMessage("moveMouse completed\n")
end
-- This function runs when the toggle key is pressed
function OnEvent(event, arg)
if event == "MOUSEBUTTONPRESSED" and arg == toggleKey then
toggle = not toggle -- Switch the toggle value (on/off)
OutputLogMessage("Toggle button pressed. New toggle state: %s\n", tostring(toggle))
if toggle then
OutputLogMessage("Script Started\n")
moveMouse() -- Call the function to move the mouse when toggled on
else
OutputLogMessage("Script Stopped\n")
end
end
end
https://redd.it/1fzol4l
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community