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

Function nhl_random

src/nhlua.c:939–953  ·  view source on GitHub ↗

random(10); -- is the same as rn2(10); */ random(5,8); -- same as 5 + rn2(8); */

Source from the content-addressed store, hash-verified

937/* random(10); -- is the same as rn2(10); */
938/* random(5,8); -- same as 5 + rn2(8); */
939staticfn int
940nhl_random(lua_State *L)
941{
942 int argc = lua_gettop(L);
943
944 if (argc == 1)
945 lua_pushinteger(L, rn2((int) luaL_checkinteger(L, 1)));
946 else if (argc == 2)
947 lua_pushinteger(L, luaL_checkinteger(L, 1)
948 + rn2((int) luaL_checkinteger(L, 2)));
949 else
950 nhl_error(L, "Wrong args");
951
952 return 1;
953}
954
955/* level_difficulty() */
956staticfn int

Callers

nothing calls this directly

Calls 2

rn2Function · 0.85
nhl_errorFunction · 0.85

Tested by

no test coverage detected