[Request] A more advanced NPC-147
Posted: Fri Apr 02, 2021 6:40 pm
Ok, so uh, so like, a blank npc that turns into any random npc in a given range. I'm just shocked that there is no npc randomizer yet.
Forums for SMBX
https://www.smbxgame.com/forums/
Code: Select all
-- Replace the numbers with your preferred IDs to turn into.
local ids = {1,2,3,4,5,6,7,8,9}
-- replace myNPC with the name of the library table
function myNPC.onTickEndNPC(v)
v:transform(RNG.irandomEntry(ids))
end
Interesting, I had my npc use the sample library, and nothing happened.Enjl wrote: ↑Sat Apr 03, 2021 3:01 amWell yeah cause it's really trivial.
Put this into your npc-n.lua and bind onTickEndNPC:Code: Select all
-- Replace the numbers with your preferred IDs to turn into. local ids = {1,2,3,4,5,6,7,8,9} -- replace myNPC with the name of the library table function myNPC.onTickEndNPC(v) v:transform(RNG.irandomEntry(ids)) end
Code: Select all
function sampleNPC.onInitAPI()
npcManager.registerEvent(npcID, sampleNPC, "onTickEndNPC")
end
local ids = {92,139,140,141,142,143,144,145,146,933}
function sampleNPC.onTickEndNPC(v)
v:transform(RNG.irandomEntry(ids))
end