38 lines
917 B
Lua
38 lines
917 B
Lua
local module = {}
|
|
|
|
local cool_rate = 0.5
|
|
function module.new(this,turbine,context)
|
|
this.heat = 0
|
|
this.hinge = _G.GetInstance(turbine,"HingeConstraint")
|
|
this.speed = _G.GetInstance(turbine,"Speed")
|
|
this.inverted = _G.GetInstance(turbine,"Inverted")
|
|
end
|
|
|
|
function module.run(this,turbine,context)
|
|
this.heat = this.heat * (1 - cool_rate * context.delta) -- wrong but idc
|
|
local mul = 1
|
|
if this.inverted.Value then mul = -1 end
|
|
this.hinge.AngularVelocity = (1-(1/(1 + this.heat))) * this.speed.Value * mul
|
|
this.hinge.MotorMaxTorque = 10000 * this.speed.Value
|
|
context.replicate(this,turbine,module,this.heat)
|
|
return true
|
|
end
|
|
|
|
function module.replicate(this,turbine,context,heat)
|
|
this.heat = heat
|
|
end
|
|
|
|
module.update = module.new
|
|
|
|
module.messages = {
|
|
flux = function(this,turbine,context,heat)
|
|
this.heat = this.heat + heat
|
|
end,
|
|
}
|
|
module.messages.default = nil
|
|
|
|
module.manifest = {
|
|
"Turbine1"
|
|
}
|
|
|
|
return module |