-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Optimise script function occlude_high_init(e) distance = 1000 itemcount= 4300 mloop=math.floor(itemcount/100) nstart=2 end function occlude_high_main(e) for n = nstart, nstart+mloop-1 do if g_Entity[n] ~= nil then PlayerDX = g_Entity[n]['x'] - g_PlayerPosX; PlayerDY = g_Entity[n]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[n]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < distance and n ~= e then Show(n) CollisionOn(n) else Hide(n) CollisionOff(n) end end end nstart=nstart+(mloop+1) if nstart+(mloop+1)>itemcount then nstart=2 end end