Redbean + Fengari = fun
I've posted several times on here lately about fengari, but I haven't mentioned Redbean and I don't see a lot of reference to it in the sub.
Anybody else using these two together?
https://redd.it/1h1wivb
@r_lua
I've posted several times on here lately about fengari, but I haven't mentioned Redbean and I don't see a lot of reference to it in the sub.
Anybody else using these two together?
https://redd.it/1h1wivb
@r_lua
lua-language-server cant be called even after adding to path in windows
https://redd.it/1h20r2d
@r_lua
https://redd.it/1h20r2d
@r_lua
Weird Lua file
Hi! i opened a .lua file and it looked like this :
LuaQ P A@ E \ ÁÀ Å Ü AA E \ ÁÁ Å Ü B A E Â \ B Á Å C Ü ÆÃ Ü Ã EÃ F Ä ZC B C AC EÃ F Ä Ä À KÃD Á \C @ KCE \C d
i used unluac tool, and i got a more readable version of it.
If i would like to get back to that version ? what should i do ?
can someone tell me if it has been encrypted or it is compiled code?
Thanks a lot in advance
https://redd.it/1h2p9lg
@r_lua
Hi! i opened a .lua file and it looked like this :
LuaQ P A@ E \ ÁÀ Å Ü AA E \ ÁÁ Å Ü B A E Â \ B Á Å C Ü ÆÃ Ü Ã EÃ F Ä ZC B C AC EÃ F Ä Ä À KÃD Á \C @ KCE \C d
i used unluac tool, and i got a more readable version of it.
If i would like to get back to that version ? what should i do ?
can someone tell me if it has been encrypted or it is compiled code?
Thanks a lot in advance
https://redd.it/1h2p9lg
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Does anyone have any experience with MapleStory worlds orhave any input about doing this as a project.
https://redd.it/1h2rheo
@r_lua
https://redd.it/1h2rheo
@r_lua
luajit autogui, how to use it
i recently came accross this github post. i need help cuz idk how to use it or does it even work
https://redd.it/1h3ccvl
@r_lua
i recently came accross this github post. i need help cuz idk how to use it or does it even work
https://redd.it/1h3ccvl
@r_lua
GitHub
GitHub - exqt/LuaJITAutoGUI: Automate keyboard&mouse input with LuaJIT
Automate keyboard&mouse input with LuaJIT. Contribute to exqt/LuaJITAutoGUI development by creating an account on GitHub.
Is this extension idiomatic Lua? Will it do more harm than good?
C-extension, isstring.c:
#include "precompile.h"
static int isstring (lua_State *L) {
luaL_checkany (L, 1);
/*
int lua_type (lua_State *L, int index);
Returns the type of the value in the given acceptable index, or
LUA_TNONE for a non-valid index (that is, an index to an "empty"
stack position). The types returned by lua_type are coded by the
following constants defined in lua.h: LUA_TNIL, LUA_TNUMBER,
LUA_TBOOLEAN, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION,
LUA_TUSERDATA, LUA_TTHREAD, and LUA_TLIGHTUSERDATA. */
lua_pushboolean (L, lua_type (L, 1) == LUA_TSTRING ? 1 : 0);
return 1;
}
int luaopen_isstring (lua_State *L) {
lua_pushcfunction (L, isstring);
return 1;
}
Yes, this can be done in Lua. But to allay efficiency concerns.
usage:
local isstring = require 'isstring'
string.is = isstring
assert (string.is 'adsfasdf')
assert (string.is (9) == false)
for i, v in ipairs {'asdvxc', string, string.is} do
if string.is (v) then print ('is a string:', v)
else print ('not a string:', v) end
end
-- optional metatable.__call
local meta = getmetatable (string)
if not meta then
meta = {}
setmetatable (string, meta)
end
meta.__call = function (self, v) return isstring (v) end
assert (string 'asdfasdf' == true)
assert (string (9) == false)
old = "if type (x) == 'string' then"
new = 'if string (x) then'
print (table.concat ({
'\n-------------------------------------------',
old,
'vs',
new,
string.format (
'\nYou are saved typing %d characters! Wowza!', #old - #new)
}, '\n'))
output:
is a string: asdvxc
not a string: table: 007E0910
not a string: function: 007E31D8
-------------------------------------------
if type (x) == 'string' then
vs
if string (x) then
You are saved typing 10 characters! Wowza!
__call metamethod on the standard string table is not used
currently, might as well give it some use. Already have `tostring` for
string construction
https://redd.it/1h3ueqi
@r_lua
C-extension, isstring.c:
#include "precompile.h"
static int isstring (lua_State *L) {
luaL_checkany (L, 1);
/*
int lua_type (lua_State *L, int index);
Returns the type of the value in the given acceptable index, or
LUA_TNONE for a non-valid index (that is, an index to an "empty"
stack position). The types returned by lua_type are coded by the
following constants defined in lua.h: LUA_TNIL, LUA_TNUMBER,
LUA_TBOOLEAN, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION,
LUA_TUSERDATA, LUA_TTHREAD, and LUA_TLIGHTUSERDATA. */
lua_pushboolean (L, lua_type (L, 1) == LUA_TSTRING ? 1 : 0);
return 1;
}
int luaopen_isstring (lua_State *L) {
lua_pushcfunction (L, isstring);
return 1;
}
Yes, this can be done in Lua. But to allay efficiency concerns.
usage:
local isstring = require 'isstring'
string.is = isstring
assert (string.is 'adsfasdf')
assert (string.is (9) == false)
for i, v in ipairs {'asdvxc', string, string.is} do
if string.is (v) then print ('is a string:', v)
else print ('not a string:', v) end
end
-- optional metatable.__call
local meta = getmetatable (string)
if not meta then
meta = {}
setmetatable (string, meta)
end
meta.__call = function (self, v) return isstring (v) end
assert (string 'asdfasdf' == true)
assert (string (9) == false)
old = "if type (x) == 'string' then"
new = 'if string (x) then'
print (table.concat ({
'\n-------------------------------------------',
old,
'vs',
new,
string.format (
'\nYou are saved typing %d characters! Wowza!', #old - #new)
}, '\n'))
output:
is a string: asdvxc
not a string: table: 007E0910
not a string: function: 007E31D8
-------------------------------------------
if type (x) == 'string' then
vs
if string (x) then
You are saved typing 10 characters! Wowza!
__call metamethod on the standard string table is not used
currently, might as well give it some use. Already have `tostring` for
string construction
https://redd.it/1h3ueqi
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Whats a weird way you do something in lua?
I found that I do oop kind of weirdly and wondered if anyone also did stuff weirdly (granted it has to work).
https://redd.it/1h4874o
@r_lua
I found that I do oop kind of weirdly and wondered if anyone also did stuff weirdly (granted it has to work).
https://redd.it/1h4874o
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
What's the conventional technique in Lua for ordered list maintenance?
While tables provide a dictionary (hash), Lua doesn't have, outside of explicit sort, ordered lists. I'm curious what conventional best practice for this problem. Red//Black, AVL, or B trees? Haul in an in-memory DB library such as SQLite and eat the overhead of SQL queries?
What does the wisdom of the crowd say here?
https://redd.it/1h49eoo
@r_lua
While tables provide a dictionary (hash), Lua doesn't have, outside of explicit sort, ordered lists. I'm curious what conventional best practice for this problem. Red//Black, AVL, or B trees? Haul in an in-memory DB library such as SQLite and eat the overhead of SQL queries?
What does the wisdom of the crowd say here?
https://redd.it/1h49eoo
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Can't Manage to Make HTTP calls for a game mod
First of all, I must say I have no prior modding or Lua background. But, I wanted to create a mod for Baldur's Gate 3 by using BG3 Script Extender, which allows people to write Lua noscripts to interact with the game state.
So, I wanted to see if I could manage to write a Lua noscript that can communicate with SteelSeries Game Engine to manipulate my keyboard's lights, to react to game state (e.g. character health bar on function keys as green light).
With the help of ChatGPT I generated a simple Lua noscript for my use case, which utilizes `socket.http` library:
local http = require("socket.http")
-- Perform the GET request
local response_body, status_code, response_headers = http.request("https://jsonplaceholder.typicode.com/todos/1")
-- Print the response
print("Status Code:", status_code) -- Similar to `response.status`
print("Response Body:", response_body) -- Similar to `response.text()`
local function parse_json(json_str)
local result = {}
for key, value in json_str:gmatch('"([^"]+)":%s*("?.-["}]?)%s*[,%}]') do
-- Remove quotes from keys and values if present
key = key:gsub('"', '')
if value:match('^".*"$') then
value = value:sub(2, -2) -- Remove quotes for strings
elseif value == "true" then
value = true
elseif value == "false" then
value = false
elseif tonumber(value) then
value = tonumber(value)
end
result[key] = value
end
return result
end
-- Parse the JSON response
local data = parse_json(response_body)
-- Access the parsed data
print("Title:", data.noscript)
print("Completed:", data.completed)
The [jsonplaceholder.typicode.com](http://jsonplaceholder.typicode.com) link is only there to test if I can manage to make a call and get a result. I would then replace it with my local Game Engine server URL to communicate with the peripherals.
It seemed to work fine when I ran the Lua noscript using **Lua.exe**. However, after I packaged the noscript and added it as a mod to the game, the Script Extender threw an error:
Loading bootstrap noscript: Mods/SteelSeriesLights/ScriptExtender/Lua/BootstrapServer.lua
bg3se::ExtensionStateBase::LuaLoadGameFile(): Script file could not be opened: Mods/SteelSeriesLights/ScriptExtender/Lua/socket.http
bg3se::lua::State::LoadScript(): Failed to execute noscript: [string "SteelSeriesLights/Server/lights.lua"]:4: attempt to index a nil value (local 'http')
stack traceback:
SteelSeriesLights/Server/lights.lua:4: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/FileLoader.lua:34: in function <builtin://Libs/FileLoader.lua:6>
(...tail calls...)
SteelSeriesLights/BootstrapServer.lua:1: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/ModLoader.lua:68: in method 'LoadBootstrap'
builtin://BuiltinLibrary.lua:26: in function <builtin://BuiltinLibrary.lua:25>
From what I can understand, it is interpreting `local http = require("socket.http")` expression as a module file that I created next to my main noscript. To get around this, I checked if I could just put the whole [socket.http code](https://github.com/lunarmodules/luasocket/blob/master/src/http.lua) within the noscript itself, but it also seems to have other dependencies.
Coming from a JavaScript background, I expected to be able to call a method like **fetch** that is built-in to the language, but so far I failed to accomplish my task.
If you could direct me toward any documentation or topic about Lua that might help me understand how to make it work, I would highly appreciate it\^\^
https://redd.it/1h52czt
@r_lua
First of all, I must say I have no prior modding or Lua background. But, I wanted to create a mod for Baldur's Gate 3 by using BG3 Script Extender, which allows people to write Lua noscripts to interact with the game state.
So, I wanted to see if I could manage to write a Lua noscript that can communicate with SteelSeries Game Engine to manipulate my keyboard's lights, to react to game state (e.g. character health bar on function keys as green light).
With the help of ChatGPT I generated a simple Lua noscript for my use case, which utilizes `socket.http` library:
local http = require("socket.http")
-- Perform the GET request
local response_body, status_code, response_headers = http.request("https://jsonplaceholder.typicode.com/todos/1")
-- Print the response
print("Status Code:", status_code) -- Similar to `response.status`
print("Response Body:", response_body) -- Similar to `response.text()`
local function parse_json(json_str)
local result = {}
for key, value in json_str:gmatch('"([^"]+)":%s*("?.-["}]?)%s*[,%}]') do
-- Remove quotes from keys and values if present
key = key:gsub('"', '')
if value:match('^".*"$') then
value = value:sub(2, -2) -- Remove quotes for strings
elseif value == "true" then
value = true
elseif value == "false" then
value = false
elseif tonumber(value) then
value = tonumber(value)
end
result[key] = value
end
return result
end
-- Parse the JSON response
local data = parse_json(response_body)
-- Access the parsed data
print("Title:", data.noscript)
print("Completed:", data.completed)
The [jsonplaceholder.typicode.com](http://jsonplaceholder.typicode.com) link is only there to test if I can manage to make a call and get a result. I would then replace it with my local Game Engine server URL to communicate with the peripherals.
It seemed to work fine when I ran the Lua noscript using **Lua.exe**. However, after I packaged the noscript and added it as a mod to the game, the Script Extender threw an error:
Loading bootstrap noscript: Mods/SteelSeriesLights/ScriptExtender/Lua/BootstrapServer.lua
bg3se::ExtensionStateBase::LuaLoadGameFile(): Script file could not be opened: Mods/SteelSeriesLights/ScriptExtender/Lua/socket.http
bg3se::lua::State::LoadScript(): Failed to execute noscript: [string "SteelSeriesLights/Server/lights.lua"]:4: attempt to index a nil value (local 'http')
stack traceback:
SteelSeriesLights/Server/lights.lua:4: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/FileLoader.lua:34: in function <builtin://Libs/FileLoader.lua:6>
(...tail calls...)
SteelSeriesLights/BootstrapServer.lua:1: in main chunk
[C++ Code]: in field 'Include'
builtin://Libs/ModLoader.lua:68: in method 'LoadBootstrap'
builtin://BuiltinLibrary.lua:26: in function <builtin://BuiltinLibrary.lua:25>
From what I can understand, it is interpreting `local http = require("socket.http")` expression as a module file that I created next to my main noscript. To get around this, I checked if I could just put the whole [socket.http code](https://github.com/lunarmodules/luasocket/blob/master/src/http.lua) within the noscript itself, but it also seems to have other dependencies.
Coming from a JavaScript background, I expected to be able to call a method like **fetch** that is built-in to the language, but so far I failed to accomplish my task.
If you could direct me toward any documentation or topic about Lua that might help me understand how to make it work, I would highly appreciate it\^\^
https://redd.it/1h52czt
@r_lua
How do i include a function from another lua?
I mean i know how to include a lua
But how do i use the functions of that lua?
like
local importantthing = require("importantthing")
How do i call a function from it?
https://redd.it/1h5mbkm
@r_lua
I mean i know how to include a lua
But how do i use the functions of that lua?
like
local importantthing = require("importantthing")
How do i call a function from it?
https://redd.it/1h5mbkm
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
AoC Lua Template
Hey all, not sure if anyone here is doing Advent of Code, but I created a lua template that some of you may find helpful: https://github.com/lcpichette/aoc-lua-template
Good luck, and happy holidays to all
https://redd.it/1h5y7w5
@r_lua
Hey all, not sure if anyone here is doing Advent of Code, but I created a lua template that some of you may find helpful: https://github.com/lcpichette/aoc-lua-template
Good luck, and happy holidays to all
https://redd.it/1h5y7w5
@r_lua
GitHub
GitHub - lcpichette/aoc-lua-template
Contribute to lcpichette/aoc-lua-template development by creating an account on GitHub.
FiveM Lua Help
Hello,
So basically purchased a FiveM noscript for esx and went to ask the creator for help on making the reward black money or dirty money instead of cash and he basically told me to screwoff. Kind of ignorant for such a small request BUT I do need some help on this code so that I am able to have it give players black money instead of clean money. Thanks in advance and for your time.
The code is as follows:
RegisterServerEvent('sh-boomerphone:sellItem', function(itemName, count, price)
local src = source
if framework == 'esx' then
local xPlayer = ESX.GetPlayerFromId(src);
if not xPlayer then return false end
if xPlayer.getInventoryItem(itemName)?.count >= count then
xPlayer.removeInventoryItem(itemName, count)
xPlayer.addMoney(price * count)
end
https://redd.it/1h5y70l
@r_lua
Hello,
So basically purchased a FiveM noscript for esx and went to ask the creator for help on making the reward black money or dirty money instead of cash and he basically told me to screwoff. Kind of ignorant for such a small request BUT I do need some help on this code so that I am able to have it give players black money instead of clean money. Thanks in advance and for your time.
The code is as follows:
RegisterServerEvent('sh-boomerphone:sellItem', function(itemName, count, price)
local src = source
if framework == 'esx' then
local xPlayer = ESX.GetPlayerFromId(src);
if not xPlayer then return false end
if xPlayer.getInventoryItem(itemName)?.count >= count then
xPlayer.removeInventoryItem(itemName, count)
xPlayer.addMoney(price * count)
end
https://redd.it/1h5y70l
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How to learn to make a Lanczos/Magic Kernel GIF downscaler in Lua?
I already wrote a decoder that gets all the frames’ pixel color data
https://redd.it/1h61hqz
@r_lua
I already wrote a decoder that gets all the frames’ pixel color data
https://redd.it/1h61hqz
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
GitHub - james2doyle/raylib-luajit-generated: An attempt at Raylib LuaJit bindings that are generated from the raylib-parser API docs
https://github.com/james2doyle/raylib-luajit-generated
https://redd.it/1h6mi3v
@r_lua
https://github.com/james2doyle/raylib-luajit-generated
https://redd.it/1h6mi3v
@r_lua
GitHub
GitHub - james2doyle/raylib-luajit-generated: An attempt at Raylib LuaJit bindings that are generated from the raylib-parser API…
An attempt at Raylib LuaJit bindings that are generated from the raylib-parser API docs - james2doyle/raylib-luajit-generated
Why do people still use lua?
Luau outclasses any form of lua out currently with much nicer source code and overall better features + native makes it as fast as gcc c++ so why do people use this irrelevant language?
https://redd.it/1h6zrmf
@r_lua
Luau outclasses any form of lua out currently with much nicer source code and overall better features + native makes it as fast as gcc c++ so why do people use this irrelevant language?
https://redd.it/1h6zrmf
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
where do you learn lua for noscripting in games like roblox?
as the noscript says i wanna learn lua but idk how i should go about it or where i would learn it from
https://redd.it/1h7lt41
@r_lua
as the noscript says i wanna learn lua but idk how i should go about it or where i would learn it from
https://redd.it/1h7lt41
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I am a roblox client or local sided developer and I want to make a client sided path finding service for a sword fighting ai that already has the moving part and attacking now I just wanted to add path finding so it's better any help?
So I've been working on a sword fighting bot on the client and I need some help read the noscript to see what I need help with.
https://redd.it/1h7r12l
@r_lua
So I've been working on a sword fighting bot on the client and I need some help read the noscript to see what I need help with.
https://redd.it/1h7r12l
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Lua Help
I dont know how to use lua and i want to learn, but there are no websites to learn lua
https://redd.it/1h7vbr7
@r_lua
I dont know how to use lua and i want to learn, but there are no websites to learn lua
https://redd.it/1h7vbr7
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Hercules - A Lua Obfuscator
Hercules is a Lua Obfuscator ive been working on for a bit, as a fun project. I was looking for people to review it, and give me some constructive criticism on what I can do better. Ive linked the GitHub Repository below.
https://github.com/zeusssz/hercules-obfuscator
https://redd.it/1h8561m
@r_lua
Hercules is a Lua Obfuscator ive been working on for a bit, as a fun project. I was looking for people to review it, and give me some constructive criticism on what I can do better. Ive linked the GitHub Repository below.
https://github.com/zeusssz/hercules-obfuscator
https://redd.it/1h8561m
@r_lua
GitHub
GitHub - zeusssz/hercules-obfuscator: A powerful Lua obfuscator designed to make your Lua code nearly impossible to reverse-engineer…
A powerful Lua obfuscator designed to make your Lua code nearly impossible to reverse-engineer, with multiple layers of advanced obfuscation techniques - zeusssz/hercules-obfuscator
Key swapping Lua Scripts for 9 keys (PRTSC - PGDN)
Key swapping Lua Scripts for 9 keys (PRTSC - PGDN) to be NumPad keys (1 - 9) instead.
don't think I ever use these keys unless for something very specific but it can change back with another profile.
Is there anyone who can write this seeing as I have no clue to write noscripts at all. Thanks in advance.
https://redd.it/1h8d9dg
@r_lua
Key swapping Lua Scripts for 9 keys (PRTSC - PGDN) to be NumPad keys (1 - 9) instead.
don't think I ever use these keys unless for something very specific but it can change back with another profile.
Is there anyone who can write this seeing as I have no clue to write noscripts at all. Thanks in advance.
https://redd.it/1h8d9dg
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I can't get this example code from Logitech G HUB Lua API to run
function OnEvent(event, arg)
if (event == "M_PRESSED" and arg == 1 ) then
--M1 has been pressed
end
end
In the console it says loaded
https://redd.it/1h8jzsd
@r_lua
function OnEvent(event, arg)
if (event == "M_PRESSED" and arg == 1 ) then
--M1 has been pressed
end
end
In the console it says loaded
https://redd.it/1h8jzsd
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community