File: l_view.cc

package info (click to toggle)
crawl 2%3A0.7.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 30,420 kB
  • ctags: 23,018
  • sloc: cpp: 244,317; ansic: 16,144; perl: 2,214; makefile: 984; python: 488; objc: 250; ruby: 200; sh: 140
file content (44 lines) | stat: -rw-r--r-- 795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * File:     l_view.cc
 * Summary:  User interaction with env.show.
 */

#include "AppHdr.h"

#include "l_libs.h"
#include "l_defs.h"

#include "cluautil.h"
#include "env.h"
#include "libutil.h"
#include "player.h"
#include "terrain.h"

coord_def player2show(const coord_def &s)
{
    return (s + coord_def(ENV_SHOW_OFFSET, ENV_SHOW_OFFSET));
}

LUAFN(view_feature_at)
{
    COORDSHOW(s, 1, 2)
    const coord_def p = player2show(s);
    if (env.show(p))
    {
        dungeon_feature_type f = grid_appearance(s + you.pos());
        lua_pushstring(ls, dungeon_feature_name(f));
    }
    return (1);
}

static const struct luaL_reg view_lib[] =
{
    { "feature_at", view_feature_at },

    { NULL, NULL }
};

void cluaopen_view(lua_State *ls)
{
    luaL_openlib(ls, "view", view_lib, 0);
}