-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Items function collect_init(e) collecting = 50 end function collect_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 80 then collecting = collecting - 1 PromptDuration(collecting.. " objects still need to be collected",1500) PlaySound(e,0); Collected(e); Destroy(e); if collecting == 0 then FinishLevel() end end end