This shows you the differences between two versions of the page.
lua:scripting:examples:olcgrid [2015/01/01 08:35] vodur created |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | In luai | ||
- | <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 | ||
- | |||
- | 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)) | ||
- | end | ||
- | if not(row==rows) then -- do south stuff | ||
- | olc("south dig "..getvnum(col,row+1)) | ||
- | end | ||
- | if not(col==1) then -- do west stuff | ||
- | olc("west dig "..getvnum(col-1,row)) | ||
- | end | ||
- | if not(col==cols) then -- do east stuff | ||
- | olc("east dig "..getvnum(col+1,row)) | ||
- | end | ||
- | end | ||
- | end | ||
- | |||
- | end | ||
- | </code> |