Jump to content

Need help with custom fuel and fueltype plz


Recommended Posts

I want to make sewing kit use silk for repair but it always says 

 

[00:01:27]: [string "../mods/bSewkitMod/scripts/prefabs/sewingki..."]:41: attempt to index field 'fuel' (a nil value)
LUA ERROR stack traceback:
    ../mods/bSewkitMod/scripts/prefabs/sewingkit.lua:41 in (field) fn (Lua) <10-55>
    scripts/mainfunctions.lua:147 in () ? (Lua) <136-178>
    =[C]:-1 in (method) SpawnPrefab © <-1--1>
    scripts/mainfunctions.lua:192 in (global) SpawnPrefab (Lua) <189-194>
    scripts/components/builder.lua:327 in (method) DoBuild (Lua) <313-395>
    scripts/actions.lua:861 in (field) fn (Lua) <859-865>
    scripts/bufferedaction.lua:23 in (method) Do (Lua) <19-33>
    scripts/entityscript.lua:1216 in (method) PerformBufferedAction (Lua) <1208-1226>
    scripts/stategraphs/SGwilson.lua:2277 in (field) ontimeout (Lua) <2274-2278>
    scripts/stategraph.lua:545 in (method) UpdateState (Lua) <531-575>
    scripts/stategraph.lua:602 in (method) Update (Lua) <594-622>
    scripts/stategraph.lua:123 in (method) Update (Lua) <107-146>
    scripts/update.lua:209 in () ? (Lua) <150-223>
 
I have attached the files I have

modmain.lua

silk.lua

sewingkit.lua

Link to comment
Share on other sites

Ok, that may sound harsh but just stop everything you'r edoing NOW.

You are taking extremly bad modding habbit by doing what you're doing. You should NEVER override an existing prefab the way you're doing because then you're killing the compatibility of your mod with ANY other mod modifying the same prefab.

You have functions for that which are called AddPrefabPostInit. Read a bit more some tutorials and study the mod samples provided by Klei and then come back to ask questions if you encounter issues. But just don't do it the way you started, it will just be awful.

Good luck :-)

Edited by ZupaleX
Link to comment
Share on other sites

yes i know that, I just wanted to know what do what and what to change, first, then do the post init.

So, do you know why it doesnt register my fuel?

 

It doesnt sound harsh, I know im a beginner that doesnt know whats hes doing lol

Edited by Noldaz
Link to comment
Share on other sites

I dont understand what is fuel component then .. i got this in sewing kit

 

inst:AddComponent("fueled")
 
inst.components.fueled.accepting = true
inst.components.fuel.fueltype = FUELTYPE.SILK  i tried "silk" and "SILK" too
inst.components.fueled:InitializeFuelLevel(0)
inst.components.fueled:StopConsuming()
 
i got this in mod main
 
GLOBAL.FUELTYPE.SILK = "SILK"
 
PrefabFiles = {
    "sewingkit",
    "silk",
}
 
 
and this in the silk 
 
inst:AddComponent("fuel")
inst.components.fuel.fueltype = "SILK"
inst.components.fuel.fuelvalue = TUNING.TINY_FUEL

 

whats missing?!

 

Edited by Noldaz
Link to comment
Share on other sites

@Noldaz, fuel and fueled are not the components you want to be using. The fueled component is specifically used by items which are always being 'consumed' or fueled, where as the fuel component is what fuels those items. Look into using the repairable and repairer components.

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...