bryman1970 Posted January 17, 2011 Share Posted January 17, 2011 I'm making a mod in which i'd like to give the player the option on turning the lights on and off. I've found an old script library collection on PES, but the script tells how to turn multiple colored lights on and off, not a single one. I'm not that good at scripting myself to know how to break it down for use with a single light. I've already made a light switch, but I just need scripts to attach to the switch and the light(s). Anyone care to write me one? Link to comment Share on other sites More sharing options...
Tchos Posted January 17, 2011 Share Posted January 17, 2011 Let's see the script. Maybe I can remove the unnecessary code. Link to comment Share on other sites More sharing options...
bryman1970 Posted January 17, 2011 Author Share Posted January 17, 2011 (edited) Ok. These scripts were the ones I found on the 'Script Library'. I'm not sure if the last one is needed in this situation, but I included it anyway just in case: Light Switch: The lightswitch script – attach this to your switch object. Rz_light is a global variable (Short). CODEBegin Rz_lights short MessageOnshort button if( MenuMode == 1) Returnendif if( OnActivate == 1) Set MessageOn to 2endif if( MessageOn == 2) MessageBox "Which light would you like on?" "Normal" "Green" "Blue" "Red" "Off";asks which lights to turn on Set MessageOn to 1endif if( MessageOn == 0) Returnendif if( MessageOn == 1) set button to GetButtonPressed if( button == 0) Set MessageOn to 0 Set Rz_light to 1 Return endif if( button == 1) Set MessageOn to 0 Set Rz_light to 2 Return endif if( button == 2) Set MessageOn to 0 Set Rz_light to 3 Return endif if( button == 3) Set MessageOn to 0 Set Rz_light to 4 Return endif if( button == 4) Set MessageOn to 0 Set Rz_light to 5 Return endifendif End Rz_lights This next script is what you place on the individual lights. This is for the “normal” lighting. Copy this and place it on your other coloured lights – you will just need to change the enable/disable to their corresponding variable value. I'll list it for you. Norm, enable if( Rz_light == 1)Green, enable if( Rz_light == 2)Blue, enable if( Rz_light == 3)Red, enable if( Rz_light == 4)All lights, disable if ( Rz_light == 5) CODEBegin Rz_lights_norm if( MenuMode == 1) Returnendif if( Rz_light == 0) Disableendif if( Rz_light == 1) Enableendif if( Rz_light == 2) Disableendif if( Rz_light == 3) Disableendif if( Rz_light == 4) Disableendif if( Rz_light == 5) Disableendif End Rz_lights_norm Reset Activator: Now heres a script you should place on another invisible activator in the room to reset the global variable when you leave the cell so you can use the script over and over. CODEbegin var_reset01 if ( MenuMode == 1 )returnendif if ( CellChanged == 1 )set var01 to 0;the name of your global variableendif end Edited January 17, 2011 by bryman1970 Link to comment Share on other sites More sharing options...
Tchos Posted January 17, 2011 Share Posted January 17, 2011 Okay, I edited it down, and this might work. Not sure about it since I didn't try it out myself. There is one thing missing from the instructions, though. It says there should be a global variable Rz_light, but it doesn't give you instructions on where to define that. There's a menu item for that in the construction set, IIRC. Also, you need to click on the properties of that light and make it a persistent reference. I think you could dispense with the global variable approach if you just give the light a name and reference it in the code, but try it this way anyway. For testing purposes, you don't need to worry about the last code block, but in your final mod you should probably add it. The lightswitch script – attach this to your switch object. Rz_light is a global variable (Short). Begin Rz_lights short LightIsOn if( MenuMode == 1) Return endif if( OnActivate == 0) Return endif if( OnActivate == 1) if( LightIsOn == 0) Set Rz_light to 1 Return endif if( LightIsOn == 1) Set Rz_light to 0 Return endif endif End Rz_lightsThis next script is what you place on the individual lights.Enable if( Rz_light == 1)Disable if ( Rz_light == 0)Begin Rz_lights_norm if( MenuMode == 1) Return endif if( Rz_light == 0) Disable endif if( Rz_light == 1) Enable endif End Rz_lights_normReset Activator:Now heres a script you should place on another invisible activator in the room to reset the global variable when you leave the cell so you can use the script over and over.begin var_reset01 if ( MenuMode == 1 ) return endif if ( CellChanged == 1 ) set Rz_light to 0 endif end Link to comment Share on other sites More sharing options...
bryman1970 Posted January 18, 2011 Author Share Posted January 18, 2011 (edited) Ok. I'll definitely give those a try. I need to retexture some vanilla lights so they'd look a bit fancier. But first, I need to find out what texture are used for the candles and the flames. Thanks for your help. Edit: Ok. I've retextured my new lights. I added the new Short Global and changed all the references in the top two scripts to match my Global name. I checked 'References Persist' on the lights. There are a total of four of them, and will be turned on and off with the same switch. I didn't check 'References Persist' on the switch. I'm not sure if i'm supposed to or not. I left the third script out for now until this is working. I tested all of this in-game. When I went inside, I saw that the lights weren't there, even though they were there in the construction set. Now that I think of it, I didn't name the lights. The only way I can give the lights a name is if I check the 'Can carry' option, but then i'd need an Icon, and i'm not sure where to find one. Since these are mounted lights, would the player actually be able to carry them? Also, if I do that, would I need to check 'Off by default' as well? Edit: I went ahead and checked the 'Can carry' option anyway but not the 'Off by default' option, seeing as it was the only way to actually name the lights. 'References Persist' is still checked off on the lights, but not the switch. The lights are still not there. I'm pretty clueless at this stuff, so I can't really be much help. Edited January 18, 2011 by bryman1970 Link to comment Share on other sites More sharing options...
Recommended Posts