Forum > Modding Help

FS17: 16x size map and \"terrain height to spline\" script

(1/1)

Loopaz:
Hello!
I have problem with script who is not working on my 16x map
Script work on gold crest valley size but it wont work on 16x size
Anyone have idea how to fix my problem?

Here is rewrited from youtube video
https://youtu.be/dqahpSgbxiY?t=2015
because the source is dead

here is the code


--- Code: ----- Author:eraitsev
-- Name:Terrain to Spline
-- Description:
-- Icon:
-- Hide: no
if ( 1 > getNumSelected() ) then
    print("Select Spline");
    return nil;
end;

local worldRoot = getRootNode()
local map = getChildAt(worldRoot,0)
local mTerrainID = getChild(map, "terrain")
local bx = 0;
local by = 1;
local bz = 0;
local mSplineID = getSelection( 0 );
local mSplineLength = getSplineLength( mSplineID ) ;
local mSplinePiece = 1;
local mSplinePiecePoint = mSplinePiece / mSplineLength ;
local mHeightOffset = 0.0;
local mSplinePos= 1.0;
while mSplinePos <= 1.0 do
    local mPosX, mPosY, mPosZ = getSplinePosition ( mSplineID, mSplinePos );
    local mHeight = mPosY + mHeightOffset;
    local mDirX, mDirY, mDirZ = worldDirectionToLocal( mSplineID, getSplineDirection ( mSplineID, mSplinePos) );
    local mVecDx, mVecDy, mVecDz = mDirY*bz - mDirZ*by, mDirZ*bx - mDirX*bz, mDirX*by - mDirY*bx;
    setTerrainHeightAtWorldPos( mTerrainID, mPosX, mPosY, mPosZ, mHeight );
    local mSideCount = 5;
    for i = 1, mSideCount, 1 do
        local mNewPosX1 = mPosX + i * mVecDx;
        local mNewPosY1 = mPosY + i * mVecDy;
        local mNewPosZ1 = mPosZ + i * mVecDz;
        local mNewPosX2 = mPosX - i * mVecDx;
        local mNewPosY2 = mPosY - i * mVecDy;
        local mNewPosZ2 = mPosZ - i * mVecDz;
    setTerrainHeightAtWorldPos( mTerrainID, mNewPosX1, mNewPosY1, mNewPosZ1, mHeight );
    setTerrainHeightAtWorldPos( mTerrainID, mNewPosX2, mNewPosY2, mNewPosZ2, mHeight );
    end;
    mSplinePos = mSplinePos + mSplinePiecePoint;
end;
--- End code ---

16x map done by this tut
https://gdn.giants-software.com/thread.php?categoryId=4&threadId=6241

Please help me to make my hills nice
Post Merge: March 27, 2021, 03:15:31 PMit is working...
the script somehow is working

Ag Hauler:
Good Deal. Did it just start working or was there something that you did to make it work?

Loopaz:
Hello!
I did a dig into scripts of editor 7.1 and 8.1 and i made a mix of scripts which work well now after move them hierarchy higher after seeing this video
https://youtu.be/F9Rpj8k0NiY?t=217
In scripts of editor there is editorUtils.lua which have everything what i need.
Maybe it will help somebody. :)
Thanks for answer :)

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version