• 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 can anyone explain me what does print(table.remove(v.event, x)) prints?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
my code:

Code:
v.event = {}
for x=1, v.duration do
                if v.event[x] then
                    stopEvent(v.event[x])
print(table.remove(v.event, x))
                    table.remove(v.event, x)
                    if v.minStack then
                        table.insert(v.event, x, addEvent(doTargetCombatHealth, x*v.interval, 0, creature, v.damType, v.minStack*v.damage, v.minStack*v.damage, v.damEffect))
                    else
                        table.insert(v.event, x, addEvent(doTargetCombatHealth, x*v.interval, 0, creature, v.damType, v.damage, v.damage, v.damEffect))
                    end
                    values = values+1
                else
                    table.remove(v.event, x)
                end
            end

The print is getting Bigger and Bigger and Bigger each time it executes this line.
the x does remain always the same (v.duration = 5)
What happens if the print value gets beyong the amount of integer value? will it crash my server?

print(table.remove(v.event, x)
is telling me the id of table value its removing, shouldn't it be 1,2,3,4 or 5?
Or does it count in some nil values?
If so how i remove these nil values from table?
 
table.remove() returns the value that was removed.
So, when you do print(table.remove()), it'll print the value that was removed.

Test example (http://www.lua.org/cgi-bin/demo):
Code:
local tab = {"Evan", "whitevo", "Mark", "Limos"}
print(table.remove(tab, 3)) -- Should remove and print "Mark"

x will not remain the same for each iteration (it will increment by 1, unless specified using a third expression in the for loop)
for as long as it doesn't match v.duration.
 
Otherwise, you can use this method:
Code:
for i = 1, #t do
    t[i] = nil -- erase the key from the table by assigning nil to the key
end
 
oh i see, i see.

So would it be better if instead of table.insert i use:
Code:
v.event[x] = addEvent(doTargetCombatHealth, x*v.interval, 0, creature, v.damType, v.minStack*v.damage, v.minStack*v.damage, v.damEffect))
and as remover
i use the code lines ninja suggested
Code:
v.event[x] = nil
 
Back
Top