Jump to content

Prefab Temperature


Recommended Posts

I've been trying to add temperate to prefabs but it always ends up with an error..

 

   inst:AddComponent("heater")
    inst.components.heater.equippedheatfn = 70 
    inst.components.heater:SetThermics(true, false)

^ gives error on line 43 in heater.lua "attempted to call field 'equippedheatfn' (a number value)"

 

Usually when I get that kind of error it says "a nil value" and I'm able to fix it, but this time I'm not sure what's wrong.. Anyone got any idea?

Edited by Aquaterion
Link to comment
Share on other sites

1 hour ago, Muche said:

As the name equippedheatfn suggests, it refers to a function. For non-dynamic heat source you can use equippedheat field.

ofcourse.. I knew it was gonna be a silly mistake, thanks man!

 

I've encountered another problem, not really related, but how can I make something not effect other players? I checked entityscript.lua to check if there is a value I can use like IsInLimbo but I couldn't find 1 for playable characters

Edited by Aquaterion
Link to comment
Share on other sites

2 hours ago, Aquaterion said:

I've encountered another problem, not really related, but how can I make something not effect other players? I checked entityscript.lua to check if there is a value I can use like IsInLimbo but I couldn't find 1 for playable characters

Players have player tag, see prefabs/player_common.lua:1517.

 

1 hour ago, Aquaterion said:

Btw is there a way to make food spoil faster/slower in your inventory?

Looking in components/perishable.lua, food on the ground spoils 50% faster (TUNING.PERISH_GROUND_MULT) than in inventory/backpack/chest. Owner can alter this by having certaing tags - e.g. fridge or spoiler.

If you want a specific prefab to spoil differently in the inventory, you can use localPerishMultiplyer, used for example in spores (prefabs/mushtree_spores.lua.

Link to comment
Share on other sites

3 minutes ago, Muche said:

Players have player tag, see prefabs/player_common.lua:1517.

 

Looking in components/perishable.lua, food on the ground spoils 50% faster (TUNING.PERISH_GROUND_MULT) than in inventory/backpack/chest. Owner can alter this by having certaing tags - e.g. fridge or spoiler.

If you want a specific prefab to spoil differently in the inventory, you can use localPerishMultiplyer, used for example in spores (prefabs/mushtree_spores.lua.

I'm looking into making the whole inventory spoil faster/spoiler depending on an equipped item. Is that possible?

Link to comment
Share on other sites

If you are content with default ratios i.e.

  • default spoiler rate with no equipped item
  • same spoiler rate as on the ground (PERISH_GROUND_MULT) with equipped item 1
  • same spoiler rate as in the ice box (PERISH_FRIDGE_MULT) with equipped item 2

then using tags spoiler / fridge should do the trick (adding them to the player onequip, removing them on unequip).

Link to comment
Share on other sites

16 minutes ago, Muche said:

If you are content with default ratios i.e.

  • default spoiler rate with no equipped item
  • same spoiler rate as on the ground (PERISH_GROUND_MULT) with equipped item 1
  • same spoiler rate as in the ice box (PERISH_FRIDGE_MULT) with equipped item 2

then using tags spoiler / fridge should do the trick (adding them to the player onequip, removing them on unequip).

I'm guessing you don't add that to the equipped item, but to the owner? or to the inventory? hmm idk

Adding it to the owner worked, Thanks, I didn't know that adding tags to owner would effect inventory, thanks for all your help! ^^

Edited by Aquaterion
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...