• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


30 Nov, 2024

Updated at 02 Dec, 2024

Are there list contractions, as it would make the code much simpler and neater

Hello All,

Essentially, I have a list of parts that’s created at the start of the script, called ‘Fronts’.
Every 10th of a second, we need to send the CFrames of all of these parts to the server.
At the moment the code to get those looks like this:

local CFrames = {}
for i,v in ipairs(Fronts) do
    table.insert(CFrames,v.CFrame)
end

But this looks rather messy!
In python it is possible to use a list contraction, and the code would look something like this:

CFrames = [v.CFrame for v in Fronts]

This looks much neater to write and use!
If this exists in Lua, please let me know how to do it. It would really clean up my code.
Thanks!

1 post - 1 participant

Read full topic