lua and python
hello! i've been wanting to learn lua for a while, so i can learn how to make a certain roblox game. but i was thinking about python because it is a better software, if i learned python first, in a few years would lua be easier?
https://redd.it/1p4ouby
@r_lua
hello! i've been wanting to learn lua for a while, so i can learn how to make a certain roblox game. but i was thinking about python because it is a better software, if i learned python first, in a few years would lua be easier?
https://redd.it/1p4ouby
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Linked List speed vs table, not as expected?
I wrote a basic SLL implementation as part of my learning process with Lua and decided to do a bit of execution time testing to see how it held up compared to tables. Now, I recognize that tables are highly optimized, but I was a little surprised by what I found. Using a Linked List as a queue or stack had the same results, but it is taking a little more than twice as long as using a table (stack only, queue it is way slower).
Any idea why it is so much slower when both the Linked List and the table should be operating in O(n) time?
Here is the Linked List module
Here is the Linked List tester noscript and the table tester.
Cheers!
https://redd.it/1p658ch
@r_lua
I wrote a basic SLL implementation as part of my learning process with Lua and decided to do a bit of execution time testing to see how it held up compared to tables. Now, I recognize that tables are highly optimized, but I was a little surprised by what I found. Using a Linked List as a queue or stack had the same results, but it is taking a little more than twice as long as using a table (stack only, queue it is way slower).
Any idea why it is so much slower when both the Linked List and the table should be operating in O(n) time?
Here is the Linked List module
Here is the Linked List tester noscript and the table tester.
Cheers!
https://redd.it/1p658ch
@r_lua
How to do a noscript that detects when a capture card freezes and then deactivates and reactivates the capture card to fix it when obs or the noscript is bad at detecting when the capture card froze?
So I have a capture that has a problem to randomly freeze at least once during certain points but the problem is when it freezes audio still is going through perfectly and I think obs recognizes it as not frozen however when it freezes it stays frozen on a certain frame during the stream and only gets fix from activating and reactivating but the problem with any noscript I tried is they can’t detect when the freezing occurs because I believe obs doesn’t even detect the capture card froze since audio still goes through. So is it possible at all to fix this issue with a noscript or something that does work?
https://redd.it/1p66bbp
@r_lua
So I have a capture that has a problem to randomly freeze at least once during certain points but the problem is when it freezes audio still is going through perfectly and I think obs recognizes it as not frozen however when it freezes it stays frozen on a certain frame during the stream and only gets fix from activating and reactivating but the problem with any noscript I tried is they can’t detect when the freezing occurs because I believe obs doesn’t even detect the capture card froze since audio still goes through. So is it possible at all to fix this issue with a noscript or something that does work?
https://redd.it/1p66bbp
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Working with arbitrary numbers of args, emulating Python's slice?
This has come up as I've been working with the language and it hasn't been a problem yet, but I could see it being an issue. I think the easiest way to explain my question is to give an example:
If I run this with
This functionality with slices is really handy when you want to deal with an arbitrary number of arguments in a noscript.
In Lua, I've been working with varargs a bit, but my understanding of them is limited. Particularly, how you could go from a table of given arguments (the built-in
https://redd.it/1p7by1n
@r_lua
This has come up as I've been working with the language and it hasn't been a problem yet, but I could see it being an issue. I think the easiest way to explain my question is to give an example:
import sys
# Print the given args, starting with the third and continuing through any number of given args
def printargs(*args):
for a in args:
print(a)
printargs(*sys.argv[2:])
If I run this with
runfile(args='a b c d e'), it will print:b
c
d
e
This functionality with slices is really handy when you want to deal with an arbitrary number of arguments in a noscript.
In Lua, I've been working with varargs a bit, but my understanding of them is limited. Particularly, how you could go from a table of given arguments (the built-in
arg table) to a vararg to give to a function, starting at a given index? Or maybe this isn't a relevant problem when working with Lua?https://redd.it/1p7by1n
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Starting In Lua
Hello, I've been interested in learning how to program in Lua because I want to make Roblox games for fun and also get a sense of what programming is about. So I'm here to ask: how did you start learning? Is there any free online program that's worth it? Your experiences and advice would be a lot of help.
Thank you!
https://redd.it/1p7kgs4
@r_lua
Hello, I've been interested in learning how to program in Lua because I want to make Roblox games for fun and also get a sense of what programming is about. So I'm here to ask: how did you start learning? Is there any free online program that's worth it? Your experiences and advice would be a lot of help.
Thank you!
https://redd.it/1p7kgs4
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Writing compact code - how do I check for multiple possibilities all at once in the shortest statement possible?
I'm a relative newbie to Lua and I'm curious about ways to very compactly write a check for multiple possible values. Consider the following code:
Obviously functional for an if statement, but I want to know if there's a less repetitious way to write it. Does Lua have any tricks for making this more compact? If so, could these tricks be scaled up for checking large numbers of possible values all at once?
https://redd.it/1p7msep
@r_lua
I'm a relative newbie to Lua and I'm curious about ways to very compactly write a check for multiple possible values. Consider the following code:
if value ~= "a" and value ~= "b" and value ~= "c" thenObviously functional for an if statement, but I want to know if there's a less repetitious way to write it. Does Lua have any tricks for making this more compact? If so, could these tricks be scaled up for checking large numbers of possible values all at once?
https://redd.it/1p7msep
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Convert C header file to more machine-readable format?
Is anybody aware of a standard for specifying the API of an object file (lib.so) besides a C header file (.h file)?
I'm designing my own assembly language and want to consume and link headers to link with dynamic libraries produced by C. It would be nice to not need to implement my own C compiler to do so.
https://redd.it/1p8it8l
@r_lua
Is anybody aware of a standard for specifying the API of an object file (lib.so) besides a C header file (.h file)?
I'm designing my own assembly language and want to consume and link headers to link with dynamic libraries produced by C. It would be nice to not need to implement my own C compiler to do so.
https://redd.it/1p8it8l
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Can someone tell me why this code doesn't work
Simply trying to iterate through a table, and nothing is printed out, why?
local myTable = {}
local myStruct = {}
myStruct.myValue = 5
myStruct.myOtherValue = "Bears"
myTable"Joe" = myStruct
myTable"Suzy" = myStruct
for name, struct in pairs(myTable) do
print("myValue= " .. struct.myValue.. ", myOtherValue = " .. struct.myOtherValue .. "\n")
end
https://redd.it/1p8n16f
@r_lua
Simply trying to iterate through a table, and nothing is printed out, why?
local myTable = {}
local myStruct = {}
myStruct.myValue = 5
myStruct.myOtherValue = "Bears"
myTable"Joe" = myStruct
myTable"Suzy" = myStruct
for name, struct in pairs(myTable) do
print("myValue= " .. struct.myValue.. ", myOtherValue = " .. struct.myOtherValue .. "\n")
end
https://redd.it/1p8n16f
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
It is possible to make a desktop app with lua?
I'm trying to work on a project of desktop app fully on lua but I struggle to find something out of love2D (I'm not sure it's the most adapted for the project but that is currently my backup option) to make the graphical interface.
Do you have any recommendations?
https://redd.it/1p8qi58
@r_lua
I'm trying to work on a project of desktop app fully on lua but I struggle to find something out of love2D (I'm not sure it's the most adapted for the project but that is currently my backup option) to make the graphical interface.
Do you have any recommendations?
https://redd.it/1p8qi58
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Need help with a discontinued balatro mod
Firstly I can pay you up to $25... In robux, I have no digital bank account so I'm limited to that if you want money for that.
If your interested "money"wise or not, I want whoever is interested to do a couple things. 1. The balatro mod has a library, a compact to work with another dependent mod. and the mod itself, I would like all of them combined. 2. I would also like it updated to the latest Smod + Lovely. If your still interested in that, feel free to tell.
https://redd.it/1p9d0kc
@r_lua
Firstly I can pay you up to $25... In robux, I have no digital bank account so I'm limited to that if you want money for that.
If your interested "money"wise or not, I want whoever is interested to do a couple things. 1. The balatro mod has a library, a compact to work with another dependent mod. and the mod itself, I would like all of them combined. 2. I would also like it updated to the latest Smod + Lovely. If your still interested in that, feel free to tell.
https://redd.it/1p9d0kc
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Looking for feedback on simple Love2D program - how to cleanly write this code?
I'm learning the LÖVE framework and having a good time covering the basics. I've currently made a little program that shows a series of text, one word at a time, while bouncing around the screen like a screensaver from the 90's. So far, it works, but I'm looking for ways to make the code nicer and avoid developing bad habits.
The code uses the [tick](https://github.com/rxi/tick) library to do changes every second. This also uses a separate "words" file that holds the full text in a table, word by word (in this case, the Gettysburg address, but any list of words will do). Here's the full main file:
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth() - font:getWidth(speech[word_count])
if x_switch == 1 and x_coord + x_switch*x_speed*dt > x_stopper then
x_switch = -1
end
if x_switch == -1 and x_coord + x_switch*x_speed*dt < 0 then
x_switch = 1
end
if y_switch == 1 and y_coord + y_switch*y_speed*dt > y_stopper then
y_switch = -1
end
if y_switch == -1 and y_coord + y_switch*y_speed*dt < 0 then
y_switch = 1
end
x_coord = x_coord + x_switch*x_speed*dt
y_coord = y_coord + y_switch*y_speed*dt
end
function love.draw()
love.graphics.print(speech[word_count], x_coord, y_coord)
end
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth()
I'm learning the LÖVE framework and having a good time covering the basics. I've currently made a little program that shows a series of text, one word at a time, while bouncing around the screen like a screensaver from the 90's. So far, it works, but I'm looking for ways to make the code nicer and avoid developing bad habits.
The code uses the [tick](https://github.com/rxi/tick) library to do changes every second. This also uses a separate "words" file that holds the full text in a table, word by word (in this case, the Gettysburg address, but any list of words will do). Here's the full main file:
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth() - font:getWidth(speech[word_count])
if x_switch == 1 and x_coord + x_switch*x_speed*dt > x_stopper then
x_switch = -1
end
if x_switch == -1 and x_coord + x_switch*x_speed*dt < 0 then
x_switch = 1
end
if y_switch == 1 and y_coord + y_switch*y_speed*dt > y_stopper then
y_switch = -1
end
if y_switch == -1 and y_coord + y_switch*y_speed*dt < 0 then
y_switch = 1
end
x_coord = x_coord + x_switch*x_speed*dt
y_coord = y_coord + y_switch*y_speed*dt
end
function love.draw()
love.graphics.print(speech[word_count], x_coord, y_coord)
end
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth()
GitHub
GitHub - rxi/tick: Lua module for delaying function calls
Lua module for delaying function calls. Contribute to rxi/tick development by creating an account on GitHub.