User Tools

Site Tools


lua:scripting:examples:scriptingolc

Differences

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

Link to this comparison view

lua:scripting:examples:scriptingolc [2014/12/24 05:40]
vodur created
— (current)
Line 1: Line 1:
-Using the CH:olc() command we can script olc editing if desired. 
- 
-Let's set all rooms in Bastion to be no_teleport. 
- 
-For this script, we will not use a trigger, but instead use the '​mprun'​ command to run the script on ourselves. 
-So we just need an mprog vnum and we're good to go. I will use my favorite one, which is 31404. 
-<code lua> 
-local rooms=mob.room.area.rooms 
-local cnt=0 
-for _,room in pairs(rooms) do 
-  -- Maybe it is already no_teleport,​ need to check. 
-  if not(room:​flag("​no_teleport"​)) then 
-    goto(room.vnum) 
-    mdo("​redit"​) 
-    olc("​room no_teleport"​) 
-    olc("​done"​) 
-    cnt=cnt+1 
-  end 
-end 
-sendtochar(mob,​ "​Updated %d rooms\n\r",​ cnt) 
-</​code>​ 
- 
-Remember that since you are using mprun, '​mob'​ will actually be you in this case. 
-In our script we choose the area based on the mob location, so need to make sure we're in Bastion when we run it. 
- 
-<​code>​ 
-goto 10204 
-The Palace Square [Room 10204 city] 
-  You stand in the common area of the walled city of Bastion. ​ Shops and 
-buildings line the streets in all directions. ​ Some distance away, in the 
-four cardinal directions, roads meet the square and continue outward into 
-the rest of the city.  Looking up you see a complex system of support beams, 
-columns, and stone work that supports the "​floating palace." ​ This palace 
-earned its name long before the walls of Bastion were built, when the palace 
-seemed to float above the rest of city and was visible from anywhere on the 
-island. ​ In the four corners of the square you notice spiral staircases 
-leading up into the palace. ​ The square is paved for pedestrian shopping 
-with white marble tiles, decorated in the patterns of the island. ​ Under 
-your feet in the center of the square is a great gold seal, and the donation 
-pit is through a hole down from here.  ​ 
- 
-[Exits: north east south west up down northeast southeast southwest northwest] 
- 
-mprun 31404 
-Running mprog 31404 on Ranglor(0) in room The Palace Square(10204) 
-Room flags toggled. 
-Room flags toggled. 
-... 
-... 
-Room flags toggled. 
-Updated 275 rooms 
-Mprog completed. 
-</​code>​ 
- 
-Now, if it worked right, we should be able to run it again and have 0 updates. 
- 
-<​code>​ 
-mprun 31404 
-Running mprog 31404 on Ranglor(0) in room Before a Shadowed Throne(10505) 
-Updated 0 rooms 
-Mprog completed. 
-</​code>​ 
- 
  
lua/scripting/examples/scriptingolc.1419399634.txt.gz ยท Last modified: 2014/12/24 05:40 by vodur