Jump to content
The Indie Stone Forums
Sign in to follow this  
IanSchot

Lua Player Body Temperature?

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...