Paste #16441: custom objects sample v0.15 subject to change

Date: 2015/06/12 19:27:31 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


my_custom_object:
    type: custom
    tags:
        food_amount:
        - determine "<this.eleven> of <this.taco>"
    mechanisms:
        add_food:
        - if <context.value> == "potato" {
          - adjust <this> eleven:<this.eleven.add[1]> save:new_obj
          - determine <entry[new_obj].result>
          }
          else {
          - determine <this>
          }
    eleven: 11
    taco: potato

my_advanced_object:
    type: custom
    inherit: my_custom_object
    twelve: Negative Three

test_comand:
    type: command
    name: test_custom
    script:
    - define temp <new[my_advanced_object]>
    - narrate <def[temp]>
    # Narrated: "custom@my_advanced_object[eleven=11;taco=potato;twelve=Negative&spThree]"
    - adjust <def[temp]> eleven:12 save:new_obj
    - narrate <entry[new_obj].result>
    # Narrated: "custom@my_advanced_object[eleven=12;taco=potato;twelve=Negative&spThree]"
    - adjust <entry[new_obj].result> add_food:potato save:new_obj2
    - narrate <entry[new_obj2].result>
    # Narrated: "custom@my_advanced_object[eleven=13.0;taco=potato;twelve=Negative&spThree]"
    - narrate <entry[new_obj2].result.eleven>
    # Narrated: "13.0"
    - narrate <entry[new_obj2].result.food_amount>
    # Narrated: "13.0 of potato"
    - narrate <entry[new_obj2].result.twelve>
    # Narrated: "Negative Three"