## Weather - Night/Day Cycle [Solved/USABLE STEPS AT BOTTOM]

Hello! I already have an idea how to do these two categories, but I wanted to double check to make sure they were the best way (or even correct). My idea was making both of these turnscripts. ((Keep in mind these aren't necessarily the final scripts/codes)). For example...
Weather

``````if (RandomChance(25)) {
game.sunweather=True
game.rainweather=False
game.stormweather=False
game.cloudyweather=False
game.suncount = game.suncount - 1
if (game.suncount = 5) {
msg ("")
}
}
if (game.suncount = 1) {
msg ("")
}
else if (RandomChance(25)) {
game.sunweather=False
game.rainweather=True
game.stormweather=False
game.cloudyweather=False
game.suncount = game.suncount - 1
if (game.raincount = 5) {
msg ("")
}
}
if (game.raincount = 1) {
msg ("")
}
else if (RandomChance(25)) {
etc
}
else {
etc
}
``````

And
Night/Day Cycle

``````if (game.day = True) {
game.daycount = game.daycount - 1
game.midday =False
game.night= False
if (game.daycount = 1) {
msg ("")
game.day = False
game.midday =True
}
}
if (game.midday= True ) {
game.middaycount = game.middaycount - 1
game.night= False
if (game.middaycount = 1) {
msg ("")
game.day = False
game.midday =True
}
}
etc
``````

I figured turnscripts would be the best way to go about these. What do you guys think?

Anonynn.

There's not too many options, as you do have to check in order to determine what/when to do or not do what you want, or you just base it on actual/clock time (Timers), so for checking, either: you use the internal turns (via Turnscripts) which does constant checking (even if you got an 'if' control for the Turnscript's scripting, you're doing that 'if' check, even if you're not doing all of the other scripting, though just doing a single 'if' Script checking is better than doing the entire rest of the scripting and/or its possible additional checks, but you're constantly doing at least one type of checking constantly with Turnscripts no matter what) or more controlled/limited checking via being based off of an Attribute (often being increased/descreased: a 'counter' Attribute, or any Attribute based on it changing Values) which you can do via many designs, through the 'changed' Script Attribute, Turnscripts, and maybe etc means, but really the only main means are: Timers, Turnscripts, and the 'changed' Script Attribute.

Yeah, I think the best way is a turn-script. Changed attributes wouldn't be enough because of all the variables and I definitely don't want to do a Timer because I don't want to force the reader to read quickly. I used to have a timer for something else which was 190 seconds and I still couldn't get through some of the reading in time (I was trying different speeds) ^_^

Thanks a lot for the feedback, HK. The real script will probably end up being less complicated than what I stated above. But I guess we'll see!

the design could be better (if care look at Pixie's libraries, on time/date/whatever, his/her 'clock/whatever' Library --- I don't know if it has climate/weather/daytime-nighttime/seasons/etc as part of it but that can be added in), but it can always be better, even for professional coders too, but especially for us noobs, all that matters is if you can get it to work or not. After you get more experience, you can go back and create/craft a better/more-efficient and/or more organized and/or scalable design, but don't be like me and be stuck on a single design/system, constantly trying to make it better, laughs. You'll never make any progress on your game, like me if you stress over perfection of design, esepcially as coding noobs... it's just a huge success for us if we can just get it to work... lol. I'm still working on 'character creation' laughs, trying to completely revamp my design from using Functions to using Objects, and I've just learned from Jay, that this might not actually be better to use Objects vs Functions, argh... laughs.

(Though, I do need to learn using Objects / Object Oriented Design / Data Structures, as I've struggled with it as school class -- had to drop out, so it's something I need to learn better/more, even if for this endeaver with my quest game it might be inferior to my already working design using Functions)

Turn scripts is one way to do it, but some turns will take longer than others, and you really want to reflect that. Possibly do it when the player moves to another room, and have that as a quarter of an hour, but build in the capacity to have some exits longer or shorter?

I would store the weather as a string, rather than a set of booleans.

``````game.weather = "sunny"
``````

It will be a lot less code, and if you later decide you want a rain of frogs or green mist, they can be added much more easily. Similarly, track the number of minutes passed as an integer, and have a single boolean that is true during the day and false at night.

Put both weather and day/night in the samne turnscrpt, as both are tracking time.

using room travel/change (either via 'changedparent' for the Player Object/s or the 'game' Game Object's global 'onenterroom / whatever it is called' Script or you can use a Turnscript too, but it's probably worse than the other two methods) is another good way for most things, as Pixie already covered, as well as any other global Scripts that the 'game' Object might have... I really need to learn more of the GUI/Editor and the built-in stuff, sighs.

and that's about it, for options. These were the last remaining ones that I hadn't covered in my prior post/s.

though if you want effects (weather/climate/nighttime/daytime/etc) to occur (also) while within a room ("time" is passing even while within a room and not just when you move from room to room)... then you got to do more or something else, as using the changing of rooms isn't of any help for having stuf happene while within a room.

lol... weather/climate/nighttime/daytime within a room... haha

well.. the room can be a 'forest'... but ya, if it's an interior room... that was funny... it's raining and lightning flashes... raining and lightning flashes inside my house!

but, you may want to have other (non-exterior/environmental/climate, lol) effects which do make sense of being able to happen while within a (an interior) room.

I thought about it more last night. I don't exactly want to add a full clock Pix but here's an alternative I thought might be useful for people. I'll post the full code here later when I get it all sorted out.

Here's what I came up with. I figured the weather could be a turn-script and the night/day cycle could be attached to exits as a StringList, so anytime the player goes through an exit, it changes the time of day (to represent travel and I can customize which rooms have it), then I could make "inside and outside" could be Booleans. Here's the idea below.

Weather TurnCount
game.clear
game.cloud
game.rain
game.storm

Night/Day StringList
game.morning
game.midday
game.evening
game.night
game.latenight

InsideOut Boolean
game.inside
game.outside

What do you guys think of this? As I mentioned, I'll end up posting the full code later in case this can help other people as well, then they can use it in their games :)

looks good, if interested, here's some of my own game design ideas as I've thought up as I've worked on some of this stuff in past (stopped due to difficulty with months/years/leap year/etc, the more I read the more math complex it was getting for it's actual accurate workings, laughs):

hours: dawn/sunrise (6 am), morning (6 am - 12 am/pm), noon/midday (12 am/pm), afternoon (12 am/pm - 6 pm), dusk/sunset (6 pm), evening (6-9 pm), twilight (9 pm - 12 pm/am), midnight (12 pm/am), twilight (12 pm/am - 6 am)

weather/climate/environment: rain/drizzle/shower/sprinkle/downpour/etc, mist, fog, cloudy, sunny, lightning/thunder, blizzard, tornado, monsoon, tsunami/tidal wave, flood/flashflood, drought, hail, sleet, snow, hurricane/typhoon, storm/tempest, ice, gale/wind, wildfire/forestfire/fire/smoke, volcano eruption/ash, desert mirage, tides, earthquakes, landslide/mudslide, moon phases, eclipse, planetary alignment, meteor/comet/shooting star/etc, vortex/water vortex,

seasons: winter....autumn/fall

months: january....december

days: sunday....saturday

interior/exterior

am/pm

daytime/nighttime

horoscope/zodiac/constellations/chinese calender/etc

civilian time (0-11, hour % 12)/military time (0-23, hour % 24)

fauna (animals) / flora (plants)

biomes/geography: forest, jungle, desert, tundra, coast, grassland, plains, floodplains/delta, marsh, marshland, woodland, swamp, swampland, oasis, beach, bog, badlands, wastelands, rainforest, hills, mountains, volcano, crater, cove, steppes, mesa, valley, cave, tunnel, cliff, isle, island, atoll, caldera, savannah, shore, bay, sea, continent, ocean, river, waterfall, lake, stream, meadow, glacier,

subterranean-underground/surface-ground/sky-heavens/space-outerspace

shipwreck/ruins/graveyard/lair/den/etc

Wow! That's incredibly complicated, HK! I definitely don't want to go into that much detail xD ! I can see why you had to stop though. I think just the right amount of complexity should help keep the player's attention and pull them into the world. Plus, if you leave it kinda simple as well, it saves you from getting pigeon-held or trapped.

In my opinion, if something is TOO complicated, I think it would pull the player out of the story because they are trying to figure everything out and how it works (which might be harder for some people to do), but if it's simple yet complex then it enriches the world you're creating. If that makes sense xD!

Speaking of which, how's your game coming along? :D Have you started it yet?

Anonynn.

I'm still working on just the 'character creation' part of it (and brainstorming more game design too), but schools started again, so I'm busy now, sighs.

I did something similar in my eternal work in progress, X3, except I cycle bats at random for different times of the day/night cycle. Jay pretty much overhauled my initial attempts and got it to work. I was nuts and decided I wanted descriptions for changing times of day and bat cycles both when the player is indoors and outdoors and that the description carry over accurately when moving from indoors to outdoors. Never would have managed it without Jay's help.

In a nutshell, here is what I would do:

1. Create a global turn script that adds one to an integer attribute on some object in the game.
2. At every 'nth' interval, set a changed attribute script (and you can make it random) to one of the weather descriptors that you want. I used 15 turns equal one change of day from dawn, morning, noon, afternoon, dusk, evening, midnight. At that change of day, the player would get a message and it would usher in a slew of game wide results - amount of light changing, number of bats seen/heard, different vendors come and go in the market area, etc.
3. On the 'nth + 1' integer count, reset the integer to 1 again. Fifteen moves later you will get another random chance weather change.
4. The bitch is, come to find out, that you probably will want to change the descriptions for the weather for your rooms. The easiest way to do this is to create an Inherited Attribute that adds weather descriptions for rooms with certain values, like (inside, nearwater, treesaround, openfield, etc...) and will spit out a descriptions that is suitable. The other option is to add a bunch of room descriptions that check to see 'IF' it is [insert weather description here] and add a comment to that particular room. I guess it depends on how specific you want to be.

As I re-read your initial post, it kind of sounds like this is what you were going for already, so...

Good luck! =P

Okay! Here are the steps to implement: Weather and TOD scripting.

Weather

clear Boolean False
cloud Boolean False
rain Boolean False
storm Boolean False

clearcount Integer Set to 201.
cloudcount Integer Set to 201.
stormcount Integer Set to 201.

3. Create Global Turnscript. ((I have designed the "Weather System" to be completely randomized. As far as Rain goes, it will have a 50% chance to proc at the beginning of "Cloudy Weather" but if it doesn't happen, I have designed it to have a 30% chance to proc at cloudcount 100. If it is already raining at cloudcount 100 then it'll have a 30% chance to stop raining. The Storm Weather can be written in room descriptions to be Rain or Snow, depending on location with; if (game.storm=True:} This code can be used for the other weather procs too, for example: if (game.clear=False: Text here} or if (game.cloud=True: Text here} ))

4. Add this line of code to a room.object's scripting, probably in a "After Leaving the Room" or "After Entering the Room" script tabs.

``````EnableTurnScript (weather)
``````
1. Make sure this script is NOT activated until you want it to be activated. If you want the script activated at the beginning of your game, you do not need the code above.

If you have any questions about it; just let me know.

``````if (game.clear=True) {
game.clearcount = game.clearcount - 1
if (game.clearcount = 200) {
msg ("<br/><font color=\"dedede\">The weather is clearing up!</font color><br/>")
}
if (game.clearcount = 1) {
game.clear = False
game.clearcount = 201
if (RandomChance(50)) {
game.clear = True
}
else if (RandomChance(25)) {
if (RandomChance(50)) {
game.cloud = True
}
else {
game.cloud = True
game.rain = True
}
}
else {
game.storm = True
}
}
}
if (game.cloud=True) {
game.cloudcount = game.cloudcount - 1
if (game.cloudcount = 200) {
msg ("<br/><font color=\"dedede\">It's getting pretty cloudy out!</font color><br/>")
if (RandomChance(30)) {
game.rain = True
msg ("<br/><font color=\"dedede\">And it's beginning to rain!</font color><br/>")
}
}
if (game.cloudcount = 100) {
if (game.rain = False) {
if (RandomChance(30)) {
game.rain = True
msg ("<br/><font color=\"dedede\">Uh-oh! It's beginning to rain!</font color><br/>")
}
}
else {
if (RandomChance(30)) {
game.rain = False
msg ("<br/><font color=\"dedede\">Seems like the rain has stopped.</font color><br/>")
}
}
}
if (game.cloudcount = 1) {
game.cloud = False
game.cloudcount = 201
if (game.rain=True) {
game.rain = False
}
if (RandomChance(50)) {
game.clear = True
}
else if (RandomChance(25)) {
if (RandomChance(50)) {
game.cloud = True
}
else {
game.cloud = True
game.rain = True
}
}
else {
game.storm = True
}
}
}
if (game.storm=True) {
game.stormcount = game.stormcount - 1
if (game.stormcount = 200) {
msg ("<br/><font color=\"dedede\">A swarm of dark clouds is moving into the air. It's beginning to storm!</font color><br/>")
}
if (game.stormcount = 1) {
game.storm = False
game.stormcount = 201
if (RandomChance(50)) {
game.clear = True
}
else if (RandomChance(25)) {
if (RandomChance(50)) {
game.cloud = True
}
else {
game.cloud = True
game.rain = True
}
}
else {
game.storm = True
}
}
}
``````

Day/Night Cycle

ndcycle String List.

2. Game.Object, Attributes. Click ndcycle, Click Add ChangeScript.
changedndcycle Integer, 0

3. Add this script to whatever room.object(s) you want the ndcycle to affect. For the first one, I suggest adding it to a previous room's "After Leaving the Room" script which can be found on the room.object, script tab. This code below will randomize the starting ndcycle but if you don't want it randomized, remove the code below and simply put...game.ndcycle = 0 which will set the individual attribute.

0 "morning"
1 "midday"
2 "evening"
3 "night"

``````if (RandomChance(25)) {
game.ndcycle = 0
}
else if (RandomChance(25)) {
game.ndcycle = 1
}
else if (RandomChance(25)) {
game.ndcycle = 2
}
else {
game.ndcycle = 3
}
``````
1. When you want the day/night cycle to advance simply put...
``````game.ndcycle = game.ndcycle + 1
if (game.ndcycle>3) {
game.ndcycle = 0
}
``````

Then you can use it in room descriptions with {if game.ndcycle=0:It was early morning}

TO USE THESE TOGETHER TRY:
{if game.ndcycle=0: It was early morning{if game.clear=True: and the sky was clear}.}

Let me know if you guys have any questions :)

This topic is now closed. Topics are closed after 60 days of inactivity.

Quest
Squiffy
ActiveLit

Documentation
Blog
GitHub

Forums