StorekeeperPlayerOwned: type: assignment debug: true default constants: server_price_requirment: true store open hour: 5 store close hour: 18 store greetings: li@Welcome to my store!|Feel free to look around!|Just give me a click if you need something! actions: # Just some setup of the triggers on remove: - flag server playerstore:<-: on assignment: - trigger name:proximity toggle:true radius:30 - trigger name:click toggle:true - trigger name:chat toggle:true - trigger name:damage toggle:true - flag npc cashregister:5 on enter proximity: - foreach { - if ! { - adjust %value% framed:]>]> } } - define name - define keeper - if !]> && '' { - inventory add o:in@def[name]_shopping_bag d: - take "i@shopping bag" - narrate "No stealing items from my store!!" } - if == && ]||null> && ! { - narrate "Hello just ask for 'help' if you need a command refresher for your shop" - flag player greeted duration:5m } else if ! && ]||null> { - if ! == null { - narrate "" } else { - narrate "].as_list.random>" } - flag player greeted duration:30s } on damage: - define name - flag player storekeepernpc:n@ - if == { - narrate " The balance is " - narrate "would you like to 'give' money to your store or 'take' money from your store?" } else if '!' && '!' { - note 'in@player bag' as:_shopping_bag - animate arm_swing - flag player storekeepernpc: - narrate 'Here, have a complimentary shopping bag!' - give 'i@shopping bag' } else if == 'i@shopping bag' && == server { - define total_price 0 - foreach { - adjust %value% quantity:1 save:item2 - if ]||null> == null { - flag server :1.00 } - adjust %value% quantity:1 save:item - define price ].mul[2].mul[]>].mul[]||null> - define total_price } - narrate "Ready to check out? Just click me with your bag!" - narrate "your total price is %total_price%" } else if == 'i@shopping bag' { - define total_price 0 - define name - foreach { - if !].mul[<%value%.qty>]||null> == null { - define price ].mul[]||null> } else { - define price ]>].mul[]||null> - define total_price } } - narrate "Ready to check out? Just click me with your bag!" - narrate "your total price is %total_price%" } else if == 'i@selling_bag' && == server { - define total_price 0 - foreach { - adjust %value% quantity:1 save:item - define price ].mul[]> - define total_price } - narrate "Ready to sell items? Just right click me with your bag!" - narrate "your total price is %total_price%" } else if == 'i@selling_bag' { - define total_price 0 - foreach { - define price - define total_price } - narrate "Ready to sell items? Just right click me with your bag!" - narrate "your total price is %total_price%" } else { - flag player storekeepernpc:n@ } on chat: - if == greeting && == { - narrate "Would you like to add or remove a greeting?" - flag player greeting - determine cancelled } - if == true && == { - if == add { - if > 4 { - narrate "You cannot exceed five greetings!" - flag player greeting:! - determine cancelled - queue clear } else { - narrate "Please say the greeting you would like to add to your store" - flag player greeting:! - flag player addgreeting - determine cancelled } } else if == remove && == { - flag player greeting:! - flag player removegreeting - narrate "What line number would you like to remove?" - foreach { - narrate "%loop_index%=%value%" } - determine cancelled } } - if == true && == { - narrate "]>" - narrate "Has been removed" - flag npc greeting[]:<- - flag player removegreeting:! - determine cancelled } - if == true && == { - flag npc greeting:->: - flag player addgreeting:! - narrate "You added a new greeting to your list. Your new greeting is" - narrate "" - determine cancelled } - if == expand && == { - execute as_op "npc select as:" - flag server playerstore:<-: - give i@storelocationstick4 - narrate "please reselect the bottom and top corners of your cuboid then drop the selector" - determine cancelled } - if == help && == { - narrate "your shop commands are Greeting, items, give, take, set, unset, expand." - narrate "Click the npc with an item to set a price for it" - narrate "Right click the npc without an item to view inventory for the store" - determine cancelled } - if == items && == { - if == null { - narrate "No items have been sold to your shop" } else { - give - flag npc buyback:! - determine cancelled } } - if == true && == { - flag npc cashregister:+: - take money qty: - narrate "You give to the cash register. The balance is now " - flag player givingtocashregister:! - determine cancelled } - if == give && == { - flag player givingtocashregister - narrate "How much would you like to give to the store?" - determine cancelled } - if == take && == { - flag player takingfromcashregister - narrate "How much would you like to take from the store?" - determine cancelled } - if == true && == { - if > { - flag npc cashregister:-: - give money qty: - narrate "You take from the cash register. The balance is now " - flag player takingfromcashregister:! - determine cancelled } else if < { - narrate "You havnt got that much money in your cashregister!" } } - if == unset && == { - flag server playerstore:<-: - narrate "your store is now unprotected! tell the npc to 'set' the store back up when you are done editing" - determine cancelled } - if == sell { - if == server { - note 'in@selling bag' as:_selling_bag - animate arm_swing - narrate 'Here is your item selling bag!' } else { - note 'in@player bag' as:_selling_bag - animate arm_swing - narrate 'Here is your item selling bag!' - narrate "We buy the following items that you have" - foreach { - if !]||null> == null { - if <%value%.display||null> == null { - narrate "We buy <%value%.material.name||null> for ]||null> coins a piece" } else { - narrate "We buy <%value%.display||null> for ]||null> coins a piece" } } } } - drop 'i@selling_bag' ].add[0,1,0]||null> - determine cancelled } - if == set && == && ! contains { - narrate "<&b>your store is now open for business!" - flag server playerstore:->: - flag npc storeitems:! - foreach { - if == item_frame { - flag npc storeitems:->: - flag npc storeitemlocations:->: } } - determine cancelled } - if == buying && == { - if == true { - narrate "please set a price below ]||null> for that item." - flag player settype:buy - determine cancelled } else { - flag player settype:buy - narrate "please set a price for that item" - determine cancelled } } - if == selling && == { - if == true { - narrate "please set a price above ]||null> for that item." - flag player settype:sell - determine cancelled } else { - flag player settype:sell - narrate "please set a price for that item" - determine cancelled } } - if ! == null && == { - if == buy && == true { - if > ]||null> && { - narrate "your price needs to be below the base price. this price will not be set for this item." - flag npc currentitem:! - flag player settype:! - determine cancelled } else if < ]||null> && { - flag npc _: - if == null { - narrate " price is now set to " } else { - narrate " price is now set to " } - flag npc currentitem:! - flag player settype:! - determine cancelled } else { - narrate "That doesn not match a valid number! please set a proper number for a price" - determine cancelled } } } - if ! == null && == { - if == sell && == true { - if < ]||null> && { - narrate "your price needs to be above the base price. this price will not be set for this item." - flag npc currentitem:! - flag player settype:! - determine cancelled } else if > ]||null> && { - flag npc _: - if == null { - narrate " price is now set to " } else { - narrate " price is now set to " } - flag npc currentitem:! - flag player settype:! - determine cancelled } else { - narrate "That doesn not match a valid number! please set a proper number for a price" - determine cancelled } } } - if ! == null && == { - if ! == true { - if { - flag npc _: - if == null { - narrate " price is now set to " } else { - narrate " price is now set to " } - flag npc currentitem:! - flag player settype:! - determine cancelled } else { - narrate "That is not a valid number. please select a valid number for the price" - determine cancelled } } on click: - define name - if == && ! == i@air { - adjust quantity:1 save:item8 - flag npc currentitem: - narrate "will you be 'selling' or 'buying' for this item?" - queue clear - determine cancelled } else if == && == i@air { - inventory open d: } - if == "i@shopping bag" { - if == 0 { - narrate "your shopping bag is empty!" } else if == server { - flag player delay duration:3s - chat "ok let's total these items up for you then!" - define total_price 0 - foreach { - adjust %value% quantity:1 save:item2 - if ]||null> == null { - flag server :1.00 } - adjust %value% quantity:1 save:item - define price ].mul[2].mul[]||null>].mul[<%value%.qty||null>]> - define total_price } - if < %total_price% { - narrate "YOU NEED MONEYS D=" - queue clear } - flag player bagnumber:+:1 - note "in@player bag" "as: _item_bag" - take money qty:%total_price% - run "itemgiverPlayer Owned" delay:1s - take 'i@shopping bag' - narrate "The shopkeeper takes %total_price% coins" - narrate "You are all checked out. have a great day!" - narrate "Do not open your item bag until you are ready to take all the items out" - foreach { - adjust %value% quantity:1 save:item9 - flag server adjust:+: - run script:price_adjuster def: } } else { - flag player delay duration:3s - chat "ok let's total these items up for you then!" - define total_price 0 - foreach { - adjust %value% quantity:1 save:item2 - if .full.escaped>]> == null { - flag server <.full.escaped>:1.00 } - define price ]>].mul[<%value%.qty>]> - define total_price } - if < %total_price% { - narrate "YOU NEED MONEYS D=" - queue clear } - if contains _shopping_bag.list_contents.simple> { - narrate "I am sorry but we just ran out of some of those items!" - queue clear } - flag player bagnumber:+:1 - note "in@player bag" "as: _item_bag" - take money qty:%total_price% - flag npc cashregister:+:%total_price% - run "itemgiverPlayer Owned" delay:1s - take 'i@shopping bag' - narrate "The shopkeeper takes %total_price% coins" - narrate "You are all checked out. have a great day!" - narrate "Do not open your item bag until you are ready to take all the items out" - foreach { - adjust %value% quantity:1 save:item9 - flag server adjust:+: - run script:price_adjuster def: } } } else if == "i@selling_bag" { - flag player delay duration:3s - if == 0 { - narrate "your selling bag is empty!" } else if { - chat "i am sorry but i do not buy back my shopping bags." } else if == server { - chat "ok let's total these items up for you then!" - define total_price 0 - foreach { - adjust %value% quantity:1 save:item - define price ].mul[]||null> - define total_price } - note as:_selling_bag remove - give money qty:%total_price% - take 'i@selling_bag' - narrate "The shopkeeper gives you %total_price% coins" - foreach { - adjust %value% quantity:1 save:item9 - flag server adjust:-: - run script:price_adjuster def: } - queue clear } else { - chat "ok let's total these items up for you then!" - define total_price 0 - foreach { - adjust %value% quantity:! save:item - define price ]>].mul[]> - define total_price } - if %total_price% < { - flag npc buyback:->: - note 'in@player bag' as:_selling_bag - give money qty:%total_price% - flag npc cashregister:-:%total_price% - take 'i@selling_bag' - narrate "The shopkeeper gives you %total_price% coins" - foreach { - adjust %value% quantity:1 save:item9 - flag server adjust:-: - run script:price_adjuster def: } - queue clear } else { - narrate "I am sorry I don't have the funds to buy all of that back!" } } } else if contains 'i@shopping bag' || contains 'i@selling_bag' { - queue clear } else if == { - queue clear } else { - chat "Please visit http://youtu.be/2f3Dk4cPCXs for a short tutorial of how to use our stores." } } itemgiverPlayer Owned: type: task debug: true script: - define name - inventory add o:in@%name%_shopping_bag 'd:in@ _item_bag' - ^adjust 'i@item_bag' "lore: " save:playersbag - give Item Frame Shop Player Owned: type: world debug: true events: on server start: - yaml load:prices.yml id:prices on price command: - if { - adjust quantity:1 save:item3 - if !]||null> { - flag player setpriceserver: - narrate "what is the base price you want for that item?" - determine cancelled } else { - narrate "That item already has a current price of ]||null>" - narrate "To adjust that items price use the /adjust_price command" - determine cancelled } } on adjust_price command: - adjust quantity:1 save:item3 - yaml id:prices set prices.:! - flag player setpriceserver: - narrate "what is the base price you want for that item?" - determine fulfilled on player chats: - if && ! == null { - if { - yaml id:prices set prices.: - yaml savefile:prices.yml id:prices - narrate " price is now set to ]||null>" - flag setpriceserver:! - determine cancelled } else { - narrate "That is not a valid number" - narrate "what is the base price you want for that item?" - determine cancelled } } on stop command: - foreach { - flag %value% playerstoreinventory: } on player teleports: - if '' { - queue clear } else if '' { - inventory add o:in@_shopping_bag d: - take "i@shopping bag" - narrate "No stealing items from my store!!" } on player quits: - if '' { - inventory add o:in@_shopping_bag d: - take "i@shopping bag" - narrate "No stealing items from my store!!" } on store_setup command: - give i@playerstorekeeperegg - determine fulfilled on player clicks with i@playerstorekeeperegg: - if == null { - run "storelocationstick3" as: delay:1t - create player storekeeper - execute as_op "npc select" - narrate "please select the bottom and top corners of your cuboid then drop the selector" - take i@playerstorekeeperegg - lookclose state:true - queue clear } - foreach { - if ]||null> { - narrate "you cannot place your store inside of someone another store" - determine cancelled } } - foreach { - if !]||null> { - run "storelocationstick3" as: delay:1t - create player storekeeper - execute as_op "npc select" - narrate "please select the bottom and top corners of your cuboid then drop the selector" - take i@playerstorekeeperegg - lookclose state:true - queue clear } } on item_frame damaged by entity_explosion: - foreach { - if ]||null> { - determine cancelled } } on item_frame damaged by block_explosion: - foreach { - if ]||null> { - determine cancelled } } on player right clicks with i@storelocationstick4: - if == null { - run "storelocationstick2" def: as: delay:1t - flag player location1: - narrate "Cuboid location 1 selected" - determine cancelled } - foreach { - if ]||null> { - determine cancelled } else { - run "storelocationstick2" def: as: delay:1t - flag player location1: - narrate "Cuboid location 1 selected" - determine cancelled } } on player left clicks with i@storelocationstick4: - if == null { - run "storelocationstick2" def: as: delay:1t - flag player location2: - narrate "Cuboid location 2 selected" - determine cancelled } - foreach { - if ]> { - determine cancelled } else { - flag player location2: - run "storelocationstick2" def: as: delay:1t - narrate "Cuboid location 2 selected" - determine cancelled } } on player drops i@storelocationstick4: - execute as_op "npc owner --id " - assignment set npc: script:StorekeeperPlayerOwned - flag playerstore:cu@| - flag player location1:! - flag player location2:! - flag server storenpcs:->: - run "storeselectorremover2" delay:1t - narrate "tell the npc 'SET' to set the items in the frame" - determine cancelled on player right clicks e@item_frame: - define name - foreach { - if ]||null> { - if == 'shopping bag' { - if >= 18 { - narrate "Your shopping bag is full!" } else if == server { - inventory add o: d:in@_shopping_bag - if != null { - narrate "You add a to your shopping bag." } else { - narrate "You add to your shopping bag." - playsound sound:DIG_GRASS } } else if contains { - inventory add o: d:in@_shopping_bag - take from: - if != null { - narrate "You add a to your shopping bag." } else { - narrate "You add to your shopping bag." - playsound sound:DIG_GRASS } else { - narrate "That item is out of stock!" } } - determine cancelled } } } on player places block: - foreach { - if ]||null> { - if && { - queue clear } else { - determine cancelled } } } on player breaks e@item_frame: - foreach { - if ]||null> { - if && { - queue clear } else { - if != null { - narrate "It's a ." } else { - narrate "It's ." } - narrate "Right click it with your shopping bag to add it to your transaction." - determine cancelled } } } on player breaks block: - foreach { - if ]||null> { - if && { - queue clear } else { - determine cancelled } - if == null { - narrate '[storekeeper] -> You<&co> Hey! You break it, you buy it! Be careful!' - flag storekeeper_warned duration:5s } } } on entity damages e@item_frame: - foreach { - if ]||null> { - if && { - queue clear } else { - foreach { - if ]||null> { - if ]||null> == null { - flag server :1.00 - determine cancelled } else if == server { - define price ].mul[2].mul[]>].as_int||null> - narrate "%price%" - determine cancelled } else { - define price ]||null> - narrate "%price%" - determine cancelled } } } } } } on player right clicks entity with i@shopping bag: - if { - flag player shopkeeper: } on player places item_frame: - foreach { - if ]> { - if && { - queue clear } else { - determine cancelled } } } on player right clicks with i@shopping bag: - define name - define is_shopping false - foreach { - if ]> { - define is_shopping true - foreach stop } } - if ! >= 2 { - take 'i@shopping bag' qty:36 - note 'in@player bag' as:_shopping_bag } - if !%is_shopping% { - inventory clear d:in@_shopping_bag - take 'i@shopping bag' - narrate 'You are not shopping right now!' } else if in@_shopping_bag == null && %is_shopping% { - note 'in@player bag' as:_shopping_bag } else if %is_shopping% { - narrate 'You take a look in your shopping bag...' - inventory open d:in@_shopping_bag } - determine cancelled on player right clicks with i@selling_bag: - define name - define is_shopping false - foreach { - if ]> { - define is_shopping true - foreach stop } } - if !%is_shopping% { - define name - foreach { - drop %value% } - inventory clear d:in@_selling_bag - narrate 'You are not in a shop right now!' - take 'i@selling_bag' - determine cancelled } else if == null && %is_shopping% { - note 'in@player bag' as:_selling_bag - inventory open d:in@_selling_bag - determine cancelled } else if %is_shopping% { - inventory open d:in@_selling_bag - determine cancelled } - determine cancelled on player right clicks with i@item_bag: - foreach { - if ]> && ]> { } else { - narrate 'You take a look in your shopping bag...' - inventory open "d:in@_item_bag" } - determine cancelled } on player drops i@shopping bag: - narrate 'You ditch your shopping bag.' - if ! == server { - inventory add o:in@_shopping_bag 'd:' } - run "bagremovertaskPlayer Owned" delay:1t - determine cancelled on player drops i@selling_bag: - define name - foreach { - drop %value% } - narrate 'You ditch your selling bag.' - run "bagremovertask1Player Owned" delay:1t - note in@_selling_bag remove - determine cancelled on player clicks in inventory: - define name - if == 'in@_shopping_bag' && == 'i@shopping bag' { - determine passively cancelled - inventory update d: } - if == 'in@_shopping_bag' && == 'i@shopping bag' { - if { - determine passively cancelled - inventory update d: } } - if == 'in@_selling_bag' { - if "li@i@shopping bag|i@selling_bag|i@item_bag" contains { - inventory update - determine cancelled } } on player picks up i@shopping bag: - if '' { - determine cancelled } else { - note 'in@player bag' as:_shopping_bag - narrate "You pick up a brand new shopping bag. It's empty!" } on player closes inventory: - if == 'i@item_bag' { - if == { } else { - define item - foreach { - drop %value% } - narrate "your shopping bag ripped" - take iteminhand } } on player picks up i@playerstorekeeperegg: - narrate "To learn how to set up the frame shop please visit https://www.youtube.com/watch?v=FlYEog5-KxU" on player clicks i@playerstorekeeperegg in inventory: - narrate "To learn how to set up the frame shop please visit https://www.youtube.com/watch?v=FlYEog5-KxU" 'player bag': type: inventory size: 18 # It's empty! 'selling bag': type: inventory size: 18 'shopping bag': type: item material: boat display name: shopping bag lore: - Give this to a shopkeeper to check out. - Right click to see the contents. 'item_bag': type: item material: boat display name: item bag lore: - this bag contains the items you bought 'selling_bag': type: item material: boat display name: selling bag lore: - Right click the shopkeeper with this bag to sell the items in it. - Left click the shopkeeper with this bag to see what the - total price of your items will be. storelocationstick4: type: item material: m@iron_hoe display name: store_selector_tool storeselectorremover2: type: task debug: false script: - take i@storelocationstick4 bagremovertaskPlayer Owned: type: task debug: false script: - take 'i@shopping bag' bagremovertask1Player Owned: type: task debug: false script: - take 'i@selling_bag' playerstorekeeperegg: type: item material: m@monster_egg display name: shop_keeper storelocationstick3: type: task debug: false script: - give "i@storelocationstick4" storelocationstick2: type: task script: - showfake m@red_wool %1% to: d:30s