Lights
icon = "blah"
Icon_state = [lights]
world/var/lights = "on"
would that work? for if you change the lights var to on or off it changes all the icon states of that icon in the world
ID:170572
![]() Jan 8 2005, 6:26 am
|
|
Lights would that work? for if you change the lights var to on or off it changes all the icon states of that icon in the world |
Nove, first of all, you really don't need those trailing slashes after everything. Second, the if(lights_on) line kind of nullifies the point of lights_on=!lights_on. However, you can still avoid an if() check by using the ? operator:
obj/Lights Still, there's not really even a reason to have nextstate, and there's also no reason to define it under world anyway: obj/Lights |
Strawgate wrote:
i understand that but how does it work? Basically, the line, lights_on=!lights_on means, in english, "set lights_on to the opposite of its current value". obviously, this statement only makes sense for boolean variables (boolean variables are variables that are always either set to 1 or set to 0; TRUE or FASLE). atom.density, for example, is a boolean variable. |
it doesnt work for turning the lights off how would i make them go off? it says cant read null.luminosity
|
Nope. You have to manually change all of the lights' icon_state. Something like this:
All we do is determine, based on the world var lights_on, what the icon_state of the lights should be, then loop through all the lights in the world and set their icon state. Then we change our variable.