Guest User

Untitled

a guest
Dec 5th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1. include, plotscr.hsd
  2. include, crafter.hsi
  3. include, scancode.hsi #very important to include this so Custom knows what keys are pressed
  4.  
  5. #These scripts are for use in Minecraft style item crafting. They can be implemented for
  6. #use on a Map representing a crafting table similar to the 3x3 grid used at the crafting
  7. #table in Minecraft. This script is currently set up for using a 4x4 tile grid, but can be
  8. #amended for whatever size grid you want to use, by adding, or deleting map coordinates.
  9.  
  10.  
  11.  
  12. # This script is for identifying your NPCs representing raw material
  13. #items in such a way that they are recognized by their ID number, while
  14. #the absence on any NPC, or False Return, is always represented by (-1)
  15.  
  16.  
  17. plotscript, npc id at spot, x, y, begin
  18. if (npc at spot(x, y) == 0) then (
  19. return (-1) # no NPC
  20. ) else (
  21. return (get npc id(npc at spot(x, y)))
  22. )
  23. end
  24.  
  25. #This script, graciously annd ingeniously devised by SS user TMC, is used in conjunction with
  26.  
  27.  
  28. plotscript, check recipe, x0y0, x1y0, x2y0, x3y0, x0y1, x1y1, x2y1, x3y1, x0y2, x1y2, x2y2, x3y2, x0y3, x1y3, x2y3, x3y3, begin
  29. if (npc id at spot(5, 3) == x0y0 && #the starting npc id at spot coordinate will depend on
  30. npc id at spot(6, 3) == x1y0 && #where you place the first tile of your crafting table on
  31. npc id at spot(7, 3) == x2y0 && #the map you are using. This example uses the coordinate
  32. npc id at spot(8, 3) == x3y0 && #5,3 as the topleft most tile of the table. This will
  33. npc id at spot(5, 4) == x0y1 && #translate to the x,y crafting table coordinate 0,0
  34. npc id at spot(6, 4) == x1y1 &&
  35. npc id at spot(7, 4) == x2y1 &&
  36. npc id at spot(8, 4) == x3y1 &&
  37. npc id at spot(5, 5) == x0y2 &&
  38. npc id at spot(6, 5) == x1y2 &&
  39. npc id at spot(7, 5) == x2y2 &&
  40. npc id at spot(8, 5) == x3y2 &&
  41. npc id at spot(5, 6) == x0y3 &&
  42. npc id at spot(6, 6) == x1y3 &&
  43. npc id at spot(7, 6) == x2y3 &&
  44. npc id at spot(8, 6) == x3y3
  45. )
  46. then (return (true)) else (return (false))
  47. end
  48.  
  49. #These scripts are used for placing a walkabout NPC representing a raw
  50. #material item onto your crafting table. They work by checking your
  51. #inventory to see if you have any of the required item, if not ithis
  52. #script is set for a sound to play, if so, an NPC representing the item
  53. #you wish to place will be created on the spot of your cursor, and one of
  54. #that item will be deleted from your inventory. This script is also set do
  55. #destroy and NPCs on that tile prior to placinga new one, to prevent
  56. #acidentally placing multiple NPCs.
  57.  
  58. plotscript, placewood, begin
  59. if (inventory (item:wood) >0) then (
  60. deletion # Remove existing item so that ti can be overwritten
  61. create npc (0, hero x, hero y)
  62. delete item (item:wood)
  63. ) else (play sound (1,false,false))
  64. end
  65.  
  66. plotscript, placeiron, begin
  67. if (inventory (item:iron ore) >0) then (
  68. deletion
  69. create npc (1, hero x, hero y)
  70. delete item (item:iron ore)
  71. ) else (play sound (1,false,false)) #etc...
  72. end
  73.  
  74. plotscript, placegold, begin
  75. if (inventory (item:gold ore) >0) then (
  76. deletion
  77. create npc (2, hero x, hero y)
  78. delete item (item:gold ore)
  79. ) else (play sound (1,false,false)) #etc...
  80. end
  81.  
  82. #This is a script which allows the player to delete an item they placed
  83. #erroneously. It will remove the NPC from that tile, and return one of
  84. #the appropriate item to their inventory.
  85.  
  86. plotscript, deletion, begin
  87. delete from board(hero x, hero y)
  88. end
  89.  
  90.  
  91. #This script is called by all successful recipe alerts to reset the crafting table
  92. #by using a door, but that was buggy so I've changed it. Script no longer needed -- TMC
  93. plotscript, resetdoor, begin
  94. end
  95.  
  96. plotscript, leave table, begin
  97. showvalue(currentmap)
  98. reset table
  99. use door (2) # leave the map
  100. end
  101.  
  102. #This script is used to find and identify all npcs on the crafting table
  103. # It is used in conjunction with the reset table script.
  104.  
  105. script, delete from board, x, y, begin
  106. variable(npcref, id)
  107. npcref := npc at spot(x, y) # get the NPC reference
  108. id := npc id at spot(x, y)
  109. if (npcref == 0) then (exit script)
  110. destroy npc (npcref)
  111.  
  112. # Figuring out which item to return
  113. if (id == 0) then (get item (item: wood))
  114. else if (id == 1) then (get item (item: iron ore))
  115. else if (id == 2) then (get item (item: gold ore))
  116.  
  117. end
  118.  
  119. #This script is used to transform your hero into a cursor, or box
  120. #to use on the crafting table map. In addition to including this
  121. #in the crafting script it can be used as an each-step script
  122.  
  123. plotscript, Herotobox, begin
  124. set hero picture (0,0 ,outside battle)
  125. set hero palette (0,0,outside battle)
  126. end
  127.  
  128. #This Script returns your hero to his or her original appearance
  129. #It does the opposite of the HerotoBox Script
  130.  
  131. plotscript, resethero, begin
  132. reset hero picture (0, outside battle)
  133. reset hero palette (0, outside battle)
  134. end
  135.  
  136. #this script clears the crafting table, and returns any placed items
  137. #to your hero's inventory
  138.  
  139. plotscript, Resettable, begin
  140. variable (x, y)
  141. for (x, 5, 8) do (
  142. for (y, 3, 6) do (
  143. delete from board(x, y)
  144. )
  145. )
  146. end
  147.  
  148.  
  149.  
  150. #This is the big cheese. The script that controls most of the
  151. #crafting mechanics, and where you will input information about
  152. #Item placing scripts, crafting recipes and text boxes
  153.  
  154. plotscript, crafting, begin
  155. herotobox
  156. # Prevent the camera from panning as the hero moves
  157. focus camera (0, 0)
  158.  
  159. while (current map == map:Crafting Table) do (
  160. if(key is pressed(key:1)) then (placewood)
  161.  
  162. if(key is pressed(key:2)) then (placeiron)
  163.  
  164. if(key is pressed(key:3)) then (placegold)
  165.  
  166. #a door leading out of
  167. #the crafting table
  168. if(keyval(key:tab) > 1) then (
  169. Show text box (17)
  170. wait for textbox
  171. )
  172.  
  173. # Help
  174. if(keyval(key:H) > 1) then (show text box (14), wait for textbox)
  175.  
  176. if(keyval(key:Delete) > 1) then (deletion)
  177.  
  178. if(keyval(key:enter) > 1) then (
  179. if(check recipes) then (
  180. # clear the table WITHOUT returning placed items to the inventory
  181. reset map state
  182. ) else (
  183. # Could add "resettable" to also wipe the table on an incorrect recipe
  184. )
  185. )
  186.  
  187. wait(1) # finished all processing for this game tick (frame),
  188. #so pause the script until the next tick
  189. )
  190. end
  191.  
  192. # Returns 'true' if a valid recipe
  193. script, check recipes, begin
  194. # Convenience names for the NPC IDs:
  195. variable(_, W, G, I)
  196. _ := -1 # empty space
  197. W := 0 # wood
  198. I := 1 # iron
  199. G := 2 # gold
  200.  
  201. # iron sword
  202. if (check recipe(
  203. _,_,_,I,
  204. I,_,I,_,
  205. _,I,_,_,
  206. W,_,I,_
  207. )) then (
  208. show text box (2)
  209. )
  210. # gold sword
  211. else if (check recipe(
  212. _,_,_,G,
  213. I,_,G,_,
  214. _,G,_,_,
  215. W,_,I,_
  216. )) then (
  217. show text box (3)
  218. )
  219.  
  220.  
  221. # iron armor
  222. else if (check recipe(
  223. _,_,_,_,
  224. I,_,_,I,
  225. _,I,I,_,
  226. _,I,I,_
  227. )) then (
  228. show text box (7)
  229. ) else if
  230.  
  231. # gold armr
  232. (check recipe(
  233. _,_,_,_,
  234. I,_,_,I,
  235. _,G,G,_,
  236. _,G,G,_
  237. )) then (
  238. #show text box (8)
  239. ) else if
  240.  
  241. # iron helmet
  242. (check recipe(
  243. _,_,_,_,
  244. _,_,_,_,
  245. _,I,I,_,
  246. I,_,_,I
  247. )) then (
  248. show text box (5)
  249. ) else if
  250.  
  251. #next recipe gold helmet
  252. (check recipe(
  253. _,_,_,_,
  254. _,_,_,_,
  255. _,G,G,_,
  256. I,_,_,I
  257. )) then (
  258. show text box (6)
  259. ) else if
  260.  
  261. #next recipe iron axe
  262. (check recipe(
  263. _,I,W,_,
  264. _,I,W,_,
  265. _,_,W,_,
  266. _,_,W,_
  267. )) then (
  268. show text box (12)
  269. )else if
  270.  
  271. #next recipe gold axe
  272. (check recipe(
  273. _,G,W,_,
  274. _,G,W,_,
  275. _,_,W,_,
  276. _,_,W,_
  277. )) then (
  278. show text box (13)
  279.  
  280. ) else (
  281. show text box (11)
  282. wait for textbox
  283. exit returning (false) # failure
  284. )
  285. wait for textbox
  286. exit returning (true) # success
  287. end
  288.  
  289.  
  290. plotscript, connect, begin
  291.  
  292. suspend player
  293.  
  294. show text box (20)
  295. wait (15)
  296. show text box (21)
  297. wait (15)
  298. show textbox (22)
  299. wait (15)
  300. show textbox (23)
  301. wait (15)
  302. show textbox (24)
  303. wait (15)
  304. show text box (25)
  305. wait (15)
  306. show text box (21)
  307. wait (15)
  308. show textbox (22)
  309. wait (15)
  310. show textbox (23)
  311. wait (15)
  312. show textbox (24)
  313. wait (15)
  314. show text box (20)
  315. wait (15)
  316. show text box (21)
  317. wait (15)
  318. show textbox (22)
  319. wait (15)
  320. show textbox (23)
  321. wait (15)
  322. show textbox (24)
  323. wait (15)
  324. show text box (25)
  325. wait (15)
  326. show text box (21)
  327. wait (15)
  328. show textbox (22)
  329. wait (15)
  330. show textbox (23)
  331. wait (15)
  332. show textbox (24)
  333. wait (15)
  334. show textbox (26)
  335. wait (10)
  336. resume player
  337. end
Advertisement
Add Comment
Please, Sign In to add comment