Storekeeper: type: assignment debug: true default constants: 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 store:<-: on assignment: - trigger name:proximity toggle:true radius:3 - trigger name:click toggle:true - trigger name:chat toggle:true - trigger name:damage toggle:true on enter proximity: - foreach { - if ! { - adjust %value% framed:]>]> } } - if ! && ]> { - narrate "].as_list.random>" - flag player greeted } on exit proximity: - flag player greeted:! on damage: - if '!' && '!' && '!' { - animate arm_swing - narrate 'Here, have a complimentary shopping bag!' - note 'in@player bag' as:_shopping_bag - give 'i@shopping bag' } else if == 'i@shopping bag' { - define total_price 0 - define name - foreach { - adjust %value% quantity:1 save:item2 - if ]> == null { - flag server :1.00 } - adjust %value% quantity:1 save:item - define price ].mul[2].mul[]>].mul[]> - 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' { - define total_price 0 - define name - foreach { - adjust %value% quantity:1 save:item2 - define price ].mul[].as_int> - define total_price } - narrate "Ready to sell items? Just right click me with your bag!" - narrate "your total price is %total_price%" } on chat: - if == sell { - animate arm_swing - narrate 'Here is your item selling bag!' - note 'in@selling bag1' as:_selling_bag - give 'i@selling bag' - if == set && == { - narrate "<&b>your store is now open for business!" - flag npc storeitems:! - foreach { - if == item_frame { - flag npc storeitems:->: - flag npc storeitemlocations:->: } } - determine cancelled } on click: - if == "i@shopping bag" { - define name - if == 0 { - narrate "your shopping bag is empty!" } 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:item - if ]> == null { - flag server %value%:1.00 } - define price ].mul[2].mul[]>].mul[].as_int> - 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 itemgiver 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:item - flag server adjust:+: - run script:price_adjuster def: } } } else if == "i@selling bag" { - flag player delay duration:3s - define name - if == 0 { - narrate "your selling bag is empty!" } else if { - chat "i am sorry but i do not buy back my shopping bags." } else { - chat "ok let's total these items up for you then!" - define total_price 0 - foreach { - adjust %value% quantity:1 save:item1 - define price ].mul[].as_int> - define total_price } - inventory clear d:in@_selling_bag - give money qty:%total_price% - take 'i@selling bag' - narrate "The shopkeeper gives you %total_price% coins" - foreach { - adjust %value% quantity:1 save:item - flag server adjust:-: - run script:price_adjuster def: } - queue clear } } else if !'' && !'' { - chat "Please visit http://youtu.be/2f3Dk4cPCXs for a short tutorial of how to use our stores." } itemgiver: type: task debug: false script: - inventory add o:in@_shopping_bag 'd:in@ _item_bag' - ^adjust 'i@item_bag' "lore: " save:playersbag - give Item Frame Shop: type: world debug: true constants: permission_for_prices: events: on price command: - if { - adjust quantity:1 save:item3 - if !]> { - flag player setpriceserver: - narrate "what is the base price you want for that item?" } else { - narrate "That item already has a current price of ]>" - 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 matches double { - yaml id:prices set prices.: - yaml savefile:prices.yml id:prices - narrate "<.display> price is now set to ]>" - flag setpriceserver:! - determine cancelled } else { - narrate "That is not a valid number" } } on store_setup command: - give i@storekeeperegg - determine fulfilled on player clicks with i@storekeeperegg: - run storelocationstick1 player: delay:1t - create player storekeeper save:mynpc - execute as_op "npc select " - narrate "<&d>please select the bottom and top corners of your cuboid then drop the selector" - take i@storekeeperegg - lookclose state:true on item_frame damaged by entity_explosion: - foreach { - if ]> { - determine cancelled } } on item_frame damaged by block_explosion: - foreach { - if ]> { - determine cancelled } } on player right clicks with storelocationstick: - run storelocationstick2 def: player: delay:1t - flag player location1: - narrate "Cuboid location 1 selected" on player left clicks with storelocationstick: - flag player location2: - run storelocationstick2 def: player: delay:1t - narrate "Cuboid location 2 selected" - determine cancelled on player drops storelocationstick: - execute as_op "npc owner --id " - assignment set npc: script:s@Storekeeper - flag global store:->:cu@| - flag store:cu@| - flag player location1:! - flag player location2:! - run s@storeselectorremover player: delay:1t - narrate "tell the npc 'SET' to set the items in the frame" - determine cancelled on player right clicks e@item_frame: - foreach { - if ]> { - if && queue clear - if == 'shopping bag' { - define name - if >= 18 { - narrate "Your shopping bag is full!" } else if ]> == null { - foreach { - if !']>' == null { - narrate " has no price! please set a price for this item by holding it in your hand ant typing /price" target:%value% } else if !]> { - flag server pricemessage:->: } } - narrate "this item has no price. please contact the servers administrators to let them know" - determine cancelled } else { - 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 } } } - determine cancelled } } on player places block: - foreach { - if ]> { - if && { - queue clear } else { - determine cancelled } } } on player breaks e@item_frame: - foreach { - if ]> { - 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 ]> { - 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 ]> { - if && { - queue clear } else { - foreach { - if ]> { - if ]> == null { - flag server :1.00 - determine cancelled } else if ]> == null { - foreach { - if !']>' == null { - narrate " has no price! please set a price for this item by holding it in your hand ant typing /price" target:%value% } else if !]> { - flag server pricemessage:->: } } - narrate "this item has no price. please contact the servers administrators to let them know" - determine cancelled } else { - define price ].mul[2].mul[]>].as_int> - 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 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 } else 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 == null && %is_shopping% { - note 'in@player bag' as:_shopping_bag } else %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 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 in@_shopping_bag||null == null && %is_shopping% { - note 'in@selling bag1' as:_selling_bag - inventory open d:in@_selling_bag - determine cancelled } else %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.' - run bagremovertask delay:1t - determine cancelled on player drops i@selling bag: - narrate 'You ditch your selling bag.' - run bagremovertask1 delay:1t - determine cancelled on player clicks in inventory: - 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' { - define lore - if == { } else { - foreach { - drop %value% } - narrate "your shopping bag ripped" - take iteminhand } on server start: - yaml load:prices.yml id:prices on player joins: - wait 5s - if ']>' { - foreach { - narrate "%value% has no price! please set a price for this item by holding it in your hand and typing /price" - flag server pricemessage:<-:%value% } } 'player bag': type: inventory size: 18 # It's empty! 'item bag': type: inventory size: 18 # It's empty! 'selling bag1': type: inventory size: 18 # It's empty! '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. price_adjuster: type: task debug: false script: - if == 100 { - flag server %1%:+:0.01 - flag server %1%adjust:1 } - if == 0 { - flag server %1%:-:0.01 - flag server %1%adjust:1 } storelocationstick: type: item material: m@iron_hoe display name: store_selector_tool storeselectorremover: type: task debug: false script: - take i@storelocationstick bagremovertask: type: task debug: false script: - take 'i@shopping bag' bagremovertask1: type: task debug: false script: - take 'i@selling bag' storekeeperegg: type: item material: m@monster_egg display name: shop_keeper storelocationstick1: type: task debug: false script: - give "i@storelocationstick" storelocationstick2: type: task script: - showfake m@red_wool %1% to: d:30s