MCPcopy Create free account
hub / github.com/NetHack/NetHack / lspo_room

Function lspo_room

src/sp_lev.c:4027–4116  ·  view source on GitHub ↗

room({ type="ordinary", lit=1, x=3,y=3, xalign="center",yalign="center", * w=11,h=9 }); */ room({ lit=1, coord={3,3}, xalign="center",yalign="center", w=11,h=9 }); */ room({ coord={3,3}, xalign="center",yalign="center", w=11,h=9, * contents=function(room) ... end }); */

Source from the content-addressed store, hash-verified

4025/* room({ coord={3,3}, xalign="center",yalign="center", w=11,h=9,
4026 * contents=function(room) ... end }); */
4027int
4028lspo_room(lua_State *L)
4029{
4030 create_des_coder();
4031
4032 if (gi.in_mk_themerooms && gt.themeroom_failed)
4033 return 0;
4034
4035 lcheck_param_table(L);
4036
4037 if (gc.coder->n_subroom > MAX_NESTED_ROOMS) {
4038 panic("Too deeply nested rooms?!");
4039 } else {
4040 static const char *const left_or_right[] = {
4041 "left", "half-left", "center", "half-right", "right",
4042 "none", "random", NULL
4043 };
4044 static const int l_or_r2i[] = {
4045 SPLEV_LEFT, SPLEV_H_LEFT, SPLEV_CENTER, SPLEV_H_RIGHT,
4046 SPLEV_RIGHT, -1, -1, -1
4047 };
4048 static const char *const top_or_bot[] = {
4049 "top", "center", "bottom", "none", "random", NULL
4050 };
4051 static const int t_or_b2i[] = { TOP, SPLEV_CENTER, BOTTOM,
4052 -1, -1, -1 };
4053 room tmproom;
4054 struct mkroom *tmpcr;
4055 lua_Integer rx, ry;
4056
4057 get_table_xy_or_coord(L, &rx, &ry);
4058 tmproom.x = rx, tmproom.y = ry;
4059 if ((tmproom.x == -1 || tmproom.y == -1) && tmproom.x != tmproom.y)
4060 nhl_error(L, "Room must have both x and y");
4061
4062 tmproom.w = get_table_int_opt(L, "w", -1);
4063 tmproom.h = get_table_int_opt(L, "h", -1);
4064
4065 if ((tmproom.w == -1 || tmproom.h == -1) && tmproom.w != tmproom.h)
4066 nhl_error(L, "Room must have both w and h");
4067
4068 tmproom.xalign = l_or_r2i[get_table_option(L, "xalign", "random",
4069 left_or_right)];
4070 tmproom.yalign = t_or_b2i[get_table_option(L, "yalign", "random",
4071 top_or_bot)];
4072 tmproom.rtype = get_table_roomtype_opt(L, "type", OROOM);
4073 tmproom.chance = get_table_int_opt(L, "chance", 100);
4074 tmproom.rlit = get_table_int_opt(L, "lit", -1);
4075 /* theme rooms default to unfilled */
4076 tmproom.needfill = get_table_int_opt(L, "filled",
4077 gi.in_mk_themerooms ? 0 : 1);
4078 tmproom.joined = get_table_boolean_opt(L, "joined", TRUE);
4079
4080 if (!gc.coder->failed_room[gc.coder->n_subroom - 1]) {
4081 tmpcr = build_room(&tmproom, gc.coder->croom);
4082 if (tmpcr) {
4083 int n = gc.coder->n_subroom;
4084

Callers

nothing calls this directly

Calls 15

create_des_coderFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_xy_or_coordFunction · 0.85
nhl_errorFunction · 0.85
get_table_int_optFunction · 0.85
get_table_optionFunction · 0.85
get_table_roomtype_optFunction · 0.85
get_table_boolean_optFunction · 0.85
build_roomFunction · 0.85
update_croomFunction · 0.85
l_push_mkroom_tableFunction · 0.85
nhl_pcall_handleFunction · 0.85

Tested by

no test coverage detected