Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include, plotscr.hsd
- include, crafter.hsi
- include, scancode.hsi #very important to include this so Custom knows what keys are pressed
- #These scripts are for use in Minecraft style item crafting. They can be implemented for
- #use on a Map representing a crafting table similar to the 3x3 grid used at the crafting
- #table in Minecraft. This script is currently set up for using a 4x4 tile grid, but can be
- #amended for whatever size grid you want to use, by adding, or deleting map coordinates.
- # This script is for identifying your NPCs representing raw material
- #items in such a way that they are recognized by their ID number, while
- #the absence on any NPC, or False Return, is always represented by (-1)
- plotscript, npc id at spot, x, y, begin
- if (npc at spot(x, y) == 0) then (
- return (-1) # no NPC
- ) else (
- return (get npc id(npc at spot(x, y)))
- )
- end
- #This script, graciously annd ingeniously devised by SS user TMC, is used in conjunction with
- plotscript, check recipe, x0y0, x1y0, x2y0, x3y0, x0y1, x1y1, x2y1, x3y1, x0y2, x1y2, x2y2, x3y2, x0y3, x1y3, x2y3, x3y3, begin
- if (npc id at spot(5, 3) == x0y0 && #the starting npc id at spot coordinate will depend on
- npc id at spot(6, 3) == x1y0 && #where you place the first tile of your crafting table on
- npc id at spot(7, 3) == x2y0 && #the map you are using. This example uses the coordinate
- npc id at spot(8, 3) == x3y0 && #5,3 as the topleft most tile of the table. This will
- npc id at spot(5, 4) == x0y1 && #translate to the x,y crafting table coordinate 0,0
- npc id at spot(6, 4) == x1y1 &&
- npc id at spot(7, 4) == x2y1 &&
- npc id at spot(8, 4) == x3y1 &&
- npc id at spot(5, 5) == x0y2 &&
- npc id at spot(6, 5) == x1y2 &&
- npc id at spot(7, 5) == x2y2 &&
- npc id at spot(8, 5) == x3y2 &&
- npc id at spot(5, 6) == x0y3 &&
- npc id at spot(6, 6) == x1y3 &&
- npc id at spot(7, 6) == x2y3 &&
- npc id at spot(8, 6) == x3y3
- )
- then (return (true)) else (return (false))
- end
- #These scripts are used for placing a walkabout NPC representing a raw
- #material item onto your crafting table. They work by checking your
- #inventory to see if you have any of the required item, if not ithis
- #script is set for a sound to play, if so, an NPC representing the item
- #you wish to place will be created on the spot of your cursor, and one of
- #that item will be deleted from your inventory. This script is also set do
- #destroy and NPCs on that tile prior to placinga new one, to prevent
- #acidentally placing multiple NPCs.
- plotscript, placewood, begin
- if (inventory (item:wood) >0) then (
- deletion # Remove existing item so that ti can be overwritten
- create npc (0, hero x, hero y)
- delete item (item:wood)
- ) else (play sound (1,false,false))
- end
- plotscript, placeiron, begin
- if (inventory (item:iron ore) >0) then (
- deletion
- create npc (1, hero x, hero y)
- delete item (item:iron ore)
- ) else (play sound (1,false,false)) #etc...
- end
- plotscript, placegold, begin
- if (inventory (item:gold ore) >0) then (
- deletion
- create npc (2, hero x, hero y)
- delete item (item:gold ore)
- ) else (play sound (1,false,false)) #etc...
- end
- #This is a script which allows the player to delete an item they placed
- #erroneously. It will remove the NPC from that tile, and return one of
- #the appropriate item to their inventory.
- plotscript, deletion, begin
- delete from board(hero x, hero y)
- end
- #This script is called by all successful recipe alerts to reset the crafting table
- #by using a door, but that was buggy so I've changed it. Script no longer needed -- TMC
- plotscript, resetdoor, begin
- end
- plotscript, leave table, begin
- showvalue(currentmap)
- reset table
- use door (2) # leave the map
- end
- #This script is used to find and identify all npcs on the crafting table
- # It is used in conjunction with the reset table script.
- script, delete from board, x, y, begin
- variable(npcref, id)
- npcref := npc at spot(x, y) # get the NPC reference
- id := npc id at spot(x, y)
- if (npcref == 0) then (exit script)
- destroy npc (npcref)
- # Figuring out which item to return
- if (id == 0) then (get item (item: wood))
- else if (id == 1) then (get item (item: iron ore))
- else if (id == 2) then (get item (item: gold ore))
- end
- #This script is used to transform your hero into a cursor, or box
- #to use on the crafting table map. In addition to including this
- #in the crafting script it can be used as an each-step script
- plotscript, Herotobox, begin
- set hero picture (0,0 ,outside battle)
- set hero palette (0,0,outside battle)
- end
- #This Script returns your hero to his or her original appearance
- #It does the opposite of the HerotoBox Script
- plotscript, resethero, begin
- reset hero picture (0, outside battle)
- reset hero palette (0, outside battle)
- end
- #this script clears the crafting table, and returns any placed items
- #to your hero's inventory
- plotscript, Resettable, begin
- variable (x, y)
- for (x, 5, 8) do (
- for (y, 3, 6) do (
- delete from board(x, y)
- )
- )
- end
- #This is the big cheese. The script that controls most of the
- #crafting mechanics, and where you will input information about
- #Item placing scripts, crafting recipes and text boxes
- plotscript, crafting, begin
- herotobox
- # Prevent the camera from panning as the hero moves
- focus camera (0, 0)
- while (current map == map:Crafting Table) do (
- if(key is pressed(key:1)) then (placewood)
- if(key is pressed(key:2)) then (placeiron)
- if(key is pressed(key:3)) then (placegold)
- #a door leading out of
- #the crafting table
- if(keyval(key:tab) > 1) then (
- Show text box (17)
- wait for textbox
- )
- # Help
- if(keyval(key:H) > 1) then (show text box (14), wait for textbox)
- if(keyval(key:Delete) > 1) then (deletion)
- if(keyval(key:enter) > 1) then (
- if(check recipes) then (
- # clear the table WITHOUT returning placed items to the inventory
- reset map state
- ) else (
- # Could add "resettable" to also wipe the table on an incorrect recipe
- )
- )
- wait(1) # finished all processing for this game tick (frame),
- #so pause the script until the next tick
- )
- end
- # Returns 'true' if a valid recipe
- script, check recipes, begin
- # Convenience names for the NPC IDs:
- variable(_, W, G, I)
- _ := -1 # empty space
- W := 0 # wood
- I := 1 # iron
- G := 2 # gold
- # iron sword
- if (check recipe(
- _,_,_,I,
- I,_,I,_,
- _,I,_,_,
- W,_,I,_
- )) then (
- show text box (2)
- )
- # gold sword
- else if (check recipe(
- _,_,_,G,
- I,_,G,_,
- _,G,_,_,
- W,_,I,_
- )) then (
- show text box (3)
- )
- # iron armor
- else if (check recipe(
- _,_,_,_,
- I,_,_,I,
- _,I,I,_,
- _,I,I,_
- )) then (
- show text box (7)
- ) else if
- # gold armr
- (check recipe(
- _,_,_,_,
- I,_,_,I,
- _,G,G,_,
- _,G,G,_
- )) then (
- #show text box (8)
- ) else if
- # iron helmet
- (check recipe(
- _,_,_,_,
- _,_,_,_,
- _,I,I,_,
- I,_,_,I
- )) then (
- show text box (5)
- ) else if
- #next recipe gold helmet
- (check recipe(
- _,_,_,_,
- _,_,_,_,
- _,G,G,_,
- I,_,_,I
- )) then (
- show text box (6)
- ) else if
- #next recipe iron axe
- (check recipe(
- _,I,W,_,
- _,I,W,_,
- _,_,W,_,
- _,_,W,_
- )) then (
- show text box (12)
- )else if
- #next recipe gold axe
- (check recipe(
- _,G,W,_,
- _,G,W,_,
- _,_,W,_,
- _,_,W,_
- )) then (
- show text box (13)
- ) else (
- show text box (11)
- wait for textbox
- exit returning (false) # failure
- )
- wait for textbox
- exit returning (true) # success
- end
- plotscript, connect, begin
- suspend player
- show text box (20)
- wait (15)
- show text box (21)
- wait (15)
- show textbox (22)
- wait (15)
- show textbox (23)
- wait (15)
- show textbox (24)
- wait (15)
- show text box (25)
- wait (15)
- show text box (21)
- wait (15)
- show textbox (22)
- wait (15)
- show textbox (23)
- wait (15)
- show textbox (24)
- wait (15)
- show text box (20)
- wait (15)
- show text box (21)
- wait (15)
- show textbox (22)
- wait (15)
- show textbox (23)
- wait (15)
- show textbox (24)
- wait (15)
- show text box (25)
- wait (15)
- show text box (21)
- wait (15)
- show textbox (22)
- wait (15)
- show textbox (23)
- wait (15)
- show textbox (24)
- wait (15)
- show textbox (26)
- wait (10)
- resume player
- end
Advertisement
Add Comment
Please, Sign In to add comment