##Core Script## ##Inventory for the shop creator menu## ShopCreatorInv: type: inventory title: Shop Editor size: 54 inventory: CHEST slots: - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] [SaveShopIt]" - "[ClearCostIt] [CostMinus1It] [CostMinus10It] [CostMinus100It] [CostMinus1000It] [CostPlus1It] [CostPlus10It] [CostPlus100It] [CostPlus1000It]" Procedural Items: - if && : - determine ].read[]> - stop - if : - determine ##World script to handle Shop Creator Inventory## ShopCreatorHandler: type: world debug: true events: on player drags in ShopCreatorInv: - determine cancelled after player clicks in ShopCreatorInv: - if == : - if && : - if : - define adjustedcost - if == 0: - if : - adjust def:adjustedcost "lore:Click Here to Sell! Offer: $<[adjustedcost].nbt[Cost]>" - else: - adjust def:adjustedcost "lore:Click Here to Buy! For: $<[adjustedcost].nbt[Cost]>" - else: - adjust def:adjustedcost "lore:<[adjustedcost].lore.include[Click Here to Buy! Cost: $<[adjustedcost].nbt[Cost]>]>" - inventory set destination: origin:<[adjustedcost]> slot: - adjust item_on_cursor:air - stop on player clicks in ShopCreatorInv: ##Prevent players from placing Shop Menu items in other slots of the menu## - if : - determine passively cancelled ##Prevent players from placing Cost Adjustment items into their inventory## - if && : - determine passively cancelled - stop - if > 54: - if : - determine passively cancelled - narrate "You can't use that there!" - stop ##Prevent a player from placing an adjusted item into their inventory## - if : - determine passively cancelled - narrate "Click on ClearCost to reset an item!." - stop - else: - stop ##Prevent replacing items with Shop Creator Items## - if && : - if : - determine passively cancelled - stop ##Add Cost Item To Cursor## - if > 0 || < 0: - determine passively cancelled - if == : - if == 64: - stop - else: - adjust quantity: save:AdjustCost - adjust item_on_cursor: - stop - else: - if != Save && != Clear: - adjust item_on_cursor: ##Add/Subtract Cost## - if > 54 && : - determine passively cancelled - stop - if && : - if == Clear: - stop - if ]>]> < 0: - determine passively cancelled - narrate "You cannot have a cost go below 0!" - stop - define adjustedcost ]>]>]> - adjust def:adjustedcost "lore:<[adjustedcost].lore.set[Click Here to Buy! Cost: $<[adjustedcost].nbt[Cost]>].at[<[adjustedcost].lore.size>]>" - inventory set destination: origin:<[adjustedcost]> slot: - define CursorStack - adjust item_on_cursor:air ##Clear Cost## on player left clicks ClearCostIt in ShopCreatorInv: - determine passively cancelled - if : - define ClearCost - adjust def:ClearCost remove_nbt - adjust def:ClearCost Lore:]> - adjust item_on_cursor:<[ClearCost]> - narrate "Cost removed from Item." - stop - adjust item_on_cursor:air on player right clicks ClearCostIt in ShopCreatorInv: - determine passively cancelled - adjust item_on_cursor:ClearCostIt on player clicks in ShopCreatorInv with:ClearCostIt: - if > 54: - adjust item_on_cursor:air - determine cancelled - stop - if || : - determine passively cancelled - stop - determine passively cancelled - define adjustedcost - adjust def:adjustedcost "lore:<[adjustedcost].lore.set[Click Here to Buy! Cost: $<[adjustedcost].nbt[Cost]>].at[<[adjustedcost].lore.size>]>" - inventory set destination: origin:<[adjustedcost]> slot: - define CursorStack - adjust item_on_cursor:air - adjust item_on_cursor:<[CursorStack]> ##Save and Exit## on player clicks SaveShopIt in ShopCreatorInv: - determine passively cancelled - narrate "Shop Inventory: has been saved to File:.yml!" - if : - yaml id: set :! - foreach : - yaml id: set :->:<[value]> - yaml savefile:/Shops/.yml id: - yaml unload id: - flag player SellShop:! - flag player AdjustedCost:! - flag player EditShop:! - flag player ShopCreator:! - inventory close ShopCreatorCmd: type: command name: createshop usage: /createshop description: "Use to create a list for a Denizen shop script. /createshop File:<&lc>FileName<&rc> Shop:<&lc>ShopName<&rc> | add Delete to delete a shop | add Edit to edit an existing shop." permission: denizen.shopcreator script: - if || : - flag player EditShop:! - flag player ShopCreator:! - flag player SellShop:! ##Delete Shop## - if : - if ]>.yml].not>: - narrate "The File: ]>.yml does not exist! Did you type it in correctly?" - stop - yaml load:/Shops/]>.yml id:]> - if ]>].contains[]>].not>: - narrate "The Shop: ]> does not exist in File: ]>! Did you type it in correctly?" - stop - yaml id:]> set ]>:! - yaml savefile:/Shops/]>.yml id:]> - narrate "The Shop: ]> in File: ]> has been deleted!" - stop ##Edit Shop## - if : - if : - flag player AdjustedCost:! - if ]>.yml].not>: - narrate "The File: ]>.yml does not exist! Did you type it in correctly?" - stop - yaml load:/Shops/]>.yml id:]> - if ]>].contains[]>].not>: - narrate "The Shop: ]> does not exist in File: ]>! Did you type it in correctly?" - stop - flag player EditShop:|:]>|]> - flag player ShopCreator:|:]>|]> - inventory open d:ShopCreatorInv - stop ##Create Shop## - if ]>.yml].not>: - yaml create id:]> - yaml savefile:/Shops/]>.yml id:]> - yaml load:/Shops/]>.yml id:]> - else: - yaml load:/Shops/]>.yml id:]> - if ]>].contains[]>]>: - yaml unload id:]> - narrate "That shop already exists! If you wish to Edit or Delete a Shop, add those arguments when using the /createshop command." - stop - flag player ShopCreator:|:]>|]> - inventory open d:ShopCreatorInv - if : - flag player SellShop ##Shop Creator Items## SaveShopIt: type: item display name: Save Shop material: writable_book[nbt=ShopMenuItem/Save] lore: - "Click here to save this shop inventory." ClearCostIt: type: item display name: Clear Cursor material: barrier[nbt=ShopMenuItem/Clear] lore: - "Clicking here with a Cost Editting item" - "will clear it from your cursor." - "Right click to pick up this item." - "Click an item to adjust its cost to $0." - "With a cost adjusted item on your cursor" - "click here to reset the item entirely." CostPlus1It: type: item display name: Add $1 material: stone[nbt=ShopMenuItem/1] lore: - "Click here to add $1 to the price" - "of an item. With this item in hand" - "click on an item. It will add $1" - "for each item in the held stack." CostPlus10It: type: item display name: Add $10 material: iron_block[nbt=ShopMenuItem/10] lore: - "Click here to add $10 to the price" - "of an item. With this item in hand" - "click on an item. It will add $10" - "for each item in the held stack." CostPlus100It: type: item display name: Add $100 material: gold_block[nbt=ShopMenuItem/100] lore: - "Click here to add $100 to the price" - "of an item. With this item in hand" - "click on an item. It will add $100" - "for each item in the held stack." CostPlus1000It: type: item display name: Add $1000 material: diamond_block[nbt=ShopMenuItem/1000] lore: - "Click here to add $1000 to the price" - "of an item. With this item in hand" - "click on an item. It will add $1000" - "for each item in the held stack." CostMinus1It: type: item display name: Subtract $1 material: coal_ore[nbt=ShopMenuItem/-1] lore: - "Click here to subtract $1 to the price" - "of an item. With this item in hand" - "click on an item. It will subtract $1" - "for each item in the held stack." CostMinus10It: type: item display name: Subtract $10 material: iron_ore[nbt=ShopMenuItem/-10] lore: - "Click here to subtract $10 to the price" - "of an item. With this item in hand" - "click on an item. It will subtract $10" - "for each item in the held stack." CostMinus100It: type: item display name: Subtract $100 material: gold_ore[nbt=ShopMenuItem/-100] lore: - "Click here to subtract $100 to the price" - "of an item. With this item in hand" - "click on an item. It will subtract $100" - "for each item in the held stack." CostMinus1000It: type: item display name: Subtract $1000 material: diamond_ore[nbt=ShopMenuItem/-1000] lore: - "Click here to subtract $1000 to the price" - "of an item. With this item in hand" - "click on an item. It will subtract $1000" - "for each item in the held stack." ##Player Shop Creation System## PlayerShopHandler: type: world events: on player places PlayerShopIt: - flag player ShopOwner: - flag player ShopCreator:|:PlayerShops|| - inventory open d:ShopCreatorInv on player closes ShopCreatorInv: - foreach : - if <[value].contains[ClearCostIt]> || <[value].contains[CostMinus1000It]> || <[value].contains[CostMinus100It]> || <[value].contains[CostMinus10It]> || <[value].contains[CostMinus1It]> || <[value].contains[CostPlus1000It]> || <[value].contains[CostPlus100It]> || <[value].contains[CostPlus10It]> || <[value].contains[CostPlus1It]>: - take <[value]> quantity:<[value].quantity> ##Player Shop Creation Item## PlayerShopIt: type: item material: sign display name: Shop Post lore: - "Congratulations! You're the proud owner" - "of a Personal Shop Post. Simply place" - "this sign anywhere you're allowed to" - "setup your own Personal Shop! Others will" - "be able to purchase items you place there!" - "Should you need to restock, simply right" - "click this sign!" ##Example Shop## GenericShopInv: type: inventory inventory: CHEST title: Shop Name Here size: 45 slots: - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" - "[] [] [] [] [] [] [] [] []" Procedural Items: - determine NPCAssignment: type: assignment debug: true actions: on assignment: - trigger name:click state:true interact scripts: - NPCInteract NPCInteract: type: interact debug: true steps: 1: click trigger: script: - narrate "Greeting Here" - yaml load:/Shops/FileName.yml id:ShopName - wait 2 - inventory open d:GenericShopInv - yaml unload id:ShopName ShopMenuHandler: type: world events: on player drags in GenericShopInv: - determine cancelled on player clicks in GenericShopInv: - determine passively cancelled - if : - if ]>: - if == 0: - narrate "Your inventory has no space!" - stop - take money quantity: - define Item - adjust def:Item remove_nbt - adjust def:Item Lore:]> - give <[Item]> - narrate "$ has been removed from your wallet." - flag player TotalSpent:+: - stop - else: - narrate "You don't have enough money! Cost: $ Your Money: $" - stop