» Sat Mar 20, 2010 3:40 am
Its three parts: the generator, the switch and the terminal/lights.
The generator has a script that displays a menu message to either leave the thing alone or add some fuel. The option to add fuel has a condition that the player actually have the right amount needed to start it up, so it only displays when the player has enough fuel on him. Once the player adds fuel, a variable called "Task" in the generator script is set to 1. The switch next to the generator uses Task == 1 in an OnActivate block. If Task = 1, the script fires and disables the "Off" terminal on the desk. The "Off" terminal is set as the enable parent of the "On" terminal which is placed in the exact same spot as the "Off" terminal and its the enable parent of the light as well. Both the "On" terminal and the lights are set so that the enable state is opposite of the parent. Disabling the "Off" terminal then has the visual effect of turning on the terminal and the lights. To make it use fuel, you would have to add a timer section to the generator script that every time period, say 2 minutes, it uses up one fuel. You would define a variable that stores the amount of fuel, and every time the timer runs out, subtract 1 from the amount of fuel variable and reset the timer. Once the fuel variable reaches zero, enable the "Off" terminal to turn off the terminal and lights and reset the Task variable to 0 to start the process all over again. You might also want to add some options to the menu message to add various amounts of fuel based on the player's inventory. Mine only requires 5 Flamer fuel, but you could add options for more, thus allowing the lights and stuff to stay on longer.