Results 1 to 7 of 7

Thread: Vector Lines auto erase?

  1. #1

    Vector Lines auto erase?

    I have a following section of script which tries to leave a trace of vector line every time after a miniature moves positions.

    I firstly set the initial position of miniature as startPos under global, then execute the following code.

    function buttonClick_Done()
    local endPos = self.getPosition()
    local startPos = startPos
    Global.setVectorLines({
    {
    points = {startPos, endPos},
    color = turn_color,
    thickness = 0.2,
    }
    })
    end

    This function is able to correctly draw a vector line for each movement.
    However, the issue is that, on the second move, the new vector line is drawn and the first vector line is erased. After each move, only the latest movement line is preserved and previous lines cannot persist.
    The previous vector line only disappear after I click the button. However within this function I do not know which part sets to erase previous lines. Or this setVectorLines function targets a common variable where new parameter always replaces old parameter rather than adding to it?

  2. #2
    Use getVectorLines, append your points and setVectorLines.

  3. #3
    Could you please elaborate a bit?
    I played with getVectorLines and cannot get the format of the returned table right.
    I cannot figure out whether the returned table contains points tables only, or tables for points, thickness, color, rotation.
    I tried to input the variable with different {} around them but it seems I am not making it right.

  4. #4
    I also found your local position script mod on workshop. I am also trying to use that to create self.setVectorLines function.
    However I also have trouble getting the correct positions.

    function buttonClick_Done()
    local endPos = self.getPosition()
    local startPos = startPos
    Global.setVectorLines({
    {
    points = {startPos, endPos},
    color = turn_color,
    thickness = 0.2,
    }
    })
    end

    In the previous code when I am trying to convert the endPos and startPos into local positions using

    local localEndPos = positionToLocal(endPos)

    it says cannot convert table into vector.
    I am currently stuck in here and I am still trying

  5. #5
    Hey, since some patch we have obj.positionToLocal/obj.positionToWorld functions, so you should use that one

    What I mean in the first post was that if you want to add to vector lines and not overwrite all of them, you should get current lines and add to them, like

    Code:
    local lines = Global.getVectorLines()
    table.insert(lines, {
        points = {startPos, endPos},
        color = turn_color,
        thickness = 0.2,
    })
    Global.setVectorLines(lines)

  6. #6
    Quote Originally Posted by dzikakulka View Post
    Hey, since some patch we have obj.positionToLocal/obj.positionToWorld functions, so you should use that one

    What I mean in the first post was that if you want to add to vector lines and not overwrite all of them, you should get current lines and add to them, like

    Code:
    local lines = Global.getVectorLines()
    table.insert(lines, {
        points = {startPos, endPos},
        color = turn_color,
        thickness = 0.2,
    })
    Global.setVectorLines(lines)
    Legend! I will try it out now.

  7. #7
    I did it! Thanks dzikakulka. This could be a pretty interesting application for some area and route based game.

Similar Threads

  1. VR 3d vector lines
    By Unreal_Ed in forum Suggestions
    Replies: 0
    Last Post: 08-17-2018, 07:44 PM
  2. Drag and Draw Shapes & Lines
    By Giddy_Grenade in forum Suggestions
    Replies: 6
    Last Post: 10-01-2017, 12:13 PM
  3. [SUPPORT] Red lines and blue lines around textures and lighting.
    By mememaster in forum Technical Support
    Replies: 8
    Last Post: 04-09-2017, 10:30 AM
  4. Maximum amount of lines in Global script ?
    By Elemental in forum Scripting
    Replies: 2
    Last Post: 09-13-2016, 07:31 AM
  5. [SOLVED] Color and multiple lines in Object Name
    By DiegoZap in forum Suggestions
    Replies: 3
    Last Post: 02-21-2016, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •