FORUM ARCHIVED

Can a script create an object with an id that can be called by other scripts?

Discussion in 'Modding' started by Bohandas, Jul 26, 2013.

  1. Bohandas

    Bohandas Member

    Can a script create an object with an id that can be called by other scripts?
    For example, should the following room work?


    <room width="11" height="13" name="Repeating Control Point">
    <row text=" ##D## "/>
    <row text="####...####"/>
    <row text="####...#P##"/>
    <row text="#..#......#"/>
    <row text="#2........d"/>
    <row text="#GG.....GG#"/>
    <row text="#GGG#.#GGG#"/>
    <row text="#GGG#1#GGG#"/>
    <row text="#GG.....GG#"/>
    <row text="d........3#"/>
    <row text="#.........#"/>
    <row text="####...####"/>
    <row text="#####D#####"/>
    <flags minLevel="0" maxLevel="3" special="1"/>

    <customblocker id="grate" name="Iron Grate" at="1" png="dungeon/bars_iron_ew.png" can_push="0" description="The iron bars of the grate refuse to let you pass."/>

    <element at="2" type="lever" id="lever0"/>
    <element at="3" type="lever" id="lever1"/>

    <script repeat="-1">
    <condition condition_type="activated_changed" id="lever0"/>
    <condition condition_type="at" id="grate" at="1" />
    <action on="success" action_type="remove" id="grate"/>
    </script>
    <script repeat="-1">
    <condition condition_type="activated_changed" id="lever1"/>
    <condition condition_type="at" id="grate" at="1" />
    <action on="success" action_type="remove" id="grate"/>
    </script>

    <script repeat="-1">
    <condition condition_type="activated_changed" id="lever0"/>
    <condition condition_type="at" id="grate" at="1" not="1"/>
    <action on="success" action_type="create" create_type="customblocker" id="grate" name="Iron Grate" at="1" png="dungeon/bars_iron_ew.png" can_push="0" description="The iron bars of the grate refuse to let you pass." />
    </script>
    <script repeat="-1">
    <condition condition_type="activated_changed" id="lever1"/>
    <condition condition_type="at" id="grate" at="1" not="1"/>
    <action on="success" action_type="create" create_type="customblocker" id="grate" name="Iron Grate" at="1" png="dungeon/bars_iron_ew.png" can_push="0" description="The iron bars of the grate refuse to let you pass." />
    </script>


    </room>
     
  2. lccorp2

    lccorp2 Member

    In short: yes, it should. I've done it before.
     
    Kazeto likes this.
  3. FaxCelestis

    FaxCelestis Will Mod for Digglebucks

    If you're trying to create prison doors--doors that open and close off of a switch--I have working code for that here:

    Code:
    <room width="12" height="12" name="Shallow Dungeon Torture Chamber" >
            <row text="######D#####" />
            <row text="#####...####" />
            <row text="#..#.......#" />
            <row text="#..#....X2X#" />
            <row text="#..........#" />
            <row text="d....X3X...#" />
            <row text="#..........#" />
            <row text="#..45....XX#" />
            <row text="d.......X1.#" />
            <row text="#..........#" />
            <row text="##...#######" />
            <row text="###D########" />
            <flags minLevel="0" maxLevel="0" />
           
            <customblocker name="Prison Bars" x="1" y="3" png="sprites/bars_w_end_0.png" description="Rusty and dented, these prison bars appear at least moderately effective." can_push="0" />
            <customblocker name="Prison Bars" x="2" y="3" png="sprites/bars_e_end_0.png" description="Rusty and dented, these prison bars appear at least moderately effective." id="cell1door" can_push="0" />
     
            <customblocker name="Iron Maiden" at="2" png="sprites/iron_maiden.png" description="Decidedly less awesome than the band of the same name." can_push="0" />
            <customblocker name="The Rack" at="1" png="sprites/rack.png" description="I don't know about you, but I prefer my racks on lamb and women." can_push="0" />
            <customblocker name="Toolbench" at="3" png="sprites/toolbench_0.png" description="There are some chilling implications here, but you'd probably best not investigate them for fear of hyperboric feedback." can_push="0" />   
     
            <element type="evilchest" at="4" />
            <element type="bbq" at="5" />
           
            <monster x="2" y="2" />
           
            <element x="3" y="4" type="lever" id="cell1lever" can_push="0" />
           
            <script repeat="-1">
                <condition condition_type="activated" activated="1" id="cell1lever"/>
                <action on="success" action_type="move" id="cell1door" x="1" y="3" />
            </script>
     
            <script repeat="-1">
                <condition condition_type="activated" activated="0" id="cell1lever"/>
                <action on="success" action_type="move" id="cell1door" x="2" y="3" />
            </script>
           
        </room>
     
    Kazeto likes this.