#!sdl_chomik


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

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

    <multiply "integer" <amount of key 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 position x of the widget <my key widget index>=<the add result "integer">;
    let <sdl chomik widgets prefix> the widget position y of the widget <my key widget index>=<<sdl chomik widgets prefix> the widget position y of the widget <my town icon index>>;
    let <sdl chomik widgets prefix> the widget <my key widget index> is visible = value boolean true;

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

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



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


let make all key widgets invisible (KEY:integer)=value code
{
    let my key id = value integer [(KEY:integer)];
    let my key widget index = <my widget for the key <my key id>>;
    let <sdl chomik widgets prefix> the widget <my key widget index> is visible = value boolean false;
};

let choose graphical sprites location for current place and key (KEY:integer)=value code
{
    let my key id = value integer [(KEY:integer)];
    let my possible key location = value item_location in place <my place id>;
    let my key widget index = <my widget for the key <my key id>>;
    let my town icon index = <my town <my place id> icon index>;

    <compare "item_location" <my location of the key <my key id>> <my possible key location>>;
    <choose graphical sprites location for current place and current key on <the compare result>>;
};

