• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Is this really happening? there is max amount of varibables you can make inside the function?!

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
This is the maximum amount of variables I can do in single function?
Why there is limit for that?! I just wanted to make sure all these variables are nil.
Code:
local i0,  i1,  i2,  i3,  i4,  i5,  i6,  i7,  i8,  i9,  i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33
local i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63, i64, i65, i66
local i67, i68, i69, i70, i71, i72, i73, i74, i75, i76, i77, i78, i79, i80, i81, i82, i83, i84, i85, i86, i87, i88, i89, i90, i91, i92, i93, i94, i95, i96, i97, i98, i99
local j0,  j1,  j2,  j3,  j4,  j5,  j6,  j7,  j8,  j9,  j10, j11, j12, j13, j14, j15, j16, j17, j18, j19, j20, j21, j22, j23, j24, j25, j26, j27, j28, j29, j30, j31, j32, j33
local j34, j35, j36, j37, j38, j39, j40, j41, j42, j43, j44, j45, j46, j47, j48, j49, j50, j51, j52, j53, j54, j55, j56, j57, j58, j59, j60, j61, j62, j63, j64, j65, j66
local j67, j68, j69, j70, j71, j72, j73, j74, j75, j76, j77, j78, j79, j80, j81, j82, j83, j84, j85, j86, j87, j88, j89, j90, j91, j92, j93, j94, j95, j96, j97, j98,
 
Put them into a table. Max ammount is 256 and in practice 200.
I believe you have less than 200 there though, but a table would be ok, and also make it look somehow more organized.
 
They are nil, because in their present state you have not assigned them a value, also if they are declared outside of a function or interface then they are global variables but are only local to the script, it is important to understand the scope of a variable or table when writing scripts.

Here is the google definition of scope
Code:
A variable can be either of global or local scope. A global variable is a variable declared in the main
body of the source code, outside all functions, while a local variable is one declared within the
body of a function or a block

Why don't you post the script so we can optimize it for you :)
 
Last edited:
Its fine, already generated the tables with loop. Just first time running into this issue..
Had to rethink my scripts though.
Wanted to simply make sure it will start off with nil values and not using some kind of global value.

Now I made this. and tweaked final result to handle the string values. So its running neat now.
Code:
local defaultAreaConstructionT = {}

local areaID = "i0"
function generateAreaID()
local newID = areaID
local currentNumber = tonumber(areaID:match("%d+"))
local nextNumber = currentNumber+1
local letter = areaID:match("%l")

    if nextNumber == 100 then
        if letter == "i" then
            letter = "j"
        elseif letter == "j" then
            letter = "l"
        elseif letter == "l" then
            letter = "k"
        end
        nextNumber = 0
    end
    areaID = tostring(letter..nextNumber)
return newID
end
for i=1, 20 do
    defaultAreaConstructionT[i] = {}
    for j=1, 20 do
        local ID = generateAreaID()
        defaultAreaConstructionT[i][j] = ID
    end
end
 
Back
Top