Source:NetHack 5.0.0/dat/tut-1.lua
Jump to navigation
Jump to search
Below is the full text to tut-1.lua from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/dat/tut-1.lua#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. 2. local tut_ctrl_key = nil; 3. local tut_alt_key = nil; 4. 5. function tut_key(command) 6. local s = nh.eckey(command); 7. local m = s:match("^^([A-Z])$"); -- ^X is Ctrl-X 8. if (m ~= nil) then 9. tut_ctrl_key = m; 10. return "Ctrl-" .. m; 11. end 12. 13. m = s:match("^M%-([A-Z])$"); -- M-X is Alt-X 14. if (m ~= nil) then 15. tut_alt_key = m; 16. return "Alt-" .. m; 17. end 18. 19. return s; 20. end 21. 22. function tut_key_help(x, y) 23. if (tut_ctrl_key ~= nil) then 24. des.engraving({ coord = { x,y }, type = "engrave", text = "Note: Outside the tutorial, Ctrl-key combinations are shown prefixed with a caret, like '^" .. tut_ctrl_key .. "'", degrade = false }); 25. tut_ctrl_key = nil; 26. end 27. end 28. 29. des.level_init({ style = "solidfill", fg = " " }); 30. des.level_flags("mazelevel", "noflip", 31. "nomongen", "nodeathdrops", "noautosearch"); 32. 33. des.map([[ 34. --------------------------------------------------------------------------- 35. |-.--|.......|......|..S....|.F.......|.............|.......|.............| 36. |.-..........|......|--|....|.F.....|.|S-------.....|.....................| 37. ||.--|.......|..T......|....|.F.....|.|.......|.....|.......|.............| 38. ||.|.|.......|......|-.|....|.F.....|.|.......|.....|--------.............| 39. ||.|.|.......|......||.|-.-----------.-.......|-S----.....................| 40. |-+-S---------..---.||........................|...|.......................| 41. |......| |.-------------------.......|...|....--S----............| 42. |......| ###### |.........| |..S.......|...|....|.....|............| 43. |----.-| -+- # |.....---.|######+..|.......S...|....|.....|............| 44. |----+----.----+---.|.--|.|.|# ------------...|....|.....F............| 45. |........|.|......|.|...F...|# ........|.....+...|....|.....|............| 46. |.P......-S|......|------.---# .........|.....|...|....-------........----| 47. |..........|......+.|...|.|.S# ..--S-----.....|LLL|..................|..| | 48. |.W......---......|.|.|.|.|.|# ..|......|.....|LLL|..................|..--| 49. |....Z.L.S.F......|.|.|.|.---# |......+.....|...|..................|..|.| 50. |........|--......|...|.....|####+......|.....|...+..................||...| 51. --------------------------------------------------------------------------- 52. ]]); 53. 54. 55. des.region(selection.area(01,01, 73, 16), "lit"); 56. 57. des.non_diggable(); 58. 59. des.teleport_region({ region = { 9,3, 9,3 } }); 60. 61. -- TODO: 62. -- - save (more of) hero state when entering 63. -- - quit-command should maybe exit the tutorial? 64. 65. -- turn on some newbie-friendly options 66. nh.parse_config("OPTIONS=mention_walls"); 67. nh.parse_config("OPTIONS=mention_decor"); 68. nh.parse_config("OPTIONS=lit_corridor"); 69. 70. local movekeys = tut_key("movewest") .. " " .. 71. tut_key("movesouth") .. " " .. 72. tut_key("movenorth") .. " " .. 73. tut_key("moveeast"); 74. 75. local diagmovekeys = tut_key("movesouthwest") .. " " .. 76. tut_key("movenortheast") .. " " .. 77. tut_key("movesoutheast") .. " " .. 78. tut_key("movenorthwest"); 79. 80. des.engraving({ coord = { 9,3 }, type = "engrave", text = "Move around with " .. movekeys, degrade = false }); 81. des.engraving({ coord = { 5,2 }, type = "engrave", text = "Move diagonally with " .. diagmovekeys, degrade = false }); 82. 83. if (u.role == "Knight") then 84. des.engraving({ coord = { 12,1 }, type = "engrave", text = "Knights can jump with '" .. tut_key("jump") .. "'", degrade = false }); 85. end 86. 87. -- 88. 89. des.engraving({ coord = { 2,4 }, type = "engrave", text = "Some actions may require multiple tries before succeeding", degrade = false }); 90. des.engraving({ coord = { 2,5 }, type = "engrave", text = "Open the door by moving into it", degrade = false }); 91. des.door({ coord = { 2,6 }, state = "closed" }); 92. 93. des.engraving({ coord = { 2,7 }, type = "engrave", text = "Close the door with '" .. tut_key("close") .. "'", degrade = false }); 94. 95. 96. -- 97. 98. des.engraving({ coord = { 4,5 }, type = "engrave", text = "You can leave the tutorial via the magic portal.", degrade = false }); 99. des.trap({ type = "magic portal", coord = { 4,4 }, seen = true }); 100. 101. -- 102. 103. des.engraving({ coord = { 5,9 }, type = "engrave", text = "This door is locked. Kick it with '" .. tut_key("kick") .. "'", degrade = false }); 104. des.door({ coord = { 5,10 }, state = "locked" }); 105. 106. -- by default, kick is the first command that can be a ctrl-key combo 107. tut_key_help(6, 8); 108. 109. 110. des.engraving({ coord = { 5,12 }, type = "engrave", text = "Look around the map with '" .. tut_key("glance") .. "', press ESC when you're done", degrade = false }); 111. 112. -- 113. 114. des.engraving({ coord = { 10,13 }, type = "engrave", text = "Use '" .. tut_key("search") .. "' to search for secret doors", degrade = false }); 115. 116. des.engraving({ coord = { 10,15 }, type = "engrave", text = "Wrong secret", degrade = false }); 117. 118. -- 119. 120. des.engraving({ coord = { 10,10 }, type = "engrave", text = "Behind this door is a dark corridor", degrade = false }); 121. des.door({ coord = { 10,9 }, state = percent(50) and "locked" or "closed" }); 122. des.region(selection.match("#"), "unlit"); 123. des.region(selection.match(" "), "unlit"); 124. des.door({ coord = { 15,10 }, state = percent(50) and "locked" or "closed" }); 125. 126. -- 127. 128. des.engraving({ coord = { 15,11 }, type = "engrave", text = "There are four traps next to you! Search for them.", degrade = false }); 129. local locs = { {14,11}, {14,12}, {15,12}, {16,12}, {16,11} }; 130. shuffle(locs); 131. for i = 1, 4 do 132. des.trap({ type = percent(50) and "sleep gas" or "board", 133. coord = locs[i], victim = false }); 134. end 135. 136. des.engraving({ coord = { 15,15 }, type = "engrave", text = "Some traps can be disabled with '" .. tut_key("untrap") .. "'", degrade = false }); 137. des.trap({ coord = { 15,16 }, type = "web", spider_on_web = false }); 138. 139. -- 140. 141. des.door({ coord = { 18,13 }, state = "closed" }); 142. 143. des.engraving({ coord = { 19,13 }, type = "engrave", text = "Pick up items with '" .. tut_key("pickup") .. "'", degrade = false }); 144. 145. local armor = (u.role == "Monk") and "leather gloves" or "leather armor"; 146. 147. des.object({ id = armor, spe = 0, buc = "cursed", coord = { 19,14} }); 148. 149. des.engraving({ coord = { 19,15 }, type = "engrave", text = "Wear armor with '" .. tut_key("wear") .. "'", degrade = false }); 150. 151. des.object({ id = "dagger", spe = 0, buc = "not-cursed", coord = { 21,15} }); 152. 153. des.engraving({ coord = { 21,14 }, type = "engrave", text = "Wield weapons with '" .. tut_key("wield") .. "'", degrade = false }); 154. 155. 156. des.engraving({ coord = { 22,13 }, type = "engrave", text = "Hit monsters by walking into them.", degrade = false }); 157. 158. des.monster({ id = "lichen", coord = { 23,15 }, waiting = true, countbirth = false }); 159. 160. -- 161. 162. des.engraving({ coord = { 24,16 }, type = "engrave", text = "Now you know the very basics. You can leave the tutorial via the magic portal.", degrade = false }); 163. 164. des.engraving({ coord = { 26,16 }, type = "engrave", text = "Step into this portal to leave the tutorial", degrade = false }); 165. des.trap({ type = "magic portal", coord = { 27,16 }, seen = true }); 166. 167. -- 168. 169. des.engraving({ coord = { 25,13 }, type = "engrave", text = "Push boulders by moving into them", degrade = false }); 170. des.object({ id = "boulder", coord = {25,12} }); 171. 172. -- 173. 174. des.engraving({ coord = { 27,9 }, type = "engrave", text = "Take off armor with '" .. tut_key("takeoff") .. "'", degrade = false }); 175. 176. -- 177. 178. des.object({ class = "?", id = "remove curse", buc = "blessed", coord = {23,11} }) 179. des.engraving({ coord = { 22,11 }, type = "engrave", text = "Some items have shuffled descriptions, different each game", degrade = false }); 180. des.engraving({ coord = { 23,11 }, type = "engrave", text = "Pick up this scroll, read it with '" .. tut_key("read") .. "', and try to remove the armor again", degrade = false }); 181. 182. -- 183. 184. des.engraving({ coord = { 19,10 }, type = "engrave", text = "Another magic portal, a way to leave this tutorial", degrade = false }); 185. des.trap({ type = "magic portal", coord = { 19,11 }, seen = true }); 186. 187. -- 188. 189. -- rock fall 190. des.object({ coord = {14, 5}, id = "rock", quantity = math.random(50,99) }); 191. des.object({ coord = {15, 5}, id = "rock", quantity = math.random(10,30) }); 192. des.object({ coord = {14, 4}, id = "rock", quantity = math.random(10,30) }); 193. des.object({ coord = {15, 6}, id = "rock", quantity = math.random(30,60) }); 194. des.object({ coord = {14, 6}, id = "rock", quantity = math.random(30,60) }); 195. des.object({ coord = {14, 6}, id = "boulder" }); 196. 197. des.door({ coord = { 20,3 }, state = percent(50) and "open" or "closed" }); 198. 199. des.engraving({ coord = { 21,3 }, type = "engrave", text = "Avoid being burdened, it slows you down", degrade = false }); 200. des.engraving({ coord = { 22,3 }, type = "engrave", text = "Drop items with '" .. tut_key("drop") .. "'", degrade = false }); 201. des.engraving({ coord = { 22,4 }, type = "engrave", text = "You can drop partial stacks by prefixing the item slot letter with a number", degrade = false }); 202. 203. -- 204. 205. des.monster({ id = "yellow mold", coord = { 26,2 }, waiting = true, countbirth = false }); 206. 207. des.engraving({ coord = { 25,5 }, type = "engrave", text = "Throw items with '" .. tut_key("throw") .. "'", degrade = false }); 208. 209. des.trap({ type = "magic portal", coord = { 21,1 }, seen = true }); 210. 211. -- 212. 213. des.monster({ id = "wolf", coord = { 29,2 }, peaceful = 0, waiting = true, countbirth = false }); 214. 215. des.engraving({ coord = { 37,4 }, type = "engrave", text = "Missiles, such as rocks, work better when fired from appropriate launcher", degrade = false }); 216. 217. des.object({ coord = { 37,3 }, id = "sling", buc = "not-cursed", spe = 9 }); 218. des.engraving({ coord = { 37,3 }, type = "engrave", text = "Wield the sling", degrade = false }); 219. des.engraving({ coord = { 36,1 }, type = "engrave", text = "Use '" .. tut_key("fire") .. "' to fire missiles with the wielded launcher", degrade = false }); 220. 221. des.engraving({ coord = { 35,4 }, type = "engrave", text = "Firing launches items from your quiver; Use '" .. tut_key("quiver") .. "' to put items in it", degrade = false }); 222. 223. des.engraving({ coord = { 33,4 }, type = "engrave", text = "You can wait a turn with '" .. tut_key("wait") .. "'", degrade = false }); 224. 225. 226. -- 227. 228. des.door({ coord = { 38,6 }, state = "closed" }); 229. 230. des.engraving({ coord = { 39,6 }, type = "engrave", text = "You loot containers with '" .. tut_key("loot") .. "'", degrade = false }); 231. 232. des.object({ coord = { 41,6 }, id = "large box", broken = true, trapped = false, 233. contents = function(obj) 234. des.object({ id = "secret door detection", class = "/", spe = 30 }); end 235. }); 236. des.engraving({ coord = { 42,6 }, type = "engrave", text = "Containers can also be emptied with '" .. tut_key("tip") .. "'", degrade = false }); 237. 238. des.engraving({ coord = { 45,6 }, type = "engrave", text = "Magic wands are used with '" .. tut_key("zap") .. "'", degrade = false }); 239. 240. -- 241. 242. des.door({ coord = { 35,9 }, state = "nodoor" }); 243. des.engraving({ coord = { 34,9 }, type = "engrave", text = "You can run by prefixing a movement key with '" .. tut_key("run") .. "'", degrade = false }); 244. 245. -- 246. 247. des.door({ coord = { 33,16 }, state = "nodoor" }); 248. des.engraving({ coord = { 35,15 }, type = "engrave", text = "Travel across the level with '" .. tut_key("travel") .. "'", degrade = false }); 249. 250. -- 251. 252. des.trap({ type = "magic portal", coord = { 27,14 }, seen = true }); 253. 254. -- 255. 256. des.engraving({ coord = { 48,1 }, type = "burn", text = "Use '" .. tut_key("eat") .. "' to eat edible things", degrade = false }); 257. 258. des.object({ coord = { 50,3 }, id = "apple", buc = "not-cursed" }); 259. des.object({ coord = { 50,3 }, id = "candy bar", buc = "not-cursed" }); 260. 261. des.object({ coord = { 50,3 }, id = "corpse", montype = "lichen", buc = "not-cursed" }); 262. 263. -- 264. 265. des.door({ coord = { 46,11 }, state = "closed" }); 266. 267. des.engraving({ coord = { 43,11 }, type = "burn", text = "Use '" .. tut_key("twoweapon") .. "' to use two weapons at once", degrade = false }); 268. des.object({ coord = { 43,13 }, id = "knife", buc = "uncursed" }); 269. des.object({ coord = { 43,14 }, id = "dagger", buc = "blessed" }); 270. 271. des.engraving({ coord = { 43,16 }, type = "burn", text = "Swap weapons quickly with '" .. tut_key("swap") .. "'", degrade = false }); 272. 273. des.door({ coord = { 40,15 }, state = "random" }); 274. 275. -- 276. 277. des.object({ coord = { 48,7 }, id = "ring of levitation", buc = "not-cursed" }); 278. 279. des.engraving({ coord = { 48,10 }, type = "burn", text = "Put on accessories with '" .. tut_key("puton") .. "'", degrade = false }); 280. 281. des.engraving({ coord = { 48,16 }, type = "burn", text = "Remove accessories with '" .. tut_key("remove") .. "'", degrade = false }); 282. 283. des.door({ coord = { 50,16 }, state = "closed" }); 284. 285. 286. -- 287. 288. des.engraving({ coord = { 58,9 }, type = "burn", text = "Use '" .. tut_key("down") .. "' to go down the stairs", degrade = false }); 289. des.stair({ dir = "down", coord = { 58,10 } }); 290. 291. -- 292. 293. -- one more ctrl-key help, if needed 294. tut_key_help(64, 4); 295. 296. des.engraving({ coord = { 65,3 }, type = "burn", text = "UNDER CONSTRUCTION", degrade = false }); 297. 298. des.trap({ type = "magic portal", coord = { 66,2 }, seen = true }); 299. 300. -- 301. 302. -- squeezing through small gaps 303. 304. des.engraving({ coord = { 69,12 }, type = "burn", text = "Can't get through? You're carrying too much.", degrade = false }); 305. 306. -- try to squeeze over boulders, find a trap door 307. 308. des.object({ id = "boulder", coord = {71,16} }); 309. des.object({ id = "boulder", coord = {72,16} }); 310. des.object({ id = "boulder", coord = {73,16} }); 311. des.trap({ type = "trap door", coord = { 73,15 } }); 312. 313. -- 314. 315. des.engraving({ coord = { 60,2 }, type = "engrave", text = "Spellcasting", degrade = false }); 316. if (u.uenmax < 5) then 317. -- TODO: make sure hero has enough Pw to cast the spell (5 pw) instead? 318. -- TODO: ensure the first cast of this spell succeeds? 319. des.engraving({ coord = { 59,2 }, type = "engrave", text = "Unfortunately you don't have enough energy to cast spells.", degrade = false }); 320. end 321. des.engraving({ coord = { 57,2 }, type = "engrave", text = "Pick up the spellbook with '" .. tut_key("pickup") .. "'", degrade = false }); 322. des.object({ coord = { 57,2 }, id = "spellbook of light", buc = "blessed" }); 323. des.engraving({ coord = { 55,2 }, type = "engrave", text = "Read the spellbook with '" .. tut_key("read") .. "'", degrade = false }); 324. des.engraving({ coord = { 53,2 }, type = "engrave", text = "Use '" .. tut_key("cast") .. "' to cast a spell", degrade = false }); 325. des.region(selection.area(53,01, 59, 3), "unlit"); 326. 327. -- 328. 329. des.engraving({ coord = { 72,2 }, type = "engrave", text = "You \"quaff\" potions with '" .. tut_key("quaff") .. "'", degrade = false }); 330. des.object({ coord = { 72,2 }, id = "potion of object detection", buc = "blessed" }); 331. 332. 333. ---------------- 334. 335. -- entering and leaving tutorial _branch_ now handled by core 336. -- // nh.callback("cmd_before", "tutorial_cmd_before"); 337. -- // nh.callback("level_enter", "tutorial_enter"); 338. -- // nh.callback("level_leave", "tutorial_leave"); 339. -- // nh.callback("end_turn", "tutorial_turn"); 340. 341. ---------------- 342. 343. -- temporary stuff here 344. -- des.trap({ type = "magic portal", coord = { 9,5 }, seen = true }); 345. -- des.trap({ type = "magic portal", coord = { 9,1 }, seen = true }); 346. -- des.object({ id = "leather armor", spe = 0, coord = { 9,2} }); 347.