Skip to content

`table index is nil`

Running the below program gets me an intermittent error state of:

Line 20: __fcpu__/src/cpu/io/memory.lua:53: table index is nil (Line in question)

Not sure if there's an empty-safe version of the idx call that I'm using, or if that's actually what is causing this. Happens randomly? I can restart the program and sometimes it'll run fine for a few cycles and other times it errors immediately.

Program
# prefiltered to green rarity as input, since we can't
# operate on quality markers?
# We've got what, 4 filter slots?
# so we just need to grab the top 4

:begin
clr

xmov mem1 green
xclt mem2 mem1 5000

:startloop
inc r1
rnd r2 0 cnm2
floor r2
# setup offset to dyn. addressing
# start at r15 for dyn. address
add r3 r1 15
mov r@3 mem2@2
idx r4 mem3 mem2@2

# check to see if we actually have a hit
tle r4 1
jmp :noexist
jmp :exist

:exist
# hit in theory?
mov r6 2

# no hit? Unsure what return val is like
:noexist
mov r6 2

#mov mem3@3 mem2@2
#mov out@1 r@3
tle r1 5
jmp :startloop
slp 100
jmp :begin
Modlist
base 2.0.23
bobinserters 1.3.2
Bottleneck 0.12.1
elevated-rails 2.0.23
flib 0.15.0
informatron 0.4.0
quality 2.0.23
Robot256Lib 2.0.6
SpidertronEnhancements 1.10.5
vehicle-wagon-graphics 1.0.0
fcpu 0.4.33
space-age 2.0.23
VehicleWagon2 4.1.5
aai-signal-transmission 0.5.0
EditorExtensions 2.4.0
SpidertronPatrols 2.5.3
visible-planets 1.2.4