Jump to content

Recommended Posts

I was playing around with modding, and wanted to try giving items of a certain kind specific names, like how Pigmen can have specific names.
 As near as I can tell, you AddComponent("named") sometime during the item's initialization, and then SetName(something) to give that item a name. But I tried the following and it did not work:

local MapScroll = GLOBAL.require "prefabs/mapscroll"

local old = {
   makeScroll = MapScroll.fn,
}

local function makeScroll()
   print("***************************** in makeScroll")
   local inst = old.makeScroll()
   inst:AddComponent("named")
   local rec = inst.components.maprecorder
   inst:SetName(rec.mapauthor .. "'s map on day " .. rec.mapday)
   return inst
end
MapScroll.fn = makeScroll
print("***************************** MapScroll ready to be named.")

Near as I can tell, MapScroll.fn is what creates the scroll, but when I build such a scroll to test with, the function "makeScroll" is never called. What should I be doing instead here?

Yes I know that you can view the author and day on map scrolls by inspecting them.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...