How To: Using levers and switches to activate other objects

Discussion in 'XmlSpawner Development' started by Chris, Jun 17, 2014.

  1. Chris

    Chris Renaissance Staff
    Renaissance Staff

    Joined:
    May 14, 2012
    Messages:
    3,385
    Likes Received:
    6,196
    Levers and Switches

    The script SimpleSwitches.cs included in the xmlspawner2 package adds three items

    SimpleLever - a 2or3-state lever
    SimpleSwitch - a 2 state switch with different facings determined by direction
    CombinationLock - a multiple digit lock.

    These can be placed by using the [add command like

    [add simplelever

    When the lever or switch are placed into a particular position (states) by double clicking them, they can be configured to set properties on target items such as doors (locked/unlocked), or even to do things like add items to containers, or activate spawners.
    The states have the values 0,1, and 2 (for the 3 state lever). Each of these states has a pair of TargetItem and TargetProperties associate with it, like

    Target0Item and Target0Property for state 0
    Target1Item and Target1Property for state 1
    Target2Item and Target2Property for state 2 (3 state lever only)

    By setting the TargetItem and TargetProperty properties, you allow the switch/lever states to set properties on the target item according the corresponding TargetProperty string.

    So, for example to use a switch to unlock a door when the switch is in the 1 state, set Target1Item to the door and then set Target1Property to

    /locked/false

    to open the door set it to

    /open/true

    to lock and close it when the switch is in the 0 state, set Target0Item to the door and then set Target0Property to

    /locked/true/open/false

    (note, it uses the same syntax as the xmlspawner2 property specification strings. Since it shares the same syntax, you can also have it do things like change the color of an item, or add items to a container using the ADD/<spec> string.)

    Activating the switches and levers is subject to range, line-of-sight restrictions (have to be within 2 tiles and be able to see it to use it).

    Original Document by ArteGordon - Modified for use on UO:Renaissance
    Original Article - http://xmlspawner.fr.yuku.com/topic/90#.U6BsfpTiKy4
  2. Chris

    Chris Renaissance Staff
    Renaissance Staff

    Joined:
    May 14, 2012
    Messages:
    3,385
    Likes Received:
    6,196
    Timed Levers and Switches

    The TimedSwitch, TimedLever, and TimedSwitchableItem items are similar to the SimpleSwitch and Simple lever, but the TimedSwitch, TimedLever items add a reset timer to the switch/lever states with MinDelay and MaxDelay properties.

    The item TimedSwitchableItem is a TimedSwitch that allows you to specify the Item statics that will be assigned to each state, allowing flexible user-defined visuals during switching, such as a torch or a stone, or a wall section, etc.

    Because it is a TimedSwitch you can assign actions that are associated with each state as well, such as opening a door when double-clicking a torch, or opening a secret passage when double-clicking on a wall section, etc.

    The current switching state of all of these items is contained in the State property, and the ResetState is the value that the State will be returned to after the reset timer expires.

    The amount of time remaining until the switch or lever resets can be seen or changed in the TimeUntilReset property.

    The Combination lock

    SimpleCombinationLock simulates a multi-digit (max 8) combination lock. The state of each of the digits can be set using (for example) the lever or switch items. The combination is set in the Combination property. So the combination of 378, would correspond to digits 2,1,0 taking on values of 3,7, and 8 respectively.
    The Match property can be tested to determine when the target combination is matched by the combination of digits.

    Note that digit number corresponds to significance, from least to most.

    Each digit is a property (Digit0, Digit1, Digit2, ... Digit7) and can take on the values 0-9. You can set the property string to indicate either a property name on the target item (e.g. switchstate, or leverstate, or totalgold), or you can specify a test such as totalgold<100, or open=false, or locked=true.
    You could use this item to look for certain combinations of switches or levers, door states, etc. or even combinations of levers, and weight of a container, or number of kills on a spawn etc., and then open a door, or add items to a container, or change the color of a stone, trigger a spawn, etc.

    Original Document by ArteGordon - Modified for use on UO:Renaissance
    Original Article - http://xmlspawner.fr.yuku.com/topic/90#.U6BsfpTiKy4
  3. Xavier WER

    Xavier WER Member

    Joined:
    Mar 13, 2015
    Messages:
    29
    Likes Received:
    33
    Theres also an attachment you can use, I think it's called XMLuse which you can attach to any object or mobile to perform actions on doubleclick.
    Could be usefull if you want to have for example a corpse that players need to open etc...

    Or attach it to a door to make it explode if players aren't carrying a specific item. Lots of fun applications

Share This Page