Paste #3282: Untitled Paste

Date: 2014/04/08 13:43:00 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"BuyHouse":
    type: assignment

    interact scripts:
    - 10 menu

    default constants:
        h1: 4000
        h2: 3000
        h3: 3000
        h4: 3000
        h5: 3000
        h6: 3000
        h7: 3000
        h8: 3000
        h9: 3000
        h10: 3000
        h11: 3000
        h12: 3000
        h13: 3000
        h14: 3000
        h15: 3000
        h16: 3000
        h17: 3000
        h18: 3000
        h19: 3000
        h20: 3000
        h21: 3000
menu:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - ^run "BuyHouseHeader"
                - ^narrate "<red> <npc.name><&sc> <blue>Buy a house in town?"
                - ^narrate "<blue> You can list all the houses by typing <dark_purple>List 1" 
                - ^narrate "<blue> And to buy a house just type for example <dark_purple>Buy 2"
                - ^narrate ""
                - ^narrate "<gold><&lb>Hint <&co> Buy <&lb>house number<&rb>, List <&lb>page<&rb><&rb>"
                - ^zap step:1
            chat trigger:
                1:
                    trigger: /REGEX:(?i)list\s\d+$/
                    script:
                    - ^run "BuyHouseHeader"
                    - ^narrate "<red> Houses"
                    - ^narrate "<green> <&ns>, Owner, Initial Cost, Daily cost"
                    - ^define lstHouses "<global.flag[HOUSES].as_list>"
                    - ^define page "<context.message.substring[6]>"
                    - ^if <%page%> == 2 {
                        - ^narrate "<blue> 6. <%lstHouses%.get[5]>, <gold>$<npc.constant[h6]><blue>, <gold>$50" 
                        - ^narrate "<blue> 7. <%lstHouses%.get[6]>, <gold>$<npc.constant[h7]><blue>, <gold>$50"
                        - ^narrate "<blue> 8. <%lstHouses%.get[7]>, <gold>$<npc.constant[h8]><blue>, <gold>$50"
                        - ^narrate "<blue> 9. <%lstHouses%.get[8]>, <gold>$<npc.constant[h9]><blue>, <gold>$50"
                        - ^narrate "<blue> 10. <%lstHouses%.get[9]>, <gold>$<npc.constant[h10]><blue>, <gold>$50"
                        }
                        else if <%page%> == 3 {
                        - ^narrate "<blue> 11. <%lstHouses%.get[10]>, <gold>$<npc.constant[h11]><blue>, <gold>$50"
                        - ^narrate "<blue> 12. <%lstHouses%.get[11]>, <gold>$<npc.constant[h12]><blue>, <gold>$50"
                        - ^narrate "<blue> 13. <%lstHouses%.get[12]>, <gold>$<npc.constant[h13]><blue>, <gold>$50"
                        - ^narrate "<blue> 14. <%lstHouses%.get[13]>, <gold>$<npc.constant[h14]><blue>, <gold>$50"
                        - ^narrate "<blue> 15. <%lstHouses%.get[14]>, <gold>$<npc.constant[h15]><blue>, <gold>$50"                   
                        }
                        else if <%page%> == 4 {
                        - ^narrate "<blue> 16. <%lstHouses%.get[15]>, <gold>$<npc.constant[h16]><blue>, <gold>$50" 
                        - ^narrate "<blue> 17. <%lstHouses%.get[16]>, <gold>$<npc.constant[h17]><blue>, <gold>$50"
                        - ^narrate "<blue> 18. <%lstHouses%.get[17]>, <gold>$<npc.constant[h18]><blue>, <gold>$50" 
                        - ^narrate "<blue> 19. <%lstHouses%.get[18]>, <gold>$<npc.constant[h19]><blue>, <gold>$50"
                        - ^narrate "<blue> 20. <%lstHouses%.get[19]>, <gold>$<npc.constant[h20]><blue>, <gold>$50"                      
                        }
                        else if <%page%> == 5 {
                        - ^narrate "<blue> 21. <%lstHouses%.get[20]>, <gold>$<npc.constant[h21]><blue>, <gold>$50"                         
                        }
                        else {
                        - ^narrate "<blue> 1. <%lstHouses%.get[0]>, <gold>$<npc.constant[h1]><blue>, <gold>$50"
                        - ^narrate "<blue> 2. <%lstHouses%.get[1]>, <gold>$<npc.constant[h2]><blue>, <gold>$50"
                        - ^narrate "<blue> 3. <%lstHouses%.get[2]>, <gold>$<npc.constant[h3]><blue>, <gold>$50"
                        - ^narrate "<blue> 4. <%lstHouses%.get[3]>, <gold>$<npc.constant[h4]><blue>, <gold>$50"
                        - ^narrate "<blue> 5. <%lstHouses%.get[4]>, <gold>$<npc.constant[h5]><blue>, <gold>$50"                  
                        }
                    - ^narrate "" 
                    - ^narrate "<Gold><&lb>Hint <&co> Buy <&lb>house number<&rb>, List <&lb>page<&rb><&rb>"
                    - ^narrate ""
                    - ^zap step:1
                2:
                    trigger: /REGEX:(?i)buy\s\d+$/
                    script:
                    - ^run "BuyHouseHeader"
                    - ^define lstHouses "<global.flag[HOUSES].as_list>"
                    - ^define house <context.message.substring[5].as_int.sub[1]>
                    - ^define houseData "<%lstHouses%.get[<%house%>]>"
                    - ^if <%houseData%> == "Available" {
                        - ^flag <player> buyHouse:<%house%>
                        - ^narrate "<red><npc.name>; <blue>This house will cost <gold>$<npc.constant[h<context.message.substring[5].as_int>]><blue> initialy and <gold>$50<blue> per day."
                        - ^narrate ""
                        - ^narrate "<blue>Do you like to buy house <context.message.substring[5]>?"
                        - ^narrate "" 
                        - ^narrate "<gold><&lb>Hint <&co> Yes, No<&rb>"                        
                        - ^zap step:2
                        }
                        else {
                        - ^narrate "<red><npc.name>; <blue>This house belongs to <red><%houseData%><blue>."
                        - ^narrate "<blue>Pick another house or maybe ask the owner if you could buy it."
                        - ^zap step:1
                        }
                3:
                    trigger: /REGEX:\w+/
                    script:
                    - ^run "BuyHouseHeader"
                    - ^narrate "<red> <npc.name>; <blue>Buy a house in town?"
                    - ^narrate "<blue> You can list all the houses by typing <dark_purple>List 1" 
                    - ^narrate "<blue> And to buy a house just type for example <dark_purple>Buy 2"
                    - ^narrate ""
                    - ^narrate "<gold><&lb>Hint <&co> Buy <&lb>house number<&rb>, List <&lb>page<&rb><&rb>"
                    - ^narrate ""
                    - ^zap step:1
        2:
            click trigger:
                script:
                - ^run "BuyHouseHeader"
                - ^narrate "<red> <npc.name>; <blue>Buy a house in town?"
                - ^narrate "<blue> You can list all the houses by typing <dark_purple>List 1" 
                - ^narrate "<blue> And to buy a house just type for example <dark_purple>Buy 2"
                - ^narrate ""
                - ^narrate "<gold><&lb>Hint <&co> Buy <&lb>house number<&rb>, List <&lb>page<&rb><&rb>"
                - ^narrate ""
                - ^zap step:1
            chat trigger:
                1:
                    trigger: "/Yes/"
                    script:
                    - ^run "BuyHouseHeader"
                    - ^if <player.money> > <npc.constant[h<player.flag[buyHouse].as_int.add[1]>]> {
                        - ^narrate "<red><npc.name>; <blue>This house costs <gold>$<npc.constant[h<player.flag[buyHouse].as_int.add[1]>]><blue>. You only have <gold>$<player.money><blue>."
                        - ^narrate "" 
                        - ^narrate ""
                        - ^narrate ""
                        - ^narrate ""
                        - ^narrate ""
                        - ^zap step:1
                        }
                        else {
                        - define lstHouses <global.flag[HOUSES].as_list>
                        - define loop_index 0
                        - flag global HOUSES:!
                        - foreach %lstHouses% {
                            - ^narrate "<%loop_index%> <el@value[%loop_index%]>"
                            - define loop_index <def[%loop_index%].as_int.add[1]>
                            }
                        - ^take money qty:<npc.constant[h<player.flag[buyHouse].as_int.add[1]>]>
                        - ^narrate "<Red><npc.name>; <Blue> Congratulations! You are now the owner of house <player.flag[buyHouse]>"
                        - ^narrate "" 
                        - ^narrate ""
                        - ^narrate ""
                        - ^narrate ""
                        - ^narrate ""
                        - ^zap step:1
                        }
                2:
                    trigger: /REGEX:\w+/
                    script:
                    - ^run "BuyHouseHeader"
                    - ^narrate "<red> <npc.name>; <blue>Buy a house in town?"
                    - ^narrate "<blue> You can list all the houses by typing <dark_purple>List 1" 
                    - ^narrate "<blue> And to buy a house just type for example <dark_purple>Buy 2"
                    - ^narrate ""
                    - ^narrate "<gold><&lb>Hint <&co> Buy <&lb>house number<&rb>, List <&lb>page<&rb><&rb>"
                    - ^narrate ""
                    - ^zap step:1
"BuyHouseHeader":
    type: task
    script:
    - ^narrate ""
    - ^narrate "<green>----------------------<red> Buy House <green>---------------------"
    - ^narrate ""