Advertisement
Zeldaboy111

Functie & item wisselen ]|[ Skript #346

Sep 13th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.72 KB | None | 0 0
  1. #multiblock structure
  2. #rename function
  3.  
  4. #requires: SkQuery, SkRayFall, Skellett, SkBee
  5.  
  6.  
  7. options:
  8. logo: &6&lBS&8:&7
  9.  
  10. function loop():
  11. if {furnace1.looping} is not true:
  12. set {furnace1.looping} to true
  13. while {furnace1.looping} is true:
  14. if size of {furnace1.loopList::*} is 0:
  15. set {furnace1.looping} to false
  16. stop loop
  17. else:
  18. loop {furnace1.loopList::*}:
  19. add 1 to {furnace1.%loop-value%.smeltTime}
  20. add 1 to {furnace1.%loop-value%.fuelingTime}
  21. if {furnace1.%loop-value%.smeltTime} >= 9:
  22. set {furnace1.%loop-value%.smeltTime} to 0
  23. remove 1 from {furnace1.%{_loc}%.contents.ore}
  24. add 1 to {furnace1.%{_loc}%.contents.ingot}
  25.  
  26. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  27. remove 1 from {furnace1.%loop-value%.contents.fuel}
  28. if {furnace1.%loop-value%.contents.fuel} <= 0:
  29. remove loop-value from {furnace1.loopList::*}
  30.  
  31. wait 1 second
  32.  
  33. function loop1():
  34. #if {furnace2.looping} is not true
  35.  
  36. # Returns how many ticks an item gives fuel
  37. function getFuelingTime(type: Item) :: integer:
  38. if {_type} is lava:
  39. return 20000
  40. else if {_type} is block of coal:
  41. return 16000
  42. else if {_type} is dried kelp block:
  43. return 4000
  44. else if {_type} is blaze rod:
  45. return 2400
  46. else if {_type} is coal or charcoal:
  47. return 1600
  48. else if {_type} is any boat or scaffolding:
  49. return 1200
  50. else if {_type} is any log or any planks or any wood slab or oak wood stairs or spruce wood stairs or birch wood stairs or jungle wood stairs or acacia wood stairs or dark oak wood stairs or any wooden button or any wooden trapdoor or any fence gate or any fence or ladder or crafting table or cartography table or fletching table or smithing table or loom or bookshelf or lectern or composter or chest or trapped chest or barrel or daylight detector or jukebox or note block or red mushroom block or brown mushroom block or mushroom stem or banner or bow or fishing rod:
  51. return 300
  52. else if {_type} is any wooden door or any sign or wooden pickaxe or wooden shovel or wooden hoe or wooden axe or wooden sword:
  53. return 200
  54. else if {_type} is bowl or any sapling or stick or any wool:
  55. return 100
  56. else if {_type} is any carpet:
  57. return 67
  58. else if {_type} is bamboo:
  59. return 50
  60. return 0
  61.  
  62. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  63. function canSmelt(type: Item, tier: Integer) :: boolean:
  64. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  65. return true
  66. else if {_tier} is 2:
  67. if {_type} is diamond ore or emerald ore or nether quartz ore:
  68. return true
  69.  
  70. return false
  71.  
  72. function outlineGui(p: Player):
  73. loop 9 times:
  74. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  75. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  76.  
  77. loop 5 times:
  78. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  79. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  80.  
  81. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  82. open chest with {_rows} rows named {_name} to {_p}
  83. set {inventory.%{_p}%.name} to uncolored {_name}
  84. set {inventory.%{_p}%.current} to {_loc}
  85. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  86. wait 2 ticks
  87. outlineGui({_p})
  88.  
  89. #function gui(p: Player):
  90. # openGuiOutlined({_p}, 6, "&8Anvil")
  91. #subcategorie armor -> alle armor die je kan maken laten zien
  92.  
  93. function guiFurnace1(p: Player, loc: Location):
  94. openGuiOutlined({_p}, {_loc}, 6, "&8Furnace I")
  95.  
  96. if {furnace1.%{_loc}%.contents.fuel} is not set:
  97. set {furnace1.%{_loc}%.contents.fuel} to 0
  98. if {furnace1.%{_loc}%.contents.ore} is not set:
  99. set {furnace1.%{_loc}%.contents.ore} to 0
  100. if {furnace1.%{_loc}%.contents.ingot} is not set:
  101. set {furnace1.%{_loc}%.contents.ingot} to 0
  102.  
  103. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  104. set {furnace1.%{_loc}%.contents.ingot} to 0
  105. if {furnace1.%{_loc}%.contents.oreType} is not set:
  106. set {furnace1.%{_loc}%.contents.ore} to 0
  107. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  108. set {furnace1.%{_loc}%.contents.fuel} to 0
  109.  
  110. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  111. if {furnace1.%{_loc}%.contents.fuelType} is set:
  112. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  113.  
  114. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  115. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  116. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  117.  
  118. if {furnace1.%{_loc}%.contents.ore} > 0:
  119. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  120.  
  121. if {furnace1.%{_loc}%.contents.fuel} > 0:
  122. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  123.  
  124. if {furnace1.%{_loc}%.contents.ingot} > 0:
  125. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  126.  
  127. #Slot for ore
  128.  
  129. #Slot for ingot
  130.  
  131. # loop for the cooking -- use states
  132.  
  133. loop 5 times:
  134. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f0%%"
  135.  
  136.  
  137.  
  138. # U T I L I T I E S
  139.  
  140. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  141. set {_value} to {_base} + {_addToDefault}
  142. if {_value} > {_max}:
  143. set {_value} to {_addToDefault} - ({_max} - {_base})
  144.  
  145. return {_value}
  146.  
  147. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  148. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  149. set {_dir} to {_facing}/2 + 1
  150.  
  151. if {_dir} > 4:
  152. remove 4 from {_dir}
  153.  
  154. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  155. return true
  156. return false
  157.  
  158.  
  159. function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item):
  160. if {_type} is "ore" or "fuel" or "ingot":
  161. set {_p}'s cursor slot to {_clickedItem}
  162. set slot {_slot} of {_p}'s current inventory to {_item}
  163. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%} to amount of {_item}
  164. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%Type} to type of {_item}
  165.  
  166. # amount of {_item} -> niet werkend
  167. # inventory drag?
  168. # functie overal neerzetten
  169. # ingots
  170. # smelting progress
  171.  
  172.  
  173. # F U R N A C E D E T E C T S
  174.  
  175. function isFurnace1(below: Location) :: boolean:
  176. if block at {_below} is campfire:
  177. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  178. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  179. loop 8 times:
  180. set {_checkLoc} to location at x-coordinate of {_below}+{_xAdjust::%loop-value%}, y-coordinate of {_below}, z-coordinate of {_below}+{_zAdjust::%loop-value%} in world of {_below}
  181. if block at {_checkLoc} is not red brick block:
  182. return false
  183. else:
  184. return false
  185. return true
  186.  
  187.  
  188. function isFurnace2(loc: Location) :: boolean:
  189. if block at {_loc} is not blast furnace:
  190. return false
  191.  
  192. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  193. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  194. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  195. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  196.  
  197. set {_base} to -2
  198. if block at location at x-coordinate of {_loc} + {_x::1}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::1} in world of {_loc} is {_layer1::1}:
  199. set {_base} to 0
  200.  
  201. else if block at location at x-coordinate of {_loc} + {_x::3}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::3} in world of {_loc} is {_layer1::1}:
  202. set {_base} to 2
  203.  
  204. else if block at location at x-coordinate of {_loc} + {_x::5}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::5} in world of {_loc} is {_layer1::1}:
  205. set {_base} to 4
  206.  
  207. else if block at location at x-coordinate of {_loc} + {_x::7}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::7} in world of {_loc} is {_layer1::1}:
  208. set {_base} to 6
  209.  
  210. set {_size} to size of {_x::*}
  211. if {_base} is not -2:
  212. loop 7 times:
  213. set {_value} to getNextNumber({_base}, loop-value, {_size})
  214. if block at location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc} is not {_layer1::%loop-value%}:
  215. return false
  216.  
  217.  
  218. set {_facingAdjust::*} to 0, 4, 6 and 8
  219. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  220. loop 4 times:
  221. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  222. set {_check} to location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc} + 1, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc}
  223. set {_facing} to {_base}
  224. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  225. remove {_facingAdjust::%loop-value%} from {_facing}
  226. else:
  227. add {_facingAdjust::%loop-value%} to {_facing}
  228.  
  229. if loop-value is 1:
  230. if block at {_check} is not {_layer2::%loop-value%}:
  231. return false
  232. else if detectStair({_facing} - 2, {_check}, "") is false:
  233. return false
  234.  
  235. if block at location 2 meters above {_loc} is not red brick block:
  236. return false
  237. else:
  238. return false
  239. else:
  240. return false
  241. return true
  242.  
  243. # C L I C K E V E N T S
  244.  
  245. on rightclick on smooth stone:
  246. if player is not sneaking:
  247. if {anvil.%location of clicked block%} is true:
  248. #gui(player)
  249. cancel event
  250.  
  251. on rightclick on cauldron:
  252. if {furnace.%location of event-block%} is true:
  253. if isFurnace1(location 1 meters below clicked block):
  254. cancel event
  255. guiFurnace1(player, location of clicked block)
  256.  
  257. else:
  258. delete {furnace1.%location of clicked block%.contents.fuel}
  259. delete {furnace1.%location of clicked block%.contents.ore}
  260. delete {furnace1.%location of clicked block%.contents.ingot}
  261. delete {furnace.%location of event-block%}
  262.  
  263. on rightclick on blast furnace:
  264. if {furnace2.%location of event-block%} is true:
  265. if isFurnace2(location of clicked block):
  266. cancel event
  267. send "WIP"
  268. else:
  269. delete {furnace2.%location of event-block%}
  270.  
  271. on rightclick holding stone axe:
  272. if clicked block is smooth stone or iron block or diamond block:
  273. if {anvil.%location of event-block%} is not true:
  274. set {anvil.%location of event-block%} to true
  275. set {_tier} to "Tier I"
  276. if clicked block is smooth stone:
  277. set {anvil.%location of event-block%.tier} to 1
  278. else if clicked block is iron block:
  279. set {anvil.%location of event-block%.tier} to 2
  280. set {_tier} to "Tier II"
  281. else:
  282. set {anvil.%location of event-block%.tier} to 3
  283. set {_tier} to "Tier III"
  284.  
  285. set {_s} to 6
  286. loop all players in radius 6 around event-block:
  287. set {_v} to ({_s} - distance between loop-player and event-block)
  288. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  289.  
  290. send "{@logo} Successfully created an anvil of %{_tier}%."
  291. summon armor stand at location 0.6 meters below event-block
  292. set name of last spawned armor stand to "&7Anvil"
  293. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  294.  
  295. summon armor stand at location 0.9 meters below event-block
  296. set name of last spawned armor stand to "&7%{_tier}%"
  297. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  298.  
  299. else if clicked block is cauldron:
  300. if {furnace.%location of event-block%} is not true:
  301. if isFurnace1(location 1 meters below clicked block):
  302. set {furnace.%location of event-block%} to true
  303. cancel event
  304.  
  305. else if clicked block is blast furnace:
  306. if {furnace.%location of event-block%} is not true:
  307. if isFurnace2(location of clicked block):
  308. set {furnace2.%location of event-block%} to true
  309. cancel event
  310. send "WIP"
  311.  
  312. on break of smooth stone or iron block or diamond block:
  313. if {anvil.%location of event-block%} is true:
  314. set {_s} to 6
  315. loop all players in radius 6 around event-block:
  316. set {_v} to ({_s} - distance between loop-player and event-block)
  317. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  318. delete {anvil.%location of event-block%}
  319. delete {anvil.%location of event-block%.tier}
  320. loop entities in radius 1 around event-block:
  321. if type of loop-entity is armor stand:
  322. kill loop-entity
  323.  
  324.  
  325. on inventory click:
  326. if type of clicked inventory is chest inventory:
  327. if inventory name of player's current inventory is "&8Anvil":
  328. cancel event
  329.  
  330. else if inventory name of player's current inventory is "&8Furnace I":
  331. cancel event
  332. if clicked slot is set:
  333. if clicked item is not air:
  334. set {_item} to player's cursor slot
  335. if {_item} is not air:
  336. if name of clicked item is "&a&lOre":
  337. if canSmelt({_item}, 1):
  338. set slot (clicked slot) of player's current inventory to {_item}
  339. set player's cursor to air
  340. else if name of clicked item is "&a&lFuel":
  341. if getFuelingTime({_item}) > 0:
  342. set slot (clicked slot) of player's current inventory to {_item}
  343. set player's cursor to air
  344. else if getFuelingTime(clicked item) > 0:
  345. if getFuelingTime({_item}) > 0:
  346. set player's cursor slot to clicked item
  347. set slot (clicked slot) of player's current inventory to {_item}
  348. else if canSmelt(clicked item, 1) is true:
  349. if canSmelt({_item}, 1):
  350. setItemInSlot(player, "ore", clicked slot, clicked item, {_item})
  351. else if getFuelingTime(clicked item) > 0:
  352. set player's cursor slot to clicked item
  353. set slot (clicked slot) of player's current inventory to lime stained glass pane named "&a&lFuel"
  354. else if canSmelt(clicked item, 1) is true:
  355. set player's cursor slot to clicked item
  356. set slot (clicked slot) of player's current inventory to lime stained glass pane named "&a&lOre"
  357.  
  358. #ingot check
  359. #set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  360.  
  361. #ore type
  362. #fuel type
  363.  
  364. # on inventory drag?
  365. # fuel/ore uit cursor slot verwijderen
  366. # fuel/ore uit inventory halen
  367. # fuel/ore opslaan
  368.  
  369.  
  370. on inventory close:
  371. if {inventory.%player%.name} is set:
  372. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  373. delete {inventory.%player%.name}
  374. delete {inventory.%player%.current}
  375.  
  376. #Cancel in crafting table or below
  377. #register new shaped recipe for air using iron ingot, air, iron ingot, iron ingot, chest, iron ingot, air, iron ingot, air
  378.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement