Lua Player Body Temperature?
0

4 posts in this topic

Recommended Posts

Im looking to make a electric blanket item that uses a OnCreate: recipe_.

i can't seem to get it to referance the Hyperthmeria/Hypothermia Stats.

(Bordem, Unhappy stats seem to work fine.)

What am i doing wrong?

 

(Lua Code)

--Raise Temperature
function recipe_raisebodytemp(items, result, player)
    local unhappy = 5;
    local hyperthermia = 50;
    HCDoStats(player, unhappy , hyperthermia);
end

(Lua Code)

Share this post


Link to post
Share on other sites

I'm not sure if you are aware, but 'HCDoStats' is a Hydrocraft function. So if you do not want your mod to rely on Hydrocraft, I would just copy the function into your own file:

function HCDoStats(player, b, u)
	player:getBodyDamage():setBoredomLevel(player:getBodyDamage():getBoredomLevel() - b);
	player:getBodyDamage():setUnhappynessLevel(player:getBodyDamage():getUnhappynessLevel() - u); 
end

 

At the moment, you are passing the incorrect parameters to the HCDoStats function (unless you've changed it from the default Hydrocraft function). This function expects 3 parameters, player, boredom, and unhappyness. You are passing player for player, which is correct, then you're passing unhappy which actually changes boredom, and 'hyperthermia' which actually changes unhappyness level.

 

To fix this, you'll need to add another line to this function called player:SetTemperature(player:GetTemperature() - hypothermia). This line will subtract 'hypothermia' from the player's current temperature. You'll then need to add another parameter (probably called hypothermia) inside of the HCDoStats parenthesis to both the function and the function call. So you should have something similar to this:

function HCDoStats(player, b, u, hypothermia)
	player:getBodyDamage():setBoredomLevel(player:getBodyDamage():getBoredomLevel() - b);
	player:getBodyDamage():setUnhappynessLevel(player:getBodyDamage():getUnhappynessLevel() - u);
	player:setTemperature(player:getTemperature() - hypothermia)
end

 

To call the function, you would then use:

HCDoStats(player, boredom, unhappy, hypothermia);

 

Edited by nater

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
0