Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
148 views

I am making a card game and im now revamping how individual card information is stored. a single card would have the following values: x, y, suit, number, state this is to be stored in a deck array ...
Mounif Alzougbi's user avatar
1 vote
1 answer
100 views

So I have the following table: local table_arr = { a = 3, b = 42, c = 10 } And my for loop: for x=1, #table_arr do local key, value = table_arr[x], arr[ table_arr[x] ] print(key) -...
C0nw0nk's user avatar
  • 992
2 votes
3 answers
107 views

As I understand Lua, an array is just a table where the keys start at 1 and increment sequentially. However, there are features within Lua to manipulate arrays in the traditional sense (e.g. ipairs, ...
deltamind106's user avatar
1 vote
1 answer
64 views

I have a code: function subsets(t) local res={} local res_t={} function subs(i) if i>#t then res[#res+1]=res_t return end res_t[#res_t+1]...
Saf Whale's user avatar
0 votes
2 answers
93 views

I'm trying to make a dance floor that lights up and changes colors periodically. So far I've gotten the game to load and pick a random color from the array upon loading, but I can't make the tiles ...
Shinikage's user avatar
0 votes
0 answers
98 views

Lua table (ref) index changes its values without assigning any to them. Why does ref table change its values after assigning it to tab[c] or using string.match()? The actual behavior is that the ref ...
Jepamb's user avatar
  • 1
-1 votes
1 answer
78 views

I program in Lua and I need some help: I have file1.lua and file2.lua In file1.lua: loadstring('print("Hello World!")') in file2.lua: _loadstring = loadstring function loadstring(code) ...
kaleb sociais's user avatar
1 vote
0 answers
32 views

I have this function that takes a string (s) and returns a table depending on what I entered. function String2Faction(s) if s == "Nomads" then return Faction_Nomads elseif s =...
Xano's user avatar
  • 11
3 votes
1 answer
80 views

I started learning Lua recently, as far as I can tell, when I don't specify the index, the function table.insert tries to put the value in the first nil in the table. Why then is it that in table t ...
Rafael's user avatar
  • 31
0 votes
1 answer
483 views

I'm trying to make my first Roblox studio game and I ran into this problem: attempt to call missing method 'UpdateCharacter' of table attempt to call missing method 'Equip' of table Any function ...
Oscar Charlo's user avatar
1 vote
1 answer
101 views

In lua, if we try to index a series of nested table (any of which can be nil), we might write code like this: -- try to get a.b.c local ret if a then local b = a.b if b then ret = b.c ...
lhh2001's user avatar
  • 31
1 vote
1 answer
56 views

Like I got two tables: {["a"] = "aaa"} and {["b"] = "bbb"} And make it into one table: {["a"] = "aaa", ["b"] = "bbb"} I ...
Sapbot SCS's user avatar
2 votes
1 answer
30 views

Here's code for a timer: local copyTable = require("Helpers.copyTable") local timer = {} timer.max = 0 timer.time = 0 function timer:add(dt) timer.time = timer.time + dt end function ...
Jackson Kidwell's user avatar
3 votes
2 answers
151 views

Why does the table.unpack() function print the unpacked table only if there is nothing following the function? > print(table.unpack({1,2,3})) 1 2 3 > print(table.unpack({1,2,3}),&...
4a6166's user avatar
  • 33
1 vote
1 answer
81 views

So I'm trying to make a table of all the creatures in a game, each creature consisting of a table with their stats. I used the creature's name as the key in the first table, but now I need to get that ...
Gabriel's user avatar
  • 25
2 votes
1 answer
52 views

a={ {11,22,33} } How to remove a[1][1] aka 11 with table.remove() so it becomes a={ {22,33} }? In the pico8 lua it is del(a[1],a[1][1]) I have no idea what table.remove(a[1],a[1][1]) is doing, it ...
kite's user avatar
  • 313
0 votes
1 answer
83 views

I am at a complete loss with the syntax to parse a LuaTable. I have a table that follows the following structure: mission = { ["coalition"] = { ["blue"] = ...
Francisco Benito's user avatar
1 vote
1 answer
233 views

So I have an array of creatures from a game, each one is just the name as a string. I want to iterate over each one and create a table for each one that contains all of the creatures stats, hp, damage,...
Gabriel's user avatar
  • 25
1 vote
1 answer
64 views

A function f() returns multiple values, which are to be fed into a second function g(). I cannot change f(), but I can change g() and all calls to it. I'm wondering if it's possible to say which ...
finefoot's user avatar
  • 11.6k
4 votes
2 answers
154 views

The source code for every Lua release is available in one handy package, which can be extracted and the versions can be compiled all at once: wget https://www.lua.org/ftp/lua-all.tar.gz tar xvf lua-...
finefoot's user avatar
  • 11.6k
2 votes
0 answers
105 views

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
123 views

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,436
4 votes
2 answers
453 views

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
  • 505
0 votes
1 answer
93 views

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
171 views

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
46 views

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
1 vote
1 answer
82 views

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
  • 691
0 votes
1 answer
68 views

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
2k views

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
70 views

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.4k
-1 votes
1 answer
100 views

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
153 views

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
79 views

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
  • 73
2 votes
1 answer
109 views

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
0 votes
1 answer
334 views

I have an object moving "freely" with body:applyForce( x, y ). I want to track it's previous position. I set a timer and with every second that goes by i get the position of the moving ...
jon's user avatar
  • 1
3 votes
1 answer
188 views

I am trying to iterate through a table but start from a position in the table using a key. list = { "one", "two", "four", "five", "six" } ...
Silver_Wolf's user avatar
0 votes
0 answers
108 views

I have a table t which is totally dynamic: it is nested, and number of levels is unknown in advance. I wish to be able to set (get is easy to do) some value at some level, using a kind of path. The ...
Hermios's user avatar
  • 634
1 vote
1 answer
124 views

im not sure if the title is the correct question, i have very little programming knowledge but i know exactly what i want to accomplish, not how to ask what to do, so ill just give an example. mX = { {...
DistantTide's user avatar
0 votes
0 answers
22 views

I'm working on a Roblox overhead GUI and I'm using a moduleScript for the values. It currently pulls a random value of its liking instead of abiding to the parameters. The (relevant) part of the ...
hard R's user avatar
  • 3
0 votes
1 answer
63 views

I'm experimenting with Lua OOP (Object Oriented Programming) but I'm experiencing some issues. Here is a sample code with comments: Object = {string = "Default"} function Object:new() ...
skrovno_CZ's user avatar
0 votes
1 answer
101 views

Below is a sample table structure of what I am wanting to sort. Data = { ["C1_RN1::F1"] = { ["class"] = "Hunter", ["name"] = "C1",...
AeroMaxx's user avatar
  • 207
2 votes
3 answers
106 views

This table is structured like this: local t = { ["track"] = "one#two#three", { ["track"] = "four" }, -- [1] } The first ...
user3204810's user avatar
2 votes
1 answer
73 views

I made a program, which checks if in table has (for example) "A" and a "B" in itself. But it doesn't works. Here's code: function inTable(t,e) return t[e] ~= nil end --Example ...
unwritten_k's user avatar
0 votes
1 answer
210 views

I am trying to implement a custom iterator which works like table.foreach in Lua, but in more "syntax friendly" manner. I came across following construction (not sure if it's done purely in ...
szulak's user avatar
  • 25
0 votes
0 answers
105 views

The core detail of my problem is: I don't know how to do it. I encountered the problem I'm trying to solve by wanting to add a table to an existing table in Lua. The major difficulty that prevented me ...
DrDreadful's user avatar
0 votes
1 answer
190 views

My table: local Cache = { SurvivalGameFramework = { parent = game.ServerStorage } } As you can probably tell, this table is not an empty value or "nil" but according to ...
Plant Food Power's user avatar
0 votes
1 answer
356 views

Let's say I have this code: local testtbl = {"foo", "bar", "baz"} How do I get the index of an element? For example: print(indexOf(testtbl, "bar")) -- 2
berriz44's user avatar
1 vote
2 answers
81 views

I'm currently learning and trying to write a script for a map i created for a pretty old game (Settlers 5 Heritage of Kings) and while doing so i tried to split up my code in different files for ...
ThatsNasu's user avatar
1 vote
1 answer
119 views

I've the following lua script, in which I use a C++ function that needs to read both keys and values of a nested table: local scenariolist = { scenarios = { 'scenario1', 'scenario3', ...
Jepessen's user avatar
  • 12.7k
0 votes
1 answer
140 views

I have following code for DCS:World scripting: koUDPSocket = {} koUDPSocket.host = "127.0.0.1" --koTCPSocket.host = "85.221.224.254" koUDPSocket.port = 52525 koUDPSocket.socket = ...
Jan Intelkor's user avatar

1
2 3 4 5
29