Nil getting through

  • stevenspell
    19th August Member 0 Permalink

    so here is the script

    local trgt = sim.pmap(39, 356)

    local crnt = 0x3fffffff
    local er1 = 1
    local er2 = 1
    check1 = function()
     for i=15, 350 do
      if sim.pmap(40, i) ~= nil then
       if sim.partProperty(sim.pmap(40, i), "dcolour") == sim.partProperty(sim.pmap(40, 351), "dcolour") then
        sim.partKill(40, 351)
       end
      else
       er1 = 2
      end
     end
    end
    check2 = function()
     for i=15, 350 do
      if sim.pmap(41, i) ~= nil then
       if sim.partProperty(sim.pmap(41, i), "dcolour") == sim.partProperty(sim.pmap(40, 351), "dcolour") then
        sim.partKill(40, 351)
       end
      else
       er2 = 2
      end
     end
    end
    F = function()
     sim.partProperty(trgt, "ctype", crnt-1)
     crnt = crnt-1
    end
    event.register(event.aftersim, F)
    event.register(event.aftersim, check1)
    event.register(event.aftersim, check2)

    the problem is that even though I have it so it wont run the nested "if" if it gets a nil, but it still gives an error saying that "line 8 partProperty was expecting a number but got nil" even though it shouldn't run that "if" if it gets nil.

  • LBPHacker
    19th August Developer 1 Permalink
    You have two sim.partProperty calls on that line, maybe it's the other one that gets nil.
  • stevenspell
    19th August Member 0 Permalink

    @LBPHacker (View Post)

     That was it thanks for the help