News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Problems with map rotation

Started by Yona-TYT, April 13, 2018, 10:02:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

Thank you very much, I have solved it with a "return coord(count_c.x, count_c.y)"  ;D

I'm sorry to divert the subject, but now the problem is the coordinates out of range when rotating the map.  :-[




Dwachs

#1
Please stop posting new problems to unrelated threads. Just open a new one.

Map rotation in simutrans rotates all coordinates. I tried hard to hide this from the script side.

Cannot reproduce an error. What steps should I do?


Edit: Did you try to use coord::href?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

It seems to only happen on maps with an asymmetric size, try a 64x192 map
to replicate you must rotate the map and use the "select" link to choose a coordinate.

Quote from: Dwachs on April 14, 2018, 08:03:39 AMEdit: Did you try to use coord::href?

function get_goal_text(pl)
{
    local goal = ttextfile("goal.txt")
    goal.start = "<em>--></em> <a href='script:script_text()'>"+ translate("Select")+"</a>"
    goal.c1 = "<a href=\"("+our_coord.x+","+our_coord.y+")\">("+our_coord.x +","+""+our_coord.y+")</a>"
    goal.c2 = "<a href=\"("+gl_pos.x+","+gl_pos.y+")\">("+gl_pos.x +","+""+gl_pos.y+")</a>"
    goal.miss = ""+miss_list[our_coord.x]+""
    return goal.tostring()
}

Dwachs

What exactly is the problem? Please read the documentation of coord::href and coord::_tostring.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT


I understand that "coord :: href" is to create links, but it's not what I'm looking for, the problem is that this function generates coordinates out of range when I rotate the map:

    function check_coord()
    {
        count_c.y+=gl_c.y/15
        if(count_c.y >= gl_c.y){
           count_c.x+= gl_c.x/15
        }
        if(!world.is_coord_valid(coord(count_c.x,0)))
            count_c.x=0
        if(!world.is_coord_valid(coord(0,count_c.y)))
            count_c.y=0

        return coord(count_c.x,count_c.y)
    }



Dwachs

There was indeed a problem with handling of coordinates on rotated non-square maps. Should be fixed with r 8422. Thanks for the report!
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

well that solved it!, I suspected that it was an error in the code hehehehe. :D

later I try it  ;) .