Paste #5934: Domestic Script

Date: 2014/06/28 18:56:04 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


DomesticHouseAssign:
    type: assignment

    actions:
        on assignment:
        - trigger name:click state:true
        - trigger name:chat state:true
    interact scripts:
    - 10 HouseSellScript



HouseSellScript:
    type: interact
    steps:
        1:
         click trigger:
            Script:
            - chat "<yellow>Welcome to the Domestic Center! I am <npc.name>, one of the current realestate agents."
            - chat "<yellow>Would you like to <gray>purchase<yellow> a plot?"

         chat trigger:
             'Purchase':
               trigger: I would like to /purchase/ a plot.
               script:
               - engage
               - if <player.has_flag[owner]> {
                 - chat "<yellow>Sorry, you can only own one plot at a time! You can <gray>sell<yellow> your plot if you would like a new one."
                 - chat "<yellow>If my records are accurate, your current plot is <gold><player.flag[owner]><yellow>." }
                 else {
                 - chat "<yellow>Excellent! Could you please give me the address?"
                 - narrate "<gold>For a list of available addresses, type <gray>available<yellow>."
                 - disengage
                 }
             'Address':
               trigger: I'm interested in /regex:.+/
               script:
               - if <npc.constant[<player.chat_history>]||null> != null {
                 - chat "<yellow>Ok! Let me check if that address is available..."
                 - flag player addresswant:<player.chat_history> duration:60
                 - wait 2 
                 - if <npc.has_flag[<player.flag[addresswant]>]> chat "<yellow>Sorry, someone already owns this plot!"
                   else {
                   - chat "<yellow>This plot will cost you <red><npc.constant[<player.flag[addresswant]>]><yellow>. Are you sure you <gray>want<yellow> it?" 
                   - zap 2 
                   - wait 10
                   - zap 1 
                   }
                 }
                 else chat "<yellow>Sorry, it appears that address does not exist." 


        2:
         chat trigger:
            'Final_Purchase':
               trigger: Yes, I /want/ it please.
               script:
               - engage 
               - if <player.money> >= <npc.constant[<player.flag[addresswant]>]> run "SellPlotTask"
                 else {
                   - chat "<yellow>Oops! It appears you don't have enough money. You have <gold><player.money><yellow> but you need <red><npc.constant[<player.flag[addresswant]>]><yellow>."
                   - chat "<yellow>Come back when you have some more cash."
                   - disengage
                   - zap 1 }
               - disengage


SellPlotTask:
    type: task
    script:
    - engage
    - take money qty:<npc.constant[<player.flag[addresswant]>]>
    - chat "<yellow>Alright! Everything appears to be in order. You must be excited! Let me just wrap up some paperwork..."
    - execute as_server "region addowner <player.flag[addresswant]> <player.name> -w neighborhoods"
    - execute as_server "dom adminowns <player.flag[addresswant]> <player.name>"
    - flag npc <player.flag[addresswant]>
    - flag player owner:<player.flag[addresswant]>
    - wait 2
    - chat "<yellow>That's it! The house is yours. Here is an owner's manual for your convience. Have a nice day!"
    - give HomeOwnersManual
    - disengage

HomeOwnersManual:
    type: book
    title: The Home Owner's Manual
    author: The Domestic Center
    text:
    - =Your Address= <p><player.flag[addresswant]>
    - Welcome to the Home Owner's Manual! This manual will walk you through becoming a successful Home Owner.
    - =Your Address= <p>The address of your plot is: <player.flag[addresswant]>
    - =Domestic Management= <p>The base domestic command is /domestic, or /d. All modification commands require you to 1. Enter your address, and 2. Be standing in your plot."
    - =Selling your Home= <p>Selling your home is easy! You can sell your home in one of two ways. <n>You can either sell it back to the Domestic Center, or you can sell it to another player using /d sell [address] [player]. 
    - If you sell your home to the Domestic Center, it will be put up for remodeling, and you will receive three quarters of what you payed for it. <n>If you sell your home to another player, then both players are expected to work out the price, and the home is sold as-is.
    - =Inviting Friends to your Home= <p>To invite friends to build things in your home, use /d invite [address] [player]. 
    - =Home Settings= <p>There are several settings you can modify in your home. <n>Type /d help to take a look!
    - Enjoy your new home! <p>~ Sincerely, <n>The Domestic Center