Skip to main content

Questions tagged [lua-table]

This tag refers to the table type in Lua that implements associative arrays.

lua-table
1 vote
0 answers
22 views

Can I change the default hash function?

I is possible to change the default hash function that lua (or luajit) uses for the HashTable part of a talbe ? I want to speedup table access in pure Lua. I saw that: The Default hash function for ...
Benjamin V's user avatar
2 votes
1 answer
65 views

Lua table.sort invokes the comparing function with the same element

I have stumbled upon a strange behavior of table.sort(), in which the comparing function is invoked by passing the same array element in both parameters. Consider the code below. I want to sort the ...
Claudi's user avatar
  • 5,336
4 votes
2 answers
84 views

Is there a way to use <const> inside a Lua table?

Since Lua 5.4, the <const> syntax lets us set const variables. I noticed that this doesn't transitively affect fields inside a table. local x <const> = { a = {1,2,3}, b = {5,6,7} } ...
rbv's user avatar
  • 457
0 votes
1 answer
41 views

Roblox Studio Lua: Variable changing without being referenced

This is my module script: local phases = {} local function getRoleAssignments(playersToAssignRoles, roles) --Assigns a random player to each role then removes player from list so player can't ...
boombuster2000's user avatar
2 votes
1 answer
75 views

How can I convert a String that is formatted like a table, into a table?

I did find a version of this for a string into a table that splits up the letters of the string, but I have a table, that I turn into a string to remove the first part of it, and now I want it back as ...
Asher Roland's user avatar
1 vote
1 answer
34 views

Comparing multiple values in a table makes it that it choses to compare only one randomly

I am making a tetris clone in love2d (lua) for practice. And what I am trying to do is to make the collins with the walls. Note:the tetris pieces are made out of tiles that each one has a relative ...
Snibo's user avatar
  • 13
0 votes
0 answers
54 views

Fivem JS not updating UI

I'm having trouble getting my script to update the UI with Lua data. I've handled the JavaScript part to the best of my ability as I'm reacquainting myself with frontend development. My friend and I ...
Menace's user avatar
  • 1
1 vote
1 answer
54 views

Dual representation and proxies to achieve privacy in Lua

I am reading Programming in Lua, 4th edition with an intention to solve every exercise in that book. The last exercise in Chapter 21 p. 172 is the following (emphs are mine): A variation of the dual ...
LRDPRDX's user avatar
  • 653
0 votes
1 answer
42 views

Avoid for table of table to mantain same memory allocation when inserted to another table [duplicate]

In Lua 5.3, I have a table t1 in which there is only a table, the latter table consisting only of a key [key] pointing to the value 1. t1 = {{key = 1}} My goal is to copy and insert the inner table ...
Plush's user avatar
  • 1
2 votes
3 answers
254 views

Lua: is there a need to use hash of string as a key in lua tables

I want to keep a list of words (let's say 20k). The only purpose of it is to check if the given word exists there. So, it's going be something known as a hash set. -- dict here is just an example, it'...
papirosnik's user avatar
1 vote
1 answer
47 views

How to reference first entry in keyless table in Lua?

I have a table defined like so: local foo = { bar = { { ['baz'] = "A sample string", ['qux'] = 128 }, }, } Obviously, the is a small part of a much larger algorithm. I'...
Jim Fell's user avatar
  • 14.1k
-1 votes
1 answer
43 views

How to make table from io.read in lua

I want to make a Table in lua with io.read, This is my code: local members = {} io.write("How many members you wanna add? ") local memberNum = io.read("n") print("Add new ...
M3gan3_sama's user avatar
0 votes
1 answer
53 views

Is it possible to use a variable as a field name in a lua table?

I am new to Lua and am writing a program for a tool changer on my CNC machine. Each tool pocket's detail is stored as an entry in a table, the table looks like: local PocketDetails = { ...
TTalma's user avatar
  • 1
2 votes
1 answer
43 views

Lua table created in C returns strange values for integers

I want to create a nested table, that shall look like this: { SA_1: {1,2,3,4}, SA_2: {11,22,33,44} } The code I have (I changed the SA_2 to strings for testing purposes): int myRegisteredCfunc: { ...
ddomnik's user avatar
  • 63
2 votes
1 answer
53 views

How to remove elements inside a table based on a value of those elements?

Iam trying to remove elements in a table which have a certain value test = { { id = 473385593, deleted = true, }, { id = 473385619, deleted = true, }, ...
Tollpatsch's user avatar

15 30 50 per page
1
2 3 4 5
95