Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a core temperature using values?

Asked by
proo34 41
5 years ago

Im making a core as a personal project to maybe learn some things. Ive been scripting for a while but never got how to add and subtract values using a script.

I need to add and subtract the values to get the temperature to rise and decrease. I have multiple machines that will effect the temperature. Once the core reaches 2000 degrees it will melt down and -2000 degrees will freeze down.

How can I set this up? Thanks for the help!

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Might look something like this to startout:

function Meltdown()
--whatever happens in here
end
function Freezedown()
--whatever happens in here
end
local MeltdownPoint = 2000
local FreezedownPoint = 2000
local updateRate = .25
local temperature = 0
local temperatureDelta = 0 -- basically the change in temperature
while true do
    wait(updateRate)
    temperature = temperature + temperatureDelta
    if temperature >= MeltdownPoint then
        Meltdown()
    elseif
        Freezedown()
    end
end

If you wanted to make the temperature change random it might look something like this:

function Meltdown()
--whatever happens in here
end
function Freezedown()
--whatever happens in here
end
local MeltdownPoint = 2000
local FreezedownPoint = 2000
local updateRate = .25
local temperature = 0
local temperatureDelta = 0 -- basically the change in temperature
while true do
    wait(updateRate)
    temperatureDelta = temperatureDelta + (math.random(-3,3)) -- can be any range you want
    temperature = temperature + temperatureDelta
    if temperature >= MeltdownPoint then
        Meltdown()
    elseif
        Freezedown()
    end
end

if this was a server script and based on player input you could have a remote events that the client fire to change the temperature delta

function Meltdown()
--whatever happens in here
end
function Freezedown()
--whatever happens in here
end
local MeltdownPoint = 2000
local FreezedownPoint = 2000
local updateRate = .25
local temperature = 0
local temperatureDelta = 0 -- basically the change in temperature
while true do
    wait(updateRate)
    temperature = temperature + temperatureDelta
    if temperature >= MeltdownPoint then
        Meltdown()
    elseif
        Freezedown()
    end
end
tempDeltaUpEvent.OnServerEvent:Connect(function() 
temperatureDelta = temperatureDelta + 1
end)
tempDeltaDownEvent.OnServerEvent:Connect(function() 
temperatureDelta = temperatureDelta -1
end)
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I assume you are using either an IntValue or a NumberValue. If you need to use decimal points use NumberValue if you don't; use IntValue. To change the values of these, access it's Value property by.

local IntValue = game.Workspace.IntValue

IntValue.Value = 1

--or

local NumberValue = game.Workspace.NumberValue

NumberValue.Value = 1

This sets the value to 0. You mentioned having multiple machines affecting the overall temperature of the core, I recommend having each machine have their own IntValue/NumberValue then add them together to get the core temperature so that you don't have to deal with multithreading. For this, you need to have a folder to hold a value for each machine temperature then iterate over them using «GetChildren()» to get the final result to display.

You might also want to use the «Changed()» event of the core Int/Number Value to check if it reached either -2000 or 2000 then do something if it does

Answer this question