This Code Does Bizarre Things (How Can I fix it?)

Description: Archive discussion
============================
Original description:
Official subforum for LunaLua - an extension framework for SMBX Engine Version 1.3 (which a core of SMBX 2.0). Share your creations that require the use of LunaLUA. You may also share info/tutorials on how to use LunaLUA.

Sambo M
Topic author, Count
Count
Avatar
Sambo M
Topic author, Count
Count
Age: 26
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #1by Sambo » 19 Feb 2016, 8:29

This is supposed to wrap all platform NPCs and create a sensor in the center of each one. It doesn't do that. And the first time I tested it, it made all the platforms act like they were set to "friendly." This only happened once.

Code: Select all

function onTickEnd()
   for ind,npc in pairs(NPC.get({60,62,64,66,104}, -1)) do
      local isAlreadyWrapped = false
      for _,wrapped in pairs(platformNPCs) do
         if npc == wrapped then
            isAlreadyWrapped = true
         end
         if not isAlreadyWrapped then
            platformNPCs[#platformNPCs + 1] = pnpc.wrap(npc)
         end
      end
   end
   for ind,npc in pairs(platformNPCs) do
      platformSensors[ind] = colliders.Point(npc.x + .5 * npc.width, npc.y + .5 * npc.height)
   end
   for _,v in pairs(platformSensors) do v:Draw(0x00ff00ff) end
end


Added after 15 hours 42 minutes:
I've done some debugging, and got it to work, mostly. It doesn't work with newly placed/spawned platforms or generators, but apparently everyone has had that problem.
Image
Current Project:
Image

Return to “LunaLua - Extension Framework”

Who is online (over the past 5 minutes)

Users browsing this forum: 4 guests