#!sdl_chomik

let please set the person widget initial location to be the current town widget location=value code
{
    <add "integer" <initial amount of person sprites in place <my place id>> 1>;
    let initial amount of person sprites in place <my place id> = <the add result "integer">;

    <print "initial amount of person sprites in" <my place id> "=" <initial amount of person sprites in place <my place id>>>;

    <multiply "integer" <initial amount of person sprites in place <my place id>> 32>;
    <add "integer" <the multiply result "integer"> <<sdl chomik widgets prefix> the widget position x of the widget <my town icon index>>>;
    let <sdl chomik widgets prefix> the widget initial position x of the widget <my person widget index>=<the add result "integer">;

    <add "integer" <<sdl chomik widgets prefix> the widget position y of the widget <my town icon index>> 32>;
    let <sdl chomik widgets prefix> the widget initial position y of the widget <my person widget index>=<the add result "integer">;

    let <sdl chomik widgets prefix> the widget <my person widget index> is visible = value boolean true;

    <print "the person widget" <my person widget index> "has been placed in" <<sdl chomik widgets prefix> the widget initial position x of the widget <my person widget index>> "," <<sdl chomik widgets prefix> the widget initial position y of the widget <my person widget index>>>;

    let <sdl chomik widgets prefix> the sprite widget index = <my person widget index>;
    let <sdl chomik widgets prefix> the window widget index = <my map window index>;
    <<sdl chomik widgets prefix> please recalculate the widget initial relative positions for the window widget and sprite widget>;
};


let please set the person widget terminal location to be the terminal town widget location=value code
{
    <add "integer" <terminal amount of person sprites in place <my place id>> 1>;
    let terminal amount of person sprites in place <my place id> = <the add result "integer">;

    <multiply "integer" <terminal amount of person sprites in place <my place id>> 32>;
    <add "integer" <the multiply result "integer"> <<sdl chomik widgets prefix> the widget position x of the widget <my town icon index>>>;
    let <sdl chomik widgets prefix> the widget terminal position x of the widget <my person widget index>=<the add result "integer">;
    let <sdl chomik widgets prefix> the widget terminal position y of the widget <my person widget index>=<<sdl chomik widgets prefix> the widget position y of the widget <my town icon index>>;
    <add "integer" <<sdl chomik widgets prefix> the widget position y of the widget <my town icon index>> 32>;
    let <sdl chomik widgets prefix> the widget terminal position y of the widget <my person widget index>=<the add result "integer">;

    let <sdl chomik widgets prefix> the widget <my person widget index> is visible = value boolean true;

    let <sdl chomik widgets prefix> the sprite widget index = <my person widget index>;
    let <sdl chomik widgets prefix> the window widget index = <my map window index>;
    <<sdl chomik widgets prefix> please recalculate the widget terminal relative positions for the window widget and sprite widget>;
};


let choose graphical sprites terminal location for current place and current person on lower=value code {};
let choose graphical sprites terminal location for current place and current person on greater=value code {};
let choose graphical sprites terminal location for current place and current person on equal=value code
{
    <please set the person widget terminal location to be the terminal town widget location>;
};

let choose graphical sprites initial location for current place and current person on lower=value code {};
let choose graphical sprites initial location for current place and current person on greater=value code {};
let choose graphical sprites initial location for current place and current person on equal=value code
{
    <print "set the person widget initial location to be the current town widget location">;
    <please set the person widget initial location to be the current town widget location>;
};

let choose graphical sprites terminal location for current place and person (PERSON:integer)=value code
{
    let my person id = value integer [(PERSON:integer)];
    let my person widget index = <my widget for the person <my person id>>;

    <compare "integer" <my place id> <my target place of the person <my person id>>>;
    <choose graphical sprites terminal location for current place and current person on <the compare result>>;
};


let choose graphical sprites initial location for current place and person (PERSON:integer)=value code
{
    let my person id = value integer [(PERSON:integer)];
    let my person widget index = <my widget for the person <my person id>>;

    <compare "integer" <my place id> <my place of the person <my person id>>>;
    <choose graphical sprites initial location for current place and current person on <the compare result>>;
};
