Module SwitchableItems { ' Switchable items object library, written by ' R.Rawson-Tetley. Version 011028 ' This library contains code for: ' On/Off Switches ' Toggle Switches ' Toggle Levers ' Up/Down Levers ' Modifications: ' ' 011104 Multiplayer bits added. ' 011028 Initial version ' To use on/off switches: ' 1. Set userboolean "ison" if you want the item switched on by default. ' 2. Make a call to SwitchableItems.switchhandler in your ' onaction code for the item. ' To use toggle switches: ' 1. Set userboolean "ison" if you want the item switched on by default. ' 2. Make a call to SwitchableItems.toggleswitchhandler in your ' onaction code for the item. ' To use toggle levers: ' 1. Set userboolean "ison" if you want the lever activated by default. ' 2. Make a call to SwitchableItems.toggleleverhandler in your ' onaction code for the item. ' To use up/down levers: ' 1. Set userboolean "isdown" if you want the lever down (I always assume ' that down is on). ' 2. Make a call to SwitchableItems.leverhandler in your ' onaction code for the item. proc switchhandler itemno ;switch,turn if ( item(itemno).getuserboolean(ison) = true ) then #on currentplayer.print The^_&_item(itemno).thename_&_^is^already^on. end endif #off currentplayer.print You^switch^off^the^_&_item(itemno).thename_&_. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^off^the^_&_item(itemno).thename_&_. item(itemno).removeuserboolean(ison) end endif else #on currentplayer.print You^switch^on^the^_&_item(itemno).thename_&_. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^on^the^_&_item(itemno).thename_&_. item(itemno).adduserboolean(ison) end endif #off currentplayer.print The^_&_item(itemno).thename_&_^is^already^off. end endif endif endif ;examine if ( item(itemno).getuserboolean(ison) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^on. else currentplayer.print The^_&_item(itemno).thename_&_^is^off. endif endif end proc toggleswitchhandler itemno ;switch,turn,press,push if ( input.adverb = 0 ) then currentplayer.print (Which^setting^do^you^want^to^set^the^_&_item(itemno).thename_&_^to^-^on^or^off?) end endif if ( item(itemno).getuserboolean(ison) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^now^off. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^off^the^_&_item(itemno).thename_&_. item(itemno).removeuserboolean(ison) end else currentplayer.print The^_&_item(itemno).thename_&_^is^now^on. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^on^the^_&_item(itemno).thename_&_. item(itemno).adduserboolean(ison) end endif endif ;examine if ( item(itemno).getuserboolean(ison) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^on. else currentplayer.print The^_&_item(itemno).thename_&_^is^off. endif endif end proc toggleleverhandler itemno ;switch,turn,press,push,pull if ( item(itemno).getuserboolean(ison) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^now^off. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^off^the^_&_item(itemno).thename_&_. item(itemno).removeuserboolean(ison) end else currentplayer.print The^_&_item(itemno).thename_&_^is^now^on. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^switches^on^the^_&_item(itemno).thename_&_. item(itemno).adduserboolean(ison) end endif endif ;examine if ( item(itemno).getuserboolean(ison) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^on. else currentplayer.print The^_&_item(itemno).thename_&_^is^off. endif endif end proc leverhandler itemno ;pull,push,move if ( input.adverb = 0 ) then currentplayer.print (Which^direction^do^you^want^to^set^the^_&_item(itemno).thename_&_^to^-^up^or^down?) end endif if ( item(itemno).getuserboolean(isdown) = true ) then #up currentplayer.print The^_&_item(itemno).thename_&_^is^already^up. end endif #down currentplayer.print You^move^the^_&_item(itemno).thename_&_^into^the^down^position. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^sets^the^_&_item(itemno).thename_&_^to^the^down^position. item(itemno).adduserboolean(isdown) end endif else #up currentplayer.print You^move^the^_&_item(itemno).thename_&_^into^the^up^position. printallinexcept currentplayer.currentlocation currentplayer.index currentplayer.name_&_^sets^the^_&_item(itemno).thename_&_^to^the^up^position. item(itemno).removeuserboolean(isdown) end endif #down currentplayer.print The^_&_item(itemno).thename_&_^is^already^down. end endif endif endif ;examine if ( item(itemno).getuserboolean(isdown) = true ) then currentplayer.print The^_&_item(itemno).thename_&_^is^in^the^down^position. else currentplayer.print The^_&_item(itemno).thename_&_^is^in^the^up^position. endif endif end }