lua:scripting:firetemple
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| lua:scripting:firetemple [2015/01/01 09:50] – vodur | lua:scripting:firetemple [2026/10/13 19:19] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Build 5x5 grid. | ||
| - | <code lua> | ||
| - | do | ||
| - | local cols=5 | ||
| - | local rows=5 | ||
| - | local basevnum=501 | ||
| - | |||
| - | local function getvnum( col, row) | ||
| - | return basevnum-1 + (row-1)*cols + col | ||
| - | end | ||
| - | |||
| - | local function setexflag( dir, flg) | ||
| - | if not(mob.room[dir]: | ||
| - | olc(dir.." | ||
| - | end | ||
| - | end | ||
| - | |||
| - | for col=1,cols do | ||
| - | for row=1,rows do | ||
| - | mdo(" | ||
| - | end | ||
| - | end | ||
| - | |||
| - | for col=1,cols do | ||
| - | for row=1,rows do | ||
| - | local vnum=getvnum(col, | ||
| - | mdo(" | ||
| - | if not(row==1) then -- do north stuff | ||
| - | olc(" | ||
| - | setexflag( " | ||
| - | setexflag( " | ||
| - | end | ||
| - | if not(row==rows) then -- do south stuff | ||
| - | olc(" | ||
| - | setexflag( " | ||
| - | setexflag( " | ||
| - | end | ||
| - | if not(col==1) then -- do west stuff | ||
| - | olc(" | ||
| - | setexflag( " | ||
| - | setexflag( " | ||
| - | end | ||
| - | if not(col==cols) then -- do east stuff | ||
| - | olc(" | ||
| - | setexflag( " | ||
| - | setexflag( " | ||
| - | end | ||
| - | end | ||
| - | end | ||
| - | |||
| - | end | ||
| - | </ | ||
| - | |||
| - | Print map | ||
| - | <code lua> | ||
| - | do | ||
| - | |||
| - | local cols=5 | ||
| - | local rows=5 | ||
| - | local basevnum=501 | ||
| - | |||
| - | local function getvnum( col, row) | ||
| - | return basevnum-1 + (row-1)*cols + col | ||
| - | end | ||
| - | |||
| - | local function setexflag( dir, flg) | ||
| - | if not(mob.room[dir]: | ||
| - | olc(dir.." | ||
| - | end | ||
| - | end | ||
| - | |||
| - | local out={} | ||
| - | |||
| - | for row=1,rows do | ||
| - | local second={} | ||
| - | for col=1,cols do | ||
| - | table.insert(out, | ||
| - | local room=getroom(getvnum(col, | ||
| - | | ||
| - | if room.east then | ||
| - | table.insert(out, | ||
| - | end | ||
| - | | ||
| - | if room.south then | ||
| - | table.insert(second, | ||
| - | end | ||
| - | end | ||
| - | table.insert(out," | ||
| - | end | ||
| - | |||
| - | sendtochar(mob, | ||
| - | |||
| - | end | ||
| - | </ | ||
| - | |||
| - | Generate maze | ||
| - | <code lua> | ||
| - | do | ||
| - | |||
| - | local function revdir( dir ) | ||
| - | if dir == " | ||
| - | elseif dir == " | ||
| - | elseif dir == " | ||
| - | elseif dir == " | ||
| - | end | ||
| - | end | ||
| - | |||
| - | --Randomized Prim's algorithm http:// | ||
| - | local walls={} | ||
| - | local maze={} | ||
| - | |||
| - | for k,v in pairs(getroom(501).exits) do | ||
| - | table.insert(walls, | ||
| - | end | ||
| - | |||
| - | while #walls>0 do | ||
| - | local wallind=randnum(1,# | ||
| - | local wall=walls[wallind] | ||
| - | table.remove(walls, | ||
| - | | ||
| - | if not maze[wall.exit.toroom] then | ||
| - | wall.exit: | ||
| - | wall.exit: | ||
| - | wall.exit.toroom[revdir(wall.dir)]: | ||
| - | wall.exit.toroom[revdir(wall.dir)]: | ||
| - | maze[wall.exit.toroom]=true | ||
| - | for k,v in pairs(wall.exit.toroom.exits) do | ||
| - | table.insert(walls, | ||
| - | end | ||
| - | end | ||
| - | | ||
| - | | ||
| - | |||
| - | end | ||
| - | |||
| - | |||
| - | end | ||
| - | </ | ||
