local sx = {} local sy = {} local sz = {} local lx = {} local ly = {} local lz = {} local hitscore = {} local scoreval = {} local doonce = {} function getnear_init(e) lx[e] = 0 lx[e] = 0 lx[e] = 0 sx[e] = 0 sx[e] = 0 sx[e] = 0 doonce[e] = 0 end function getnear_main(e) if doonce[e] == 0 then --- assign variables inside main once again -------------------------- since lua might call them nil hitscore[e] = 0 scoreval[e] = 25 --- how many points to get for this object sx[e] = g_Entity[e]['x'] sy[e] = g_Entity[e]['y'] -- this object position sz[e] = g_Entity[e]['z'] lx[e] = g_Entity[14]['x'] ly[e] = g_Entity[14]['y'] -- other object position lz[e] = g_Entity[14]['z'] doonce[e] = 1 end --- do once assignments lx[e] = g_Entity[14]['x'] ly[e] = g_Entity[14]['y'] -- other object position lz[e] = g_Entity[14]['z'] if math.abs(lx[e] - sx[e]) < 30 then --- found object x,y,z is near if math.abs(ly[e] - sy[e]) < 30 then --- add score, move object if math.abs(lz[e] - sz[e]) < 30 then --- and play sound hitscore[e] = hitscore[e] + scoreval[e] --PlaySound(e,1) CollisionOff(e) SetPosition(e,99, 999, 99) Hide[e] end -- z position there end -- y position there end -- x position there end --- main