ID:2290241
 
Code:
var/global
list/holder=list("Time"=new/obj/Time)
list/OnlinePlayers=list()

proc
GrabHolder(wh as text)//grabs something out of the holder associated list by name.
if(holder.Find(wh))
return holder[wh]
else
return null



mob/player//the default mob, whatever you may call it.
Login()//applied on login. can be changed for elsewhere.
..()
OnlinePlayers+=src
var/obj/Time/T=GrabHolder("Time")
if(!isnull(T))
T.Apply(src)
Logout()//removed on logout.
var/obj/Time/T=GrabHolder("Time")
if(!isnull(T))
src.client.screen-=T
src.client.screen-=T.Weather
..()//continue deletion

obj/Time//this is the time object
New()//upon creation initialize the weather object and set it's properties.
if(isnull(Weather))//should be null at start
Weather=new
Weather.screen_loc="SOUTHWEST to NORTHEAST"
Weather.icon='Art/Weather/Weather.dmi'
Weather.icon_state="storm"
Weather.layer=MOB_LAYER+6//configures the weather properly.
spawn(25)DayCycle()
..()
layer=MOB_LAYER+5
icon_state="still"
mouse_opacity=0
alpha=50
icon='Art/Weather/DayNNite.dmi'
screen_loc="SOUTHWEST to NORTHEAST"
var
rev=0
cTOD="morning"//time of the day
cWEA="calm"//the current weather
season="Summer"//the current season
weather_counter=1//weather counter, responsible for changing weather.
list/TOD=list("morning","midmorning","noon",
"afternoon","dusk","sunset","nightfall","night")//time of day goes here, should match the name of your icon states.
chg_wait=300//5 mins per change.
obj/Weather//this is the object that holds the visual elements for weather.
proc
Apply(mob/m)//this applies the weather and day to the client's screen. call this once
if(!isnull(m.client))
m.client.screen+=src
m.client.screen+=src.Weather
InWea()//this is a weather proc that increases the chance of weather change.
switch(cWEA)
if("calm")//calm lasts longest with the least amount of weather change
weather_counter++
if("snow")
weather_counter+=5
if("rain")
weather_counter+=5
if("storm")
weather_counter+=10
if("severestorm")
weather_counter+=25//storms are severe, so they have a chance at passing quickly.
if("blizzard")
weather_counter+=25
if("windy")
weather_counter+=3
if(prob(weather_counter))//if the weather has changed by chance..
switch(season)
if("Spring")//then pick the appropriate weather as per the icon file
cWEA=pick("calm","rain")
if("Summer")
cWEA=pick("calm","rain","storm","severestorm")
if("Fall")
cWEA=pick("calm","windy")
if("Winter")
cWEA=pick("calm","snow","blizzard")
Weather.icon_state=cWEA
weather_counter=1

DayColor(wh)//simply changes the color of the day based on the time of the day.
switch(wh)
if("midmorning")
return rgb(255,255,204,46)
if("morning")
return rgb(255,255,204,46)
if("noon")
return rgb(255,255,204,0)
if("afternoon")
return rgb(255,255,204,0)
if("sunset")
return rgb(255,153,0,60)
if("nightfall")
return rgb(0,0,102,102)
if("night")
return rgb(0,0,102,160)
if("dusk")
return rgb(0,153,153,46)//you can play with these for various effects.

DayCycle()//this is the day cycle proc. It runs and controls daytime changes and
if(!rev)//weather changes.
rev=1//recursive looped so that this runs smoothly in the background at all times
var/r=TOD.Find(cTOD)//with little to no CPU cost on the host server.
if(r==TOD.len)r=1
else
r=min(TOD.len,r+1)
animate(src,color=DayColor(TOD[r]),time=round(chg_wait/3))
cTOD=TOD[r]
InWea()//call weather changes.
spawn(chg_wait)
rev=0
.()


Problem description:Trying to set screen_loc to 1,1,2 to 500,500,2 to lock it to a specific map. As the code stands above, it applies rain, even when inside buildings.

I tried setting it to the specific coordinates my map has, but and it compiles, but in-game it says that the z2's aren't good.

I am new by the way, don't roast me xD


You can't use screen_loc to put something on a specific Z level.
Then is there something that I can learn to use, or isn't there such a thing?
In response to Seijinz
What I'd do is put an object in the map-editor, on said Z level, and make it transform() to your map_x and map_y values on New().
I would have no clue how to do that, I can make objects and all that, I just wouldn't know how to:

transform() Also cant find anything on google searching that, so I have no references.

Would that exclude any other z levels though?
Transform isn't a proc, it's a variable. Why are you Googling? In DreamMaker, press F1 to open the DM Reference. Search for "matrix" and "transform."
Could you show an example of using transform in this case, dont have to. I just learn that way, and I dont understand how to go about using an obj to start that code.

Thanks for helping me out so far, ill keep reading the F1 and try harder as well.
transform var (atom)
See also: vars (atom) matrix
An atom can be made to appear rotated, scaled, and/or translated (moved) by using affine transforms. This takes a matrix and multiplies the x and y positions of the icon's corners like so:
a d 0
x y 1 * b e 0 = x' y' 1
c f 1

This is equivalent to:
x' = a*x + b*y + c
y' = d*x + e*y + f

You do not need to understand matrix math to use transforms, because you can use the matrix datum to do this for you.

Transformations are relative to the center of the icon. They do not apply to maptext.

Examples:

// Rotate the atom by 45° clockwise
src.transform = turn(src.transform, 45)

// OR
var/matrix/M = matrix()
M.Turn(45)
src.transform = M

// Scale the atom by 2x2
src.transform *= 2

// OR
var/matrix/M = matrix()
M.Scale(2,2)
src.transform = M


Whenever you read the atom.transform var, you will get a copy of the atom's current transformation. Whenever you assign a value to the var, you will update the transformation.

Assigning null to atom.transform will revert the atom to using no transformation at all. It is also legal to assign a list with six values, which is equivalent to using a matrix.


Edit: Alternatively
Problem description:Trying to set screen_loc to 1,1,2 to 500,500,2 to lock it to a specific map. As the code stands above, it applies rain, even when inside buildings.

screen objects live in the screen. Not on the map. You can't permanently add an object to the screen and only show it over a specific map. You will need to keep track of the user's lifecycle in such a way that you can trap when they enter and exit parts of your map.
So I would create a new object, which I'd like to call Weathermaker, then under New() in the piece of code, or under the object itself, I should use transform, to set x,y,z values, to myself the player?

Or would I need to create an obj, which runs the code from above, but transform the X,y,Z values, to apply to the mob/player for example?

I trying my hardest, haha, it's very hard for me to understand all these new things I am needing to use a simple library code from the website.
Kumorii has a weather effects library here that is pretty plug-and-play friendly. :)
In response to Seijinz
Seijinz wrote:
So I would create a new object, which I'd like to call Weathermaker, then under New() in the piece of code, or under the object itself, I should use transform, to set x,y,z values, to myself the player?

Or would I need to create an obj, which runs the code from above, but transform the X,y,Z values, to apply to the mob/player for example?

I trying my hardest, haha, it's very hard for me to understand all these new things I am needing to use a simple library code from the website.

Objects in the screen don't have map locations.