Jump to content

Giving all existing prods with these properties a tag on world load


Recommended Posts

Hi, I haven't been able to succeed in my past two threads, so I'm gonna try something else:

My question is in the title, here are the properties I need:

prod.components.burnable

prod.components.container

prod.components.crop 

prod.components.dryer

prod.components.harvestable

prod.components.machine 

prod.components.wardrobe

prod.components.sleepingbag

prod.components.deployable

I hope you guys don't mind but ima tag a few modders to see if they can help me, because I have tried a bunch of times and got crashes so eventually I gave up with the old methods, and the code AlainMCD gave me didn't work:

@alainmcd @JohnWatson

Link to comment
Share on other sites

I'm not sure what you're asking for, but this is what I think you're trying to ask for.

local function HookThis(component)
    AddComponentPostInit(
        component,
        function(inst)
            if not GLOBAL.TheWorld.ismastersim
            then
                return
            end
            inst.inst:AddTag("Ayy")
        end
    )
end
local HookThese = {
    "burnable",
    "container",
    "crop",
    "dryer",
    "harvestable",
    "machine",
    "wardrobe",
    "sleepingbag",
    "deployable",
}
for _,v in pairs(HookThese)
do
    HookThis(v)
end

 

Edited by CarlZalph
inst -> inst.inst
Link to comment
Share on other sites

49 minutes ago, CarlZalph said:

I'm not sure what you're asking for, but this is what I think you're trying to ask for.


local function HookThis(component)
    AddComponentPostInit(
        component,
        function(inst)
            if not GLOBAL.TheWorld.ismastersim
            then
                return
            end
            inst:AddTag("Ayy")
        end
    )
end
local HookThese = {
    "burnable",
    "container",
    "crop",
    "dryer",
    "harvestable",
    "machine",
    "wardrobe",
    "sleepingbag",
    "deployable",
}
for _,v in pairs(HookThese)
do
    HookThis(v)
end

 

ATTEMPT TO CALL METHOD ADDTAG (A NIL VALUE)Thanks for your time so far!

Link to comment
Share on other sites

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
 Share

×
  • Create New...