Sign in to follow this  
WoodieMain45684

Is there a way to edit the actions file in a mod?

Recommended Posts

The actions file I'm referring to is under scripts\actions. I am wanting to make an it give the player a specific item whenever a certain fuel is added which I've created. I've tried editing it from the components\fueled and components\fuel side, but it isn't turning out so well. I've tried editing the TakeFuelItem(inst, doer) function in the fueled component to give the player the item by inserting doer.components.inventory:GiveItem(itemname), but for now its only giving me errors which say scripts/components/inventory.lua tried to index field components. I'm hoping that putting this in actions right before TakeFuelItem is called would give better results than inserting it in fueled (where it is called). Would I be able to edit actions in modmain.lua? 

image.png

Edited by WoodieMain45684

Share this post


Link to post
Share on other sites
Ultroman    704

Yes, you can edit actions in modmain.lua, but it really shouldn't be necessary. I'm sure we can find a better way, using the fueled component or the prefab you wish to react to burning. Please give a more precise description of the functionality you want, without referring to the code as it is or the game code. Just plain talk. Also, please include a zipped version of your mod with the fueled-example you talked about. I'll take a look.

Share this post


Link to post
Share on other sites

I'm wanting to add in a new resource into the game: Oil. I was hoping that I could transfer it in buckets. A bucket of oil would be able to fuel a miner hat or a lantern. Whenever a bucket of oil would be used as fuel I was going to make it to where it would give the player the bucket back. I tried to use the fueled component to do this. I only added in a few lines to the code. To find it easier, look for the function Fueled:TakeFuelItem(item, doer). I tried to insert an if statement and doer.components.inventory:GiveItem("bucket") there next to item:Remove(). Thanks for taking a look at my case; I'm a little new so I probably am not thinking of all the options.

 
   

fueled.lua

Share this post


Link to post
Share on other sites
Ultroman    704

I'm gonna stop you right there. We do not edit game files directly, unless we know exactly what we're doing. The mod would become HIGHLY incompatible with other mods, as well as messing it up for every other original item using the fueled-component. Instead, we use the modding utilities given to us by Klei, in the form of e.g. AddPlayerPostInit, AddPrefabPostInit, AddComponentPostInit etc. I can show you an example when you've replied to the following.

I got your general idea now. Can you have oil without it being in a bucket, or will you always have to use a bucket in order to transport the oil from the source? Or is there no source, and it's just a bucket of oil you can craft?

You could add a completely new fueltype called OIL, but then you'd have to alter all the items you want to use it for to be able to use OIL in place of its original fueltype. If you know exactly which items you want to be able to fuel with it, it would be helpful. If you just want your oil to be able to fuel anything that you can use logs for, you can basically just imitate the log code and change the images, and make your Bucket of Oil have a high fuel value. Keep in mind, though, that all fueled items have a maximum amount of fuel they can hold. If you want your oil to fuel things that normally take logs as well as items which take other kinds of fuel, then you'll be in for a lot of work.

Share this post


Link to post
Share on other sites

I set the bucket of oil as FUELTYPE.CAVE (for now). I was wanting it to fuel things in a completely identical fashion to lightbulbs, slurtle slime, and fireflies which means it will only be able to fuel miners hats and lanterns. The bucket of oil is completely coded in already and had its fueltype declared as cave and everything. I could easily make it an item instead of being in a bucket, but that's not what I want for this mod. The only thing not coded in is the ability for it to give the bucket back.

 
   

Share this post


Link to post
Share on other sites
Ultroman    704

You should still not overwrite the original fueled-component. Can I see a zip of your mod? It's much easier to help when you have the full picture.

Share this post


Link to post
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
Sign in to follow this