Jump to content

Specific Fueltype Help?


Recommended Posts

Does anyone  have any idea how to make a structure accept only one specific item as fuel(specifically logs, grass, and rocks)? I've looked into different items' code that use atypical fuels in-game - and the components that make them function the way they do - but couldn't really figure anything out from there.

Link to comment
Share on other sites

You can create a new fuel type by adding this into your modmain.lua:

GLOBAL.FUELTYPE.YOUR_FUELTYPE_HERE = "YOUR_FUELTYPE_HERE"

And then set the fuel type of the item you want to the appropriate type:

inst.components.fueled.fueltype = FUELTYPE.YOUR_FUELTYPE_HERE

 

  • Thanks 1
Link to comment
Share on other sites

11 hours ago, -t- said:

You can create a new fuel type by adding this into your modmain.lua:


GLOBAL.FUELTYPE.YOUR_FUELTYPE_HERE = "YOUR_FUELTYPE_HERE"

And then set the fuel type of the item you want to the appropriate type:


inst.components.fueled.fueltype = FUELTYPE.YOUR_FUELTYPE_HERE

 

Before I start with good ol trial and error, is this the correct format?

GLOBAL.FUELTYPE.FUELTYPE_LOGS = "FUELTYPE_LOGS"
inst.components.fueled.fueltype = FUELTYPE.FUELTYPE_LOGS

 

Link to comment
Share on other sites

Yes, it is. Just make sure the first line is in modmain.lua and the second is in your items fn() function.

Alternatively, if you want to edit the fueltype of an existing item you'll have to add this to the modmain.lua:

AddPrefabPostInit(prefab_name, function(inst)
	if not GLOBAL.TheWorld.ismastersim then
		return inst
	end

	inst.components.fueled.fueltype = GLOBAL.FUELTYPE.YOUR_FUELTYPE_HERE
end)

 

Edited by -t-
Link to comment
Share on other sites

11 hours ago, -t- said:

Yes, it is. Just make sure the first line is in modmain.lua and the second is in your items fn() function.

Alternatively, if you want to edit the fueltype of an existing item you'll have to add this to the modmain.lua:


AddPrefabPostInit(prefab_name, function(inst)
	if not GLOBAL.TheWorld.ismastersim then
		return inst
	end

	inst.components.fueled.fueltype = GLOBAL.FUELTYPE.YOUR_FUELTYPE_HERE
end)

 

Been fiddling with this all day and I just can't get it to work. The calls for the fueltype(first reply) seem to technically work, but are of course useless without adding the fueltype to the prefab(second reply). However, when I try to run the mod with that code in place it borderline crashed my laptop and produced an utterly ridiculous crashlog when I chopped a tree to get logs to test functionality(idk why it keeps referencing the Tungsten mod; I'm not even subscribed to it and I even manually searched both the old and new mod directories just to make sure).

client_log.txt

Link to comment
Share on other sites

Well, there's definitely a lot of errors in this log (i mean, damn, 21000 lines of just FMOD errors). I don't know if I can help you with the tungsten mod You're talking about but if you manage to test your mod without any other mods enabled, send me the client_log.txt and the server_log.txt.

Link to comment
Share on other sites

4 hours ago, -t- said:

Well, there's definitely a lot of errors in this log (i mean, damn, 21000 lines of just FMOD errors). I don't know if I can help you with the tungsten mod You're talking about but if you manage to test your mod without any other mods enabled, send me the client_log.txt and the server_log.txt.

 

client_log.txt Cluster_3.zip

Link to comment
Share on other sites

On 10/21/2021 at 3:03 PM, -t- said:

Yes, it is. Just make sure the first line is in modmain.lua and the second is in your items fn() function.

Alternatively, if you want to edit the fueltype of an existing item you'll have to add this to the modmain.lua:


AddPrefabPostInit(prefab_name, function(inst)
	if not GLOBAL.TheWorld.ismastersim then
		return inst
	end

	inst.components.fueled.fueltype = GLOBAL.FUELTYPE.YOUR_FUELTYPE_HERE
end)

 

The problem with this code is that you set the fueltype to the fueled component. But this component is used if the prefab needs fuel to function so you choose the fueltype it accepts. As your prefab has no fueled component, it crashes the game. Replace the fueled with fuel and it should work, as this is the correct component for items that can be consumed. If your prefab has no fuel component you will need to add it beforehand..

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Monti18 said:

The problem with this code is that you set the fueltype to the fueled component. But this component is used if the prefab needs fuel to function so you choose the fueltype it accepts. As your prefab has no fueled component, it crashes the game. Replace the fueled with fuel and it should work, as this is the correct component for items that can be consumed. If your prefab has no fuel component you will need to add it beforehand..

Ah, you're right, sorry I got them mixed up.

@TrashLord Use the "fuel" component instead.

  • Like 1
Link to comment
Share on other sites

11 hours ago, Monti18 said:

The problem with this code is that you set the fueltype to the fueled component. But this component is used if the prefab needs fuel to function so you choose the fueltype it accepts. As your prefab has no fueled component, it crashes the game. Replace the fueled with fuel and it should work, as this is the correct component for items that can be consumed. If your prefab has no fuel component you will need to add it beforehand..

 

9 hours ago, -t- said:

Ah, you're right, sorry I got them mixed up.

@TrashLord Use the "fuel" component instead.

Thanks, all! I put in the code fixes and everything's in working order ^w^

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