tommyfun
|
  |
| Joined: 04 Jan 2011 |
| Total Posts: 1404 |
|
|
| 28 Mar 2014 03:25 PM |
Ok, I'm sew to scripting, so if someone could point me in the direction of a wiki article or just explain how to do this, I would appreciate it.
Ok, I want to make a map that changes depending on the time of year the game chooses. So, say it's winter. The game would tell all the water to turn to ice, all the ground to have snow on it (this would be a bit of a challenge, and may cause lag I think) and so forth. If the game chose summer, all the water would stay thawed, grass everywhere, increased thirst, ect.
How would I do this? |
|
|
| Report Abuse |
|
|
tommyfun
|
  |
| Joined: 04 Jan 2011 |
| Total Posts: 1404 |
|
| |
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 28 Mar 2014 03:36 PM |
Well, then you have to be able to check the time in a year (which month is it?) Now there is a function called tick(). It tells you how many seconds passed since 1 January 1970. You could use this to calculate which month of the year it is. I guess that would work like this:
print(math.floor(((tick()/3600/24/365)%1)*12))
This will print the number of the month I guess...
I hope this works
~sycips~ |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2014 03:59 PM |
| Do you want the seasons to correspond with actual seasons in real life? Because those can vary (i.e. Australia having a winter whilst the US has summer) |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 28 Mar 2014 04:03 PM |
1 Player servers ^
Could he make |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2014 04:06 PM |
| Yes, 1 Player servers are nice and all, but I'm asking him the question, not asking if it's possible. I'd find it preferable to use local parts. |
|
|
| Report Abuse |
|
|
tommyfun
|
  |
| Joined: 04 Jan 2011 |
| Total Posts: 1404 |
|
|
| 28 Mar 2014 04:28 PM |
| No, I don't want the seasons to occur at the same time as in real life. I want the game to randomly pick a month and the map will load with that month as the time of year. |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 28 Mar 2014 04:31 PM |
well, then you would make a table, no?
seasons = {"winter", "spring", "summer", "fall" }
if one of those is selected then you can make your stuff
|
|
|
| Report Abuse |
|
|
|
| 28 Mar 2014 05:03 PM |
You can take this plenty of ways, which I'm sure would take a modest amount of work. I'm sure the easiest, most friendly of doing this would be something like this:
Seasons = { Current = {}, ChangeTo = function(self, index) if self.Current.seasonModel then self.Current.seasonModel:Destroy() end
local mainModel = Instance.new("Model") --create model where all seasonal parts will go self[index](mainModel) --add season parts self.Current = {seasonName = index, seasonModel = mainModel} --update current season status mainModel.Name = index.." Scenery" mainModel.Parent = workspace --make it appear
print("Changed to "..index.." season!") end, Summer = function(mainModel) --make summer parts, parent them to mainModel end, Winter = function(mainModel) --make winter parts end, Spring = function(mainModel) --make spring parts end, Autumn = function(mainModel) --make fall parts end, }
while true do Seasons:ChangeTo("Spring") wait(60*5) --60 * number of minutes Seasons:ChangeTo("Summer") wait(60*5) Seasons:ChangeTo("Autumn") wait(60*5) Seasons:ChangeTo("Winter") wait(60*5) end
Hope I didn't go too overboard. All you have to do is change where I noted to make the parts for each season. The parts in each section will all appear when the season is reached, as well as a message in the output telling that the season changed. The old season's parts will also disappear. It's possible to add seasons by just setting one up in the table like all of the others are; for example: CustomSeason = function(mainModel) --make customseason parts end
Simple as that. |
|
|
| Report Abuse |
|
|