Enjl wrote: ↑Sat Apr 03, 2021 3:01 am
Well 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
Interesting, I had my npc use the sample library, and nothing happened.
Actually never mind, I forgot to register the functions, and this is how I solved it:
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