Lua - Reddit – Telegram
Lua - Reddit
31 subscribers
281 photos
31 videos
4.28K links
News and discussion for the Lua programming language.

Subreddit: https://www.reddit.com/r/lua

Powered by : @r_channels & @reddit2telegram
Download Telegram
I legit need help what on earth is math.huge I'm actually confused. Please tell me I'm trying to know what it is.



https://redd.it/1e56wtw
@r_lua
Lua compiler

Does anybody know where I can download the iGO LUA Software mentioned in this modding guide:

https://www.techpowerup.com/forums/threads/tropico-5-small-modding-tutorial.201529/

Obviously the link provided in the guide doesn’t work.

I would also appreciate suggestions with the same functionality that aren’t overly complicated to use.

Just for clarification: I’m not looking for a lua decompiler (like unluac) that make lua files that show a bunch of nonsense in the editor readable but the reverse software that compiles them into the original “nonsense” form.

https://redd.it/1e5qf9q
@r_lua
what is the difference between Lua and Luan?

Best way to Learn Lua Language?
some Tips?

Learn in the Roblox Studio or maybe Visual Studio Code? What is the difference?

Difference between Lua and Luan?
Guys pleas help.!

https://redd.it/1e5ulzv
@r_lua
Problem with Luarocks Module

I correctly installed luarocks without any error and installed a module but I get an error with:

require "myModule"

because Lua can't find the path where I've installed it. I've also tried with:

require "myPath\\myModule.lua

But I get the same error. How can I solve it?

Thanks in advance

https://redd.it/1e695sl
@r_lua
Where do I start learning

Hello,

One of the metaverse I play has started using lua as language for their noscripting and I'm a 3d artist who wants to tap in the other side of gamedev. I really wanna learn lua to break the wall. So, as a non coder background, where do I start?

https://redd.it/1e6li92
@r_lua
Logitech noscript help.

ive gotten a working noscript to move my mouse to doa 180 degree turn. Its set to MB4. However i want to use that noscript in a macro. So if i press MB5 it will be input as MB4 (noscript), then shift. But when i tried this by remapping mb5 to shift, delay, mb4. It just outputs as if i pressed shift.

MoveAmount = -900

function OnEvent(event, arg)

OutputLogMessage("event = %s, arg = %d\\n", event, arg)

if (event == "PROFILE_ACTIVATED") then

EnablePrimaryMouseButtonEvents(true)

elseif event == "PROFILE_DEACTIVATED" then

ReleaseMouseButton(4) -- to prevent it from being stuck on

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then

for x=1,10,1

do

MoveMouseRelative(MoveAmount, 0)

Sleep(5)

end

end

end

this is the noscript. im not sure how to get the newly mapped macro to use it

https://redd.it/1e6tn5h
@r_lua
Isn't the code supposed to be right? (Roblox)
https://redd.it/1e70w8v
@r_lua
Do I always need to type lua main.lua into the terminal to run my code?

I'm using the terminal in vs code, if that is any consolation thanks. Just started learning

https://redd.it/1e7f6n6
@r_lua
How would you handler a function that returns depending on outcome, different amount of values?



https://redd.it/1e82tp7
@r_lua
Need help with lua noscript please!

Im trying to make a rapid fire (left click) noscript to work with my logitech mouse. I want it to continuously left click when both right and left click are being held at the same time, and to end when either right or left click are released(but especially left). I need both left and right click to still function as normal when only 1 of them are pressed.
this is what i have so far but the noscript only ends when right click is released.
i have tried changing the last 2 IsMouseButtonPressed(3) to IsMouseButtonPressed(1) but then the noscript just stops working compleatly


EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)

if IsKeyLockOn("scrolllock" )then -- scrolllock / On/OFF

if IsMouseButtonPressed(3) then

-- OutputLogMessage("check") --debugging

repeat



if IsMouseButtonPressed(1)then

-- OutputLogMessage("Rapid Fire") --debugging

repeat

PressMouseButton(1)

Sleep(15)

ReleaseMouseButton(1)

Sleep(15)

until not IsMouseButtonPressed(3)



end

until not IsMouseButtonPressed(3)

end

end

end

https://redd.it/1e85n5o
@r_lua
can anyone perform an edit of a .lua noscript for me?

Hello everyone,

I am using the Conky program on Linux Mint, and I am trying to get text displayed on a curved path. I wanted a semi-circle starting at 270 degrees and ending at 90 degrees. I worked with online resources but they could only generate text from 0 to 180 or 180 to 360. Here is the closed the bot could get:

require 'cairo'



function conky_half_curved_text_final()

if conky_window == nil then return end



local surface = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)

local cr = cairo_create(surface)



-- Set the text you want to display

local text = "Your Custom Text Here" -- <-- Change this to your desired text



-- Set the center of the circular path

local center_x = 180

local center_y = 180



-- Set the radius of the circular path

local radius = 100



-- Set the starting and ending angles in radians

local start_angle = -math.pi / 2 -- 270 degrees

local end_angle = math.pi / 2 -- 90 degrees



-- Set the font and size

cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)

cairo_set_font_size(cr, 20)



-- Calculate the angle step based on the text length and the angular span

local text_length = string.len(text)

local angular_span = end_angle - start_angle

local angle_step = angular_span / (text_length - 1) -- -1 because angle_step is between characters



-- Set the color (R, G, B, Alpha)

cairo_set_source_rgba(cr, 0, 1, 0, 1) -- Green color



-- Draw the half-circular path only where the text will be placed

cairo_set_line_width(cr, 1)

cairo_arc(cr, center_x, center_y, radius, start_angle, end_angle)

cairo_stroke(cr)



-- Loop through each character in the text

for i = 0, text_length - 1 do

local angle = start_angle + i * angle_step

local x = center_x + radius * math.cos(angle)

local y = center_y + radius * math.sin(angle)



-- Rotate the context so the text is properly oriented along the path

cairo_save(cr)

cairo_translate(cr, x, y)

cairo_rotate(cr, angle + math.pi / 2) -- Adjust rotation to ensure proper orientation

cairo_move_to(cr, 0, 0)

cairo_show_text(cr, text:sub(i + 1, i + 1))

cairo_restore(cr)

end



cairo_destroy(cr)

cairo_surface_destroy(surface)

end


Can anyone edit this to a proper half circle display without an underline please?

Thank you for reading,


Logan

https://redd.it/1e8jykr
@r_lua
Hello. I could use some help with a Lua noscript I am using in Coppeliasim for a project. The lua noscript is used to program a robot arm, the type is dobot. More details in the body.

Within CoppeliaSim, a conveyor belt brings boxes from left to right to the robot station. The boxes are aligned one by one, and it means there is no two boxes arriving at robot station at the same time.The boxes on conveyor have two types of colors – green and red.

At the end of conveyor belt, depth camera sensor is installed to detect the box’s color and position to send the information to robot arm controller.

Robotic arm picks the box at the end of the conveyor belt and place the box on the green or red table, according to the color of the box (e.g., green box to Green Table, and red box to Red table).

The robot arm places all the red boxes at the same co-ordinates on the red table and places the green boxes on the same co-ordinates on the green table. This causes the boxes to collide into each other. I would like to know how to change the drop pose of the robot dynamically so that the boxes are placed next to each other. I have listed the noscript of the robot arm below. Would appreciate any help given.

--RobotArm

function sysCall_init()

flagSet = false

homePose =      {0  *math.pi/180,    0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

pickUpPose1 =   {-20*math.pi/180,    0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

pickUpPose2 =   {-20*math.pi/180,   50*math.pi/180, 47*math.pi/180,  0*math.pi/180}

corout=coroutine.create(coroutineMain)

prevActionComplete = true

end

 

function sysCall_actuation()

if coroutine.status(corout)\~='dead' then

local ok,errorMsg=coroutine.resume(corout)

if errorMsg then

error(debug.traceback(corout,errorMsg),2)

end

else

corout=coroutine.create(coroutineMain)

end

end

 

function movCallback(config, vel, accel, handles)

for i=1,#handles,1 do

if sim.isDynamicallyEnabled(handles[i\]) then

sim.setJointTargetPosition(handles[i\], config[i\])

else   

sim.setJointPosition(handles[i\], config[i\])

end

end

end

 

function moveToConfig(handles, maxVel, maxAccel, maxJerk, targetConf, enable)

local currentConf={}

for i=1,#handles,1 do

currentConf[i\]=sim.getJointPosition(handles[i\])

targetConf[i\]=targetConf[i\]

end

sim.moveToConfig(-1, currentConf, nil, nil, maxVel, maxAccel, maxJerk, targetConf, nil, movCallback, handles)

 

if enable then

sim.writeCustomDataBlock(gripperHandle, 'activity', 'on')

else

sim.writeCustomDataBlock(gripperHandle, 'activity', 'off')

end

end

 

function coroutineMain()

modelBase=sim.getObject('.')

gripperHandle=sim.getObject('./suctionCup_link2')

motorHandles = {}

for i=1,4,1 do

motorHandles[i\]=sim.getObject('./motor'..i)

end

auxMotor1=sim.getObject('./auxMotor1')

auxMotor2=sim.getObject('./auxMotor2')

local vel=22 

local accel=40

local jerk=80

local maxVel={vel*math.pi/180, vel*math.pi/180, vel*math.pi/180, vel*math.pi/180}

local maxAccel={accel*math.pi/180, accel*math.pi/180, accel*math.pi/180, accel*math.pi/180}

local maxJerk={jerk*math.pi/180, jerk*math.pi/180, jerk*math.pi/180, jerk*math.pi/180}

   

if flagSet then

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, pickUpPose1, false)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, pickUpPose2, true)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, pickUpPose1, true)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, dropPose1, true)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, dropPose2, false)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, dropPose1, false)

moveToConfig(motorHandles, maxVel, maxAccel, maxJerk, homePose, false)

prevActionComplete = true

flagSet = false

end

end

 

function sysCall_joint(inData)

local jointError = 0  -- Initialize jointError to zero

if inData.handle == auxMotor1 then

local t2 = sim.getJointPosition(motorHandles[2\])

local t3 = sim.getJointPosition(motorHandles[3\])

jointError = t3 - t2 - inData.pos

end

if inData.handle == auxMotor2 then

local t3 =
sim.getJointPosition(motorHandles[3\])

jointError = -t3 - inData.pos

end

 

local ctrl = jointError * 20

local maxVelocity = ctrl

if (maxVelocity > inData.maxVel) then

maxVelocity = inData.maxVel

end

if (maxVelocity < -inData.maxVel) then

maxVelocity = -inData.maxVel

end

local forceOrTorqueToApply = inData.maxForce

 

local outData = {vel = maxVelocity, force = forceOrTorqueToApply}

return outData

end

 

function sampleFunc(color)

if prevActionComplete then

flagSet = true

currentBoxColor = color

homePose =      {0  *math.pi/180,    0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

pickUpPose1 =   {-20*math.pi/180,    0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

pickUpPose2 =   {-20*math.pi/180,   50*math.pi/180, 47*math.pi/180,  0*math.pi/180}



-- Set drop poses based on the box color (in radians)

if color == "red" then

dropPose1 = {-110*math.pi/180,   0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

dropPose2 = {-110*math.pi/180,  50*math.pi/180, 47*math.pi/180,  0*math.pi/180}

elseif color == "green" then

dropPose1 = {110*math.pi/180,   0*math.pi/180,  0*math.pi/180,  0*math.pi/180}

dropPose2 = {110*math.pi/180,  50*math.pi/180, 47*math.pi/180,  0*math.pi/180}

end



prevActionComplete = false

return flagSet

else

return false

end

end



https://redd.it/1e8mne7
@r_lua
lua is so difficult

i watch a lot of tutorials and still nothing, im losing hope now

https://redd.it/1e8re5f
@r_lua
Fandom wikia coding help module using LUA

local p = {}

function p.calculateAlchValue(frame)
local shop_value_str = frame.args[1] or ""
local shop_value = tonumber(shop_value_str)


-- Check if the conversion was successful
if not shop_value then
return "Error: Invalid or missing shop_value. Received: " .. tostring(shop_value_str)
end

local percentage = 1.3754
local result = math.ceil(shop_value * percentage)

return tostring(result)
end

return p

This isn't working, everytime I enter a value that uses dynamic values aka shop\_value, it displays the error as: `Error: Invalid or missing shop_value. Received: 1150`
When I open the visual editor bam, theres the actual answer of 1582. But only in the visual editor...

If I send the code:

{{Item
| Item name = {{PAGENAME}}
| Item Image = [[File:{{PAGENAME}}.png]]
| tradeable = Yes
| stackable = No
| examine = It is a(n) {{PAGENAME}}.
| shop_value = 1150
| alch_value = {{#invoke:CalcAlchValue|calculateAlchValue|1150}}
| noteable = Yes
}}

It returns the correct value of 1582. I really just don't understand this crap lol

The code I'm using on the page:

{{Item
| Item name = {{PAGENAME}}
| Item Image = [[File:{{PAGENAME}}.png]]
| tradeable = Yes
| stackable = No
| examine = It is a(n) {{PAGENAME}}.
| shop_value = 1150
| alch_value = {{#invoke:CalcAlchValue|calculateAlchValue|{{{shop_value}}}}}
| noteable = Yes
}}

If anyone knows how to fix any of this, I've reached out to different sub-reddits, and even fandom support, used GPT to help, but nothing has worked so far.

Links to the fandom pages: [https://remote-realms.fandom.com/wiki/Module:CalcAlchValue](https://remote-realms.fandom.com/wiki/Module:CalcAlchValue) | [https://remote-realms.fandom.com/wiki/Palatine\_ore](https://remote-realms.fandom.com/wiki/Palatine_ore)



https://redd.it/1e91mn7
@r_lua
How to display an image pop up mid-battle?

Hi, I am making a fighting game on Ikemen and I need to make the game display some images at a certain point during a battle in storymode,the images have to be displayed above the fighters (like a pop-up).The point is I do not know how to do this in Ikemen and I don't even know if that is possible. Is there a way using maybe Lua modules (or even something else) to achieve that?Many thanks!

https://redd.it/1ea97n7
@r_lua
Hackable Lua noscript for Linux to escape reinstalling things from scratch
https://codeberg.org/onuelito/lsdm

https://redd.it/1eadeba
@r_lua
I Cant Execute Codes

So i decided to learn lua and settled up everything, when it comes to running the code, the code doesnt displays on the terminal, please help!!!

https://redd.it/1eahkg6
@r_lua