require "lua/entity.lua" require "lua/utilities.lua" debugMode = false myID = myID or 0 print("slime_button init, ID: ",myID) timer = 0 --metaobject.ValueInfo metaobject.IntMeasurement --create variable myTime = 0 masterTimer = myTime+15 HeatBlasting_Low = 0 HeatBlasting_High = 0 verticalOffset = 0 function getPositions() print("getPositions") lowHeat = { --[[ { object("Rising_Heat"), {object("Rising_Heat").position()} }, { object("Rising_Heat_1_"), {object("Rising_Heat_1_").position()} }, { object("Rising_Heat_2_"), {object("Rising_Heat_2_").position()} }, { object("Rising_Heat_3_"), {object("Rising_Heat_3_").position()} }, ]] { object("Rising_Heat_4_"), {object("Rising_Heat_4_").position()} }, } highHeat = { { object("Rising_Heat_5_"), {object("Rising_Heat_5_").position()} }, { object("Rising_Heat_6_"), {object("Rising_Heat_6_").position()} }, } lowHeatDest = { { object("Rising_Heat_4_Dest"), {object("Rising_Heat_4_Dest").position()} }, } highHeatDest = { { object("Rising_Heat_5_Dest"), {object("Rising_Heat_5_Dest").position()} }, { object("Rising_Heat_6_Dest"), {object("Rising_Heat_6_Dest").position()} }, } end getPositions() function sink(o,p) local x,y,z = unpack(p) o.position(x,y,z-20) end function rise(o,p) local x,y,z = unpack(p) o.position(x,y,z) end --initial setup --[[ for k,v in pairs(lowHeat) do if k < 5 then print("sink",v[1],unpack(v[2])) sink(v[1],v[2]) else print("don't initial sink excluded lowHeat object") end end ]] --lowHeat[5][1].rotation(0,0,90) lowHeat[1][1].scale(6.0,0.8,1.0) --highHeat[1][1].rotation(0,0,90) highHeat[1][1].scale(3.0,0.6,1.0) --highHeat[2][1].rotation(0,0,90) highHeat[2][1].scale(3.0,0.6,1.0) --[[ for k,v in pairs(highHeat) do print("sink",v[1],unpack(v[2])) sink(v[1],v[2]) end ]] --[[ if ValueInfoResolver.Match_Underway= 0 then masterTimer = myTime+15 end --flow continue ]] function wait() --print("wait") if myID == 0 or debugMode then if HeatBlasting_Low == 0 then if trigger.received(1,"ActionButton") then print("got ActionButton") --play SoundInfoResolver.Rumble_BumpSmall on actor that press the actionbutton HeatBlasting_Low = 1 --disable actionbuttontrigger currentBehavior=spinUp --play SoundInfoResolver.FireLarge --slideValue(^myFireRoar .volume,100,1,0,0) --play SoundInfoResolver.ValveUp timer = myTime+2 --play SoundInfoResolver.WarningBuzzer --for k,v in pairs(lowHeat) do lowHeat[1][1].trigger.send(1,"fireFX") lowHeat[1][1].trigger.send(1,"fireFXSoundStart") --[[ if k < 5 then print("rise low heat floor:\n",v[1],unpack(v[2])) rise(v[1],v[2]) elseif k == 5 then ]] print("deploy low heat wall:\n",lowHeat[1][1],unpack(lowHeat[1][2])) local px,py,pz = unpack(lowHeatDest[1][2]) lowHeat[1][1].translateSmooth( px , py , pz , 0.5, 0 , 1 ) --end --end end elseif HeatBlasting_Low == 1 then --disable ActionButton trigger end end if myID == 1 or debugMode then if HeatBlasting_High == 0 then if trigger.received(1,"ActionButton") then print("got ActionButton") --play SoundInfoResolver.Rumble_BumpSmall on actor that press the actionbutton HeatBlasting_High = 1 --disable actionbuttontrigger currentBehavior=spinUp --play SoundInfoResolver.ValveUp timer = myTime+2 --play SoundInfoResolver.WarningBuzzer --play SoundInfoResolver.FireLarge --slideValue(^myFireRoar .volume,100,1,0,0) for k,v in pairs(highHeat) do print("deploy high heat:\n",v[1],unpack(v[2])) local px,py,pz = unpack(highHeatDest[k][2]) v[1].translateSmooth( px , py , pz , 0.5, 0 , 1 ) v[1].trigger.send(1,"fireFX") v[1].trigger.send(1,"fireFXSoundStart") end end elseif HeatBlasting_High == 1 then --disable actionbuttontrigger end --OpFlowBehavior end end function spinUp() --spinUpCount = spinUpCount or 0 --spinUpCount = spinUpCount + 1 --print("spinUp",spinUpCount,verticalOffset) --TODO: Make a proper interpolation for the verticalOffset --[[ if spinUpCount < 129 then verticalOffset = verticalOffset + (ft2m(5) / 60) --slideValue(myself.position.distance.vertical,5,1,0,0) end ]] --TODO: Make a proper interpolation for the verticalOffset --is this good enough? if verticalOffset < ft2m(5) then verticalOffset = verticalOffset + ( ft2m(5) * dt ) rotateSmoothRelative( nil, nil , 1200 * dt , 0 , 0, 0 ) end if verticalOffset > ft2m(5) then verticalOffset = ft2m(5) end if myTime>= timer then currentBehavior=slimeIsUP --stop sound SoundInfoResolver.WarningBuzzer spinUpCount = 0 end end function slimeIsUP() --print("slimeIsUP",myID,myTime,timer) if myID == 0 or debugMode then if HeatBlasting_Low == 0 or myTime >= timer +2 then --for k,v in pairs(lowHeat) do lowHeat[1][1].trigger.send(2,"fireFX") --v[1].trigger.send(2,"fireFXSoundStart") lowHeat[1][1].trigger.send(1,"fireFXSoundStop") --[[ if k < 5 then print("sink low heat floor:\n",v[1],unpack(v[2])) sink(v[1],v[2]) elseif k == 5 then ]] print("retract low heat wall:\n",lowHeat[1][1],unpack(lowHeat[1][2])) local px,py,pz = unpack(lowHeat[1][2]) lowHeat[1][1].translateSmooth( px, py , pz , 0.5, 1 ,0 ) --end --end currentBehavior=spinDown --play SoundInfoResolver.ValveDown --slideValue(myFireRoar .volume,0,0.5,0,0) end end if myID == 1 or debugMode then if HeatBlasting_High == 0 or myTime >= timer +2 then for k,v in pairs(highHeat) do print("retract high heat:\n",v[1],unpack(v[2])) local px,py,pz = unpack(highHeat[k][2]) v[1].translateSmoothRelative( px , py , pz , 0.5, 1 , 0 ) v[1].trigger.send(2,"fireFX") --v[1].trigger.send(2,"fireFXSoundStart") v[1].trigger.send(1,"fireFXSoundStop") end currentBehavior=spinDown --play SoundInfoResolver.ValveDown --slideValue(myFireRoar .volume,0,1,0,0) end --flow continue end if debugMode or (myID == 0 and HeatBlasting_Low == 0) or (myID == 1 and HeatBlasting_High == 0) or myTime >= timer + 5 then timer = myTime + 0.5 end end --flow continue function spinDown() --spinDownCount = spinDownCount or 0 --spinDownCount = spinDownCount + 1 --print("spinDown",spinDownCount,dt,verticalOffset) HeatBlasting_Low = 0 HeatBlasting_High = 0 --TODO: Make a proper interpolation for the verticalOffset --is this good enough? if verticalOffset > 0 then verticalOffset = verticalOffset - ( ft2m(5) * (dt*2) ) rotateSmoothRelative( nil, nil , 1200 * (dt*2) , 0 , 0, 0 ) end if verticalOffset < 0 then verticalOffset = 0 end --slideValue(myself.position.distance.vertical,0,0.5,0,0) if myTime >= timer then --stop sound myFireRoar currentBehavior=wait masterTimer = myTime+15 spinDownCount = 0 end --flow continue end --OpFlowBehavior currentBehavior = wait function slimeButtonTick() if trigger.received(1,"ActionButton") then print("got ActionButton in tick") end if dt > 0 then currentBehavior() end local px,py,pz = position() position( px, py , pz + verticalOffset ) end