Is it possible the character doesn't walk by clicking outside the area of the way borders?

  • #1, by juansirlinkWednesday, 22. February 2017, 19:13 3 years ago
    Hi there!

    Guys, I wonder if Is it possible the character doesn't walk by clicking outside the area of the way borders... Is there any way to do this?

    Thanks a lot!!

    Newbie

    46 Posts


  • #2, by sebastianWednesday, 22. February 2017, 19:58 3 years ago
    With no waypoints in the waysystem the character has no points he/she could go to to reach the closest destination. But you also have problems then when your wayborder shape is not convex

    Thread Captain

    2337 Posts

  • #3, by juansirlinkWednesday, 22. February 2017, 20:22 3 years ago
    Jur... But I really need waypoints... Isn't there any another way?

    Newbie

    46 Posts

  • #4, by sebastianWednesday, 22. February 2017, 21:24 3 years ago
    you could try to use lua script and check if when left clicked outside of the wayborder-polygon of the current scene. Then setting the characters speed of the current outfit to 0.
    And the other way around when clicking inside the waypoint polygon.

    Im not sure if this really works and also not how to script it out of my mind. But i think that all relevant data structure fields for this exist...

    Thread Captain

    2337 Posts

  • #5, by juansirlinkWednesday, 22. February 2017, 21:50 3 years ago
    Really thanks, sebastian, that's a good idea. I'm not sure how to script that but I will try to think how to do that...

    Thanks, guy!

    Newbie

    46 Posts

  • #6, by ke4Wednesday, 22. February 2017, 22:17 3 years ago
    Maybe you could just stop the character instead of changing the speed.

    Stuff you would need for the solution Sebastian suggested.
    You should be able to get the current way borders with this line

    game.CurrentScene.SceneCurrentWaySystem.WaySystemBorder
    1

    And you can get the current cursor position with the getCursorPos() function

    getCursorPos().x
    getCursorPos().y
    1
    2

    Then there's this built in function for checking point inside polygon

    isPointInsidePolygon()
    1

    So the whole script might look something like this

    polygon = game.CurrentScene.SceneCurrentWaySystem.WaySystemBorder
    if not isPointInsidePolygon({ x = getCursorPos().x, y = getCursorPos().y}, polygon) then
    --your actions
    end
    1
    2
    3
    4

    I didn't test it, don't know if that works.

    Key Killer

    810 Posts

Write post