Create a free account to remove all ad content.

Author Topic:  [Blueprint] Intance Chest  (Read 387 times)

0 Members and 1 Guest are viewing this topic.

muD

  • Legendary Member
  • *
  • Posts: 1177
    • View Profile
[Blueprint] Intance Chest
« on: December 31, 2014, 08:55:50 AM »
Instance Chest

An example of a scripted Instanced Chest.
Used to give each player one instance of the chests inventory.


Each player can take each item, one time each..
Once a player has taken an item, the chest will no longer stock that item for that player.


The Scripts

This scriptwork can be replicated into your Creative world.
Note: Replace all forward slashes with backslashes. The forum board doesn't display the backslash.

Creative Scripts:
Spoiler for Creative Scripts:
Place a chest on a scriptblock, anywhere in your Creative world.
Like so:
<- Leave empty
<- Set to run 2 scripts.

Script 1:
iChest1/Open
-Run when scriptblock is powered ON. When chest is opened

Code: [Select]
1. Inventory [rel:0,1,0] [clear]
2.
3. If
4.   HasHistory [iChest/Iron Sword] [player] [false]
5. Then
6.   Inventory [rel:0,1,0] [add] [ironsword]
7. Endif
8.
9.  // To add more item support: Copy & paste lines 3-7, then edit item names.
10. // Example:
11.
12. If
13.   HasHistory [iChest/Iron Shield] [player] [false]
14. Then
15.   Inventory [rel:0,1,0] [add] [ironshield]
16. Endif


Script 2:
iChest1/Close
-Run when scriptblock is powered Off. When chest is closed

Code: [Select]
1. If
2.   HasInventory [rel:0,1,0] [ironsword] [<] [1]
3. Then
4.   History [iChest1/Iron Sword] [clear] [player]
5.   History [iChest1/Iron Sword] [player]
6. Endif
7.
8.  // To add more item support: Copy & paste lines 1-6, then edit the item names.
9.  // Example:
10.
11. If
12.   HasInventory [rel:0,1,0] [ironshield] [<] [1]
13. Then
14.   History [iChest1/Iron Shield] [clear] [player]
15.   History [iChest1/Iron Shield] [player]
16. Endif


Scripts for Survival & Dig Deep:
Spoiler for Survival Scripts:
Stack a Locked (or buried) chest, a scriptblock and a chest, anywhere in your world.
Like so:
<- Leave empty
<- Set to run 2 scripts
<- Stocked with Iron Swords
<- Stocked with Iron Shields
Place more chests with items to suit.

Script 1:
iChest1/Open
-Run when scriptblock is powered ON. When chest is opened

Code: [Select]
1. Inventory [rel:0,1,0] [clear]
2.
3. If
4.   HasHistory [iChest/Iron Sword] [player] [false]
5. Then
6.   Inventory [rel:0,-1,0] [rel:0,1,0] [move] [ironsword] [1]
7. Endif
8.
9.  // To add more item support: Copy & paste lines 3-7, then edit item names.
10. // Example:
11.
12. If
13.   HasHistory [iChest/Iron Shield] [player] [false]
14. Then
15.   Inventory [rel:0,-2,0] [rel:0,1,0] [move] [ironshield] [1]
16. Endif


Script 2:
iChest1/Close
-Run when scriptblock is powered Off. When chest is closed

Code: [Select]
1. If
2.   HasInventory [rel:0,1,0] [ironsword] [<] [1]
3. Then
4.   History [iChest1/Iron Sword] [clear] [player]
5.   History [iChest1/Iron Sword] [player]
6. Endif
7.
8.  // To add more item support: Copy & paste lines 1-6, then edit the item names.
9.  // Example:
10.
11. If
12.   HasInventory [rel:0,1,0] [ironshield] [<] [1]
13. Then
14.   History [iChest1/Iron Shield] [clear] [player]
15.   History [iChest1/Iron Shield] [player]
16. Endif



You can copy & paste the iChest to create multiple instances of the same iChest. i.e. All copies will act the same, giving the player one instance of each item. If they take an item from one, it will also remove it from the other.

To make a new, unique iChest with its own items; Open both scripts and select 'Copy to New Script', then edit each script name from iChest1 to iChest2.
-This will allow you to edit all the items without it effecting the other iChests.



Can be modified to:
-Stock stacks of items and record how many the player takes.
-Allow the player to replace items.


Important:
Scripted Instance Chests cannot be used as normal chests.
Any items which are not scripted to be in there will be deleted whenever it is opened.
iChests are not intended to be personal storage units; They are for giving players set items.