ID:176186
 
proc Night() for(var/turf/T in world)//for all turfs if(T.icon_state == "night")//if its night turf T.icon_state = ""//make them day else//if its day T.icon_state = "night"//make the icons night for(var/obj/O in world)//for all obj if(O.icon_state == "night")//if its a night icon O.icon_state = ""//make them day else//if its day O.icon_state = "night"//make the icons night for(var/area/A in world)//for all area if(A.icon_state == "night")//if its a night icon A.icon_state = ""//make them day else//if its day A.icon_state = "night"//make the icons night for(var/mob/M in world)//for all mobs if(!M.client)//if its an npc if(M.night==1)//if its night M.night = 0//make it day else//otherwise M.night = 1//its night spawn(1200)//20 min Night()//again world New()// at the creation of the world ..() spawn(1) Night()//calls the night proc

Ok this is my night proc. I have one problem though. My game is uses a menu, and withing the dmi file for it there are tons of icons states icluding letters numbers and the menu backround itself. I figure if i made a night version so instead of menu.dmi i could make one nightmenu.dmi. Is there anyway that wthin this proc wherever it says 'menu.dmi' at night its replaced with 'nightmenu.dmi'. I was thinking defining a macro for each but im not to sure about going and doing that, any help?
<code> proc/Night() while(1) sleep(1200) for(var/atom/A in world)//for all turfs if(ismob(A)) if(A.night) A.night=0 else A.night=1 else if(A.icon='menu.dmi') A.icon='nightmenu.dmi' else if(A.icon='nightmenu.dmi') A.icon='menu.dmi' else if(A.icon_state == "night") A.icon_state = ""//make them day else A.icon_state="night"//make the icons night world/New()// at the creation of the world ..() spawn(1) Night()//calls the night proc </code>

This should work, but I havn't tested it.
-=Ken=-
In response to NeoHaxor
proc
Night()
for(var/turf/T in world)//for all turfs
if(T.icon_state == "night")//if its night turf
T.icon_state = ""//make them day
else//if its day
T.icon_state = "night"//make the icons night
for(var/obj/O in world)//for all obj
if(istype(/obj/back))
if(O.icon == 'back.dmi')
O.icon = 'nback.dmi'
if(O.icon == 'nback.dmi')
O.icon = 'back.dmi'
else if(istype(/obj/text))
if(O.icon == 'text.dmi')
O.icon = 'ntext.dmi'
if(O.icon == 'ntext.dmi')
O.icon = 'text.dmi'
else
if(O.icon_state == "night")//if its a night icon
O.icon_state = ""//make them day
else//if its day
O.icon_state = "night"//make the icons night
for(var/area/A in world)//for all area
if(A.icon_state == "night")//if its a night icon
A.icon_state = ""//make them day
else//if its day
A.icon_state = "night"//make the icons night
for(var/mob/M in world)//for all mobs
if(!M.client)//if its an npc
if(M.night==1)//if its night
M.night = 0//make it day
else//otherwise
M.night = 1//its night

spawn(1200)//20 min
Night()//again


world
New()// at the creation of the world
..()
spawn(1)// call it after a few seconds
Night()//calls the night proc
obj
back
icon='back.dmi'
layer=MOB_LAYER+4
New(client/C)C.screen+=src
text
icon='text.dmi'
layer=MOB_LAYER+5
New(client/C)C.screen+=src


when i test this these i get

Smart NPC.dm:111:error:/obj/back:unknown variable type
Smart NPC.dm:116:error:/obj/text:unknown variable type

how would i make it so it only does this icon change to these obj only?
In response to Erdrickthegreat2
Erdrickthegreat2 wrote:
>           if(istype(/obj/back))
>

Smart NPC.dm:111:error:/obj/back:unknown variable type
Smart NPC.dm:116:error:/obj/text:unknown variable type

how would i make it so it only does this icon change to these obj only?

istype() reqiures another arguement. In your case;
istype(O,/obj/back)


~>Volte
In response to Volte
proc
Night()
for(var/turf/T in world)//for all turfs
if(T.icon_state == "night")//if its night turf
T.icon_state = ""//make them day
else//if its day
T.icon_state = "night"//make the icons night
for(var/obj/O in world)//for all obj
if(istype(O,/obj/back))
if(O.icon == 'back.dmi')
O.icon = 'nback.dmi'
if(O.icon == 'nback.dmi')
O.icon = 'back.dmi'
else if(istype(O,/obj/text))
if(O.icon == 'text.dmi')
O.icon = 'ntext.dmi'
if(O.icon == 'ntext.dmi')
O.icon = 'text.dmi'
else
if(O.icon_state == "night")//if its a night icon
O.icon_state = ""//make them day
else//if its day
O.icon_state = "night"//make the icons night
for(var/area/A in world)//for all area
if(A.icon_state == "night")//if its a night icon
A.icon_state = ""//make them day
else//if its day
A.icon_state = "night"//make the icons night
for(var/mob/M in world)//for all mobs
if(!M.client)//if its an npc
if(M.night==1)//if its night
M.night = 0//make it day
else//otherwise
M.night = 1//its night

spawn(1200)//20 min
Night()//again
world
New()// at the creation of the world
..()
spawn(1)// call it after a few seconds
Night()//calls the night proc


obj
back
icon='back.dmi'
layer=MOB_LAYER+4
New(client/C)C.screen+=src
text
icon='text.dmi'
layer=MOB_LAYER+5
New(client/C)C.screen+=src

whats wrong with this, for some reason the color doesnt change.... its kinda annoying since theres no errors i dont see the problem in the code

perhaps im not changing the icon correctly, any help please?
In response to Erdrickthegreat2
Well I notice you didn't do anything that I did, I was trying to help but I appreciate the rejection :-(.

-=Ken=-
In response to NeoHaxor
sorry =) thats because it didnt work for what i needed it for
In response to Erdrickthegreat2
Now, why doesnt this work?


obj/text
icon = 'text.dmi'
if(dark == 1)
icon = 'ntext.dmi'
else
icon = 'text.dmi'
// heres where the other stuff goes

obj/back
icon = 'back.dmi'
if(dark == 1)
icon = 'nback.dmi'
else
icon = 'back.dmi'
// heres where the other stuff goes

proc
night
// Ok so in here is where the regular night proc is
for(var/obj/O as obj in world)
if(O.dark == 0)
O.dark = 1
else
O.dark = 0

obj/var
dark

any idea of where the problem is, i think the changing icon is the problem...
i thought maybe #define Back 'back.dmi'
#define NBack 'nback.dmi'
#define Text 'text.dmi'
#define NText 'ntext.dmi'
then setting if(dark == 1)
Back = NBack and Text = NText

or something along those lines... Im not to familiar with Macro work..


In response to Erdrickthegreat2
Erdrickthegreat2 wrote:
Now, why doesnt this work?


obj/text
icon = 'text.dmi'
if(dark == 1)
icon = 'ntext.dmi'
else
icon = 'text.dmi'
// heres where the other stuff goes

obj/back
icon = 'back.dmi'
if(dark == 1)
icon = 'nback.dmi'
else
icon = 'back.dmi'
// heres where the other stuff goes
Only use if()s inside a proc... DM doesn't know when to call those ifs... place them in a proc. New() is called when the object is created:

obj/New()
..()
if(bahhah == 2)
world << "Duh!"

-<font color="#33ff33">Nova</font>
In response to Nova2000
......wha? dude i understand i can't put the if()in the obj but how would i be able to change the icon of those 2 specific obj when i change the value of their variable?(note: this variable is called for all obj, but i just want this variable to affect these 2 certain obj's) I want the icons to change for these obj because they have icon_states that i need for my menu's but for my night proc i want my chatting to change color, so i need to use a totally new icon for them.. hence wanting to change the icon from 'back.dmi' to 'Nback.dmi'and 'text.dmi' to 'Ntext.dmi'
In response to Erdrickthegreat2
You call a proc when you want it to change.
In response to Garthor
so like for this as an example?

obj/back
icon = 'back.dmi'
src.icon_change()

proc/icon_change()
//icon changing
//yep
//how would i change the icon for obj baack from here?


I'm real confused when i probably shouldnt be =)
In response to Erdrickthegreat2
No. I thnk you are somewhat confused. You cannot put if()'s outside of a proc. You cannot put proc calls outside of a proc (thus the New() proc, which is called upon creation of the object). What you want is to simply change the back's icon whenever you need it to change, either by calling a proc for all clients ( for(var/client/C in world) ) and adjusting the objects in their screen, or by some other method.
In response to Garthor
so
obj/New()
..()
for(var/obj/O as obj in world)
if(O.night == 1)
if(O.icon == 'back.dmi')
O.icon = 'nback.dmi'
O.night = 0
else
//same but switch icons


is that something that could work?