User Tools

Site Tools


lua:scripting:firetemple

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lua:scripting:firetemple [2015/01/01 09:38]
vodur
— (current)
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]:​flag(flg)) then 
-        olc(dir.."​ "​..flg) 
-    end 
-end 
- 
-for col=1,cols do 
-    for row=1,rows do 
-        mdo("​redit create "​..getvnum(col,​row) ) 
-    end 
-end 
- 
-for col=1,cols do 
-    for row=1,rows do 
-        local vnum=getvnum(col,​row) 
-        mdo("​goto "​..vnum) 
-        if not(row==1) then -- do north stuff 
-            olc("​north dig "​..getvnum(col,​row-1)) 
-            setexflag( "​north",​ "​door"​) 
-            setexflag( "​north",​ "​dormant"​) 
-        end 
-        if not(row==rows) then -- do south stuff 
-            olc("​south dig "​..getvnum(col,​row+1)) 
-            setexflag( "​south",​ "​door"​) 
-            setexflag( "​south",​ "​dormant"​) 
-        end 
-        if not(col==1) then -- do west stuff 
-            olc("​west dig "​..getvnum(col-1,​row)) 
-            setexflag( "​west",​ "​door"​) 
-            setexflag( "​west",​ "​dormant"​) 
-        end 
-        if not(col==cols) then -- do east stuff 
-            olc("​east dig "​..getvnum(col+1,​row)) 
-            setexflag( "​east",​ "​door"​) 
-            setexflag( "​east",​ "​dormant"​) 
-        end 
-    end 
-end 
- 
-end 
-</​code>​ 
- 
-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]:​flag(flg)) then 
-        olc(dir.."​ "​..flg) 
-    end 
-end 
- 
-local out={} 
- 
-for row=1,rows do 
-    local second={} 
-    for col=1,cols do 
-        table.insert(out,​ "#"​) 
-        local room=getroom(getvnum(col,​row)) 
-        ​ 
-        if room.east then 
-            table.insert(out,​ room.east:​flag("​dormant"​) and " " or "​-"​) 
-        end 
-        ​ 
-        if room.south then 
-            table.insert(second,​ room.south:​flag("​dormant"​) and " " or  "| ") 
-        end 
-    end 
-    table.insert(out,"​\n\r"​..table.concat(second).."​\n\r"​) 
-end 
- 
-sendtochar(mob,​ table.concat(out)) 
- 
-end 
-</​code>​ 
- 
-Generate maze 
-<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]:​flag(flg)) then 
-        olc(dir.."​ "​..flg) 
-    end 
-end 
- 
-local out={} 
- 
-for row=1,rows do 
-    local second={} 
-    for col=1,cols do 
-        table.insert(out,​ "#"​) 
-        local room=getroom(getvnum(col,​row)) 
-        ​ 
-        if room.east then 
-            table.insert(out,​ room.east:​flag("​dormant"​) and " " or "​-"​) 
-        end 
-        ​ 
-        if room.south then 
-            table.insert(second,​ room.south:​flag("​dormant"​) and " ​ " or  "| ") 
-        end 
-    end 
-    table.insert(out,"​\n\r"​..table.concat(second).."​\n\r"​) 
-end 
- 
-sendtochar(mob,​ table.concat(out)) 
- 
-end 
-</​code>​ 
lua/scripting/firetemple.1420105086.txt.gz ยท Last modified: 2015/01/01 09:38 by vodur