Not a member yet? Why not Sign up today
Create an account  

  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Simple fortress height script

#1
I just wanted my fortress to stay at the most fuel efficient height while building. And since Automated Control Block seem to be unable to control fortresses I wrote a simple script. In case anyone needs it:

Code:
function Update(I)
  centerheight = I:GetConstructCenterOfMass().y;
  if centerheight < -1 then
    -- too low, move up
    I:MoveFortress(Vector3(0,1,0));
  end
  if centerheight > 1 then
    -- too high, move down
    I:MoveFortress(Vector3(0,-1,0));
  end
end
Reply

#2
Cool thing, been wanting something to keep fortresses at a set height. But I don't understand LUA, so could you let me know what I'd need to input to, say, keep it at 20m?
Reply

#3
Hehe that is easy. See the centerheight string? Modify the >< things like you would an ACB.

Will use this lua for my house and floating resort. Thanks!
Reply

#4
Outstanding! ALL my fortresses will be retrofit with this script!
Reply

#5
Wonderful!
If you're still here I summon thee from the depths of time, and ask:
"centerheight" means altitude from sea level.
Is there a parameter which shows it from the terrain/seabed?
Thank you.

The solution seems to be this:


Code:
function Update(I)
--  centerheight = I:GetConstructCenterOfMass().y;
  centerheight = I:GetConstructCenterOfMass().y;
  terrainheight = I:GetTerrainAltitudeForPosition(I:GetConstructCenterOfMass().x,I:GetConstructCenterOfMass().y,I:GetConstructCenterOfMass().z);
  heightfromterrain = centerheight - terrainheight;
  I:LogToHud(heightfromterrain)
;
  if heightfromterrain < 9 then
    -- too low, move up
    I:MoveFortress(Vector3(0,1,0));
  end
  if heightfromterrain > 11 then
    -- too high, move down
    I:MoveFortress(Vector3(0,-1,0));
  end
end
From the Depths english playlist starts here, before that it's hungarian:
https://youtu.be/Ltdx0yVI9cA?list=PLImar...ZokVtdBa73
MULTIPLAYER!

[Image: 6yFiDvF.jpg]
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)