Color Guide:
Red indicates a command (or commands) you enter into the MUCK.
Navy indicates text returned by the MUCK, usually a result of a command you typed.
MUF: ChargeIt, A Device Charging Program
by Silver of A Bug's Muck
Would you like to build something that needs to be charged or loaded before it can be used? ChargeIt is a very simple program that makes this easy to do.
Say you want to build a balloon-weapon with an action called 'lob' that hurls a water balloon at a target, and an action called 'load' that loads the weapon with a water balloon. You don't want 'lob' to work if the weapon isn't loaded. You could write some MPI to do this, but it's a bit messy and won't prevent the teleporting functions of linked actions. There's another solution involving locks and MUF that is not only easier, but the same program can be used for any object with charge-dependent actions.
ChargeIt works by locking the actions to the program and testing the lock against a property on the parent object that is set if the object is charged, and cleared if the object is not charged. ChargeIt is easy to use. In the water balloon weapon example, you would create two actions, 'load' and 'lob' on the balloon launcher. Load will be the charging action, and lob will be a charge-dependent action.
First, create the actions and lock them to the ChargeIt program. In A Bug's Muck, you can use the dbref #3712, though I can't guarantee that it will always exist.
@lock load=#3712
@lock lob=#3712
Make sure you change 'load' and 'lob' to your action names or dbrefs. Next you'll need to set a special property "_charger:YES" on the action you want to be the charger, so that ChargeIt recognizes it. In this example, 'load' is the charging action.
@set load=_charger:YES
Now all you have to do is set the message properties like you would on any action. Make sure you set the fail messages for these actions though. For the charging action, the action will fail if the object is already charged, so you will need appropriate fail and ofail messages. For the charge-dependent actions, the action will fail if the object isn't charged, so you'll need fail and ofail messages for these cases. Here are examples for the balloon launcher:
@set load=_/sc:You load a water balloon into the weapon.
@set load=_/osc:loads a water balloon into the weapon.
@set load=_/fl:The balloon weapon is already loaded.
@set load=_/ofl:tries to load a second water balloon in the weapon but fails.
@set lob=_/sc:You launch the water balloon!
@set lob=_/osc:launches a water balloon from the weapon!
@set lob=_/fl:*click* You need to load a water balloon first.
@set lob=_/ofl:tries to fire the water balloon weapon, but nothing happens.
ChargeIt can be used for any number of actions on the same device, and can be used for any number of devices. Have fun!