Jump to content

How can I get a prefab code?


Recommended Posts

Thanks Mobbstar with my last question, I start to learn about mods and I promise bring some interesting mods someday, but now I want to understand how the game's world works and Im studing the existing prefabs, How can I access to the code of the prefabs of the game?, im looking for the science machine, meat effigy, shadow manipulator and the firepit

Link to comment
Share on other sites

@Rily Have you looked through the games "scripts" folder? You can find all the lua code there.

"..\scripts\prefabs\" contains all the prefabs' code files.

scienceprototyper.lua - Science machine

resurrectionstatue.lua - Meat effigy

magicprototyper.lua - Shadowmanipulator

firepit.lua - Firepit

Link to comment
Share on other sites

@Rily Have you looked through the games "scripts" folder? You can find all the lua code there.

"..\scripts\prefabs\" contains all the prefabs' code files.

scienceprototyper.lua - Science machine

resurrectionstatue.lua - Meat effigy

magicprototyper.lua - Shadowmanipulator

firepit.lua - Firepit

Thanks a lot, now, I was looking in the guides and I found so much content about  create new things but how about of modify the existing ones? which guides can give me more information about change the existing prefabs?

Link to comment
Share on other sites

I'm kind of bad at mods but to my understanding you make a mod that effectively replaces the .lua of whatever item you are modyfying for instance to remove the spoiling effect of the pumpkin lantern, you'd effectively need to delete these lines:

local function OnDropped(inst)
    inst.components.perishable:StartPerishing()
    if not TheWorld.state.isday then
        fade_in(inst)
    end
 
But messing with .lua-s is not actual modding so yeah good luck
Link to comment
Share on other sites

 

I'm kind of bad at mods but to my understanding you make a mod that effectively replaces the .lua of whatever item you are modyfying for instance to remove the spoiling effect of the pumpkin lantern, you'd effectively need to delete these lines:

local function OnDropped(inst)
    inst.components.perishable:StartPerishing()
    if not TheWorld.state.isday then
        fade_in(inst)
    end
 
But messing with .lua-s is not actual modding so yeah good luck

 

ok,I got it, but, should I literally replace the .lua file?, the mod can not do something like lock the original .lua file or something?, I Want to make a simple mod, not a permanent change to the game, another thing that I  want is to lock some recipes permanently for some characters, it is possible? for example make Wigfrid unable to build a science machine

Link to comment
Share on other sites

@Rily PostInit functions are what you're looking for.

You are able to override files by giving them the same name and relative path in your mod, but I wouldn't recommend it. You can achieve almost everything you'd want to with post init functions, and it's much cleaner and reliable that way.

Thanks, that is exactly what im looking for

Link to comment
Share on other sites

then, my best suggestion is to look at a simple mod and copy parts of it for yourself(don't forget to use the same version), another thing to understand are scenarios, components and features.

For making some recipe unavailable I'd go look at how Wickerbottom has some recipes.

She has a science level buff for builder.lua in components.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...