Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V   1 2 >  
Reply to this topicStart new topic
> [Eventing]Extremely Simple Day/Night, For those who dont want it to be complicated
Nuque
post Oct 19 2008, 11:03 AM
Post #1


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




Okay, are you someone who just wants a watch and for their maps to get darker through the day? Then this is for you.

Steps 1 + 2 are parallel process common events with a switch activation
For steps 1 + 2 create an autorun map event that turns on a switch and then erases itself
For step 3 place the script anywhere, I put it below the default scripts and before main. Just copy and paste

[Show/Hide] Core System
Step 1: Minutes and Hours
CODE

Put in the following commands in a common event: (Dont forget a switch to activate it!!)

@>Control Variables:[0002:Hours] = 10 (When you want day to start. This is also when the screen will become daytime)
@>Loop
@>Wait 1 frame(s)
@>Control Variables: [0003: Seconds] += 1
@>Conditional Branch: [0003: Seconds] = 25
@>Control Variables: [0001: Minutes] += 1
@>Control Variables: [0003: Seconds] = 0
@>Conditional Branch: Variable [0001: Minutes] == 60
@>Control Variable: [0001: Minutes] == 0
@>Control Variable: [0002: Hours] += 1
@>
: Branch End
@>Conditional Branch: Variable [0002: Hours] ==13
@>Condition Branch: [0004: AM/PM] = 1
@>Control Variables: [0002: Hours] = 1
@>Control Variables: [0004: AM/PM] = 2
@>Control Switches: [0001: PM] = OFF
Else
@>Control Variables: [0002: Hours] = 1
@>Control Variables: [0004: AM/PM] = 1
@>Control Switches: [0001: PM] = ON
: Branch End
@>
: Repeat Above
@>





Step 2: Day and Night
CODE


Put in the following in a common event: (Dont forget a switch to activate it!!)

@>Loop
@>Condition Branch: Switch [0001: PM] = ON
@>Conditional Branch Variable [0002: Hours] = 10 < make this number when night starts! (here its 10 pm)
@>Change Screen Color Tone: (-187, -119, -34, 68)
@>Control Switches: [0002: Night] = ON
@>
: Branch End
@>
: Branch End
@>Condition Branch: Switch [0001: PM] = OFF
@>Conditional Branch Variable [0002: Hours] = 6 < make this number when morning starts! (here its 6 am)
@>Change Screen Color Tone: ( 0, 34, 0, 0)
@>Control Switches: [0002: Night] = OFF
@>
: Branch End
@>
: Branch End
@>Condition Branch: Switch [0001: PM] = ON
@>Conditional Branch Variable [0002: Hours] = 10 < make this number when day starts! (here its 10 am)
@>Change Screen Color Tone: ( 0, 0, 0, 0)
@>
: Branch End
@>
: Branch End
@> Wait: 1 frame(s)
@>
: Repeat Above
@>

Cool, aint it?

Test it out, its awesome!!!!
Heres a screenie to look at:



Note that the hud is optional and does not have to be used, instead you can use a watch on the menu screen, an item, or a map event.
This is covered in the next spoiler tag.



[Show/Hide] Watch/Hud
Option A: Watch On Menu Screen

Edit def refresh in Window_PlayTime to look like this:
CODE

def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Time")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = $game_variables[2]
min = $game_variables[1]
text = sprintf("%02d:%02d", hour, min)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end

If it shows 0s, change these lines:
hour = $game_variables[2] Change 2 to your hour variable
min = $game_variables[1] Change 1 to your minute variable


Option B: Hud
CODE

class Window_YourHUD < Window_Base
def initialize
super(0, 416, 640, 64)
self.contents = Bitmap.new(640 - 32, 64 - 32)
refresh
end
def refresh
self.contents.clear
reset_variables
return if !@actor
draw_actor_hp(@actor, 0, 0)
draw_actor_sp(@actor, 160, 0)
self.contents.font.color = system_color
self.contents.draw_text(320, 0, 60, 32, "Time")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = $game_variables[2]
min = $game_variables[1]
text = sprintf("%02d:%02d", hour, min)
self.contents.font.color = normal_color
self.contents.draw_text(400, 0, 60, 32, text, 2)
end
def reset_variables
@actor = $game_party.actors[0]
@old_hp = @actor ? @actor.hp : 0
@old_maxhp = @actor ? @actor.maxhp : 0
@old_sp = @actor ? @actor.sp : 0
@old_maxsp = @actor ? @actor.maxsp : 0
end
def update
super
refresh if (@actor = $game_party.actors[0] or
@old_hp = @actor ? @actor.hp : 0 or
@old_maxhp = @actor ? @actor.maxhp : 0 or
@old_sp = @actor ? @actor.sp : 0 or
@old_maxsp = @actor ? @actor.maxsp : 0)
end
end
class Scene_Map
alias yourhud_main main
alias yourhud_update update
def main
@yourhud = Window_YourHUD.new
yourhud_main
@yourhud.dispose
end
def update
@yourhud.update
yourhud_update
end
end


If there is an error, change the lines
hour = $game_variables[2]
min = $game_variables[1]
to
hour = $game_variables[y] y = your hour variable
min = $game_variables[x] x = your min. variable





Addon 1 : Bed System (Map Event)
CODE

@>Change Screen Color Tone: ( 0, 34, 0, 0)
@>Wait: 20 frame(s)
@>Play ME: '014-Inn01", 100, 100
@>Control Variables: [0002: Hours] = 7 <<This is your time when waking up
@>Control Variables: [0001: Minutes] = 30 << This is your minutes, together its 7:30
@>Control Variables: [0003: Seconds] = 0
@>Control Variables: [0004: AM/PM] = 2
@>Wait: 60 frame(s)
@>Change Screen Color Tone: (0, 0, 0, 0)
@>


Coming Soon:

1. Weather System - just needs to be added (extremely buggy, ill post it, but you have to help me out!)
2. Houses dont get dark until bedtime (9:30?) - to be done
3. Bed System - DONE!
4. Lightning in my weather system (also easily done)

Sorry if im lazy, ill get these done eventually.




!!!!NEW!!!!
Demo Available!!!

This post has been edited by shantanu: Nov 22 2008, 05:04 PM
Attached File(s)
Attached File  DayNight_Demo.zip ( 190.34K ) Number of downloads: 43
 


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
punk13
post Oct 19 2008, 11:19 AM
Post #2


Level 3
Group Icon

Group: Member
Posts: 34
Type: None
RM Skill: Undisclosed




Looks cool 1) in common events do you mean the ones in the database or make an event on the map
2) does the code go under main?

sorry i just got back into rpgmaker after a 2 year rest.
Go to the top of the page
 
+Quote Post
   
Nuque
post Oct 19 2008, 11:34 AM
Post #3


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




here are some answers fer ya

1. An parallel process event in the database. Then make a autorun map event that turns your switch on and then erases itself.

2. The code can go anywhere you want it to go. I have it after all of the default scripts. But it HAS to be AFTER MAIN.

This post has been edited by shantanu: Nov 23 2008, 04:56 PM


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Oct 19 2008, 04:26 PM
Post #4


Level 50
Group Icon

Group: +Gold Member
Posts: 1,521
Type: Scripter
RM Skill: Undisclosed




Edited: Have you tried this while changing maps? I had a go at the whole loop thing using common events and my loops broke sad.gif

I like your scripting though, I have no idea how to script, but I think I could learn alot from using yours smile.gif

This post has been edited by Night_Runner: Oct 21 2008, 08:36 PM


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Rukiri
post Oct 19 2008, 09:03 PM
Post #5


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,722
Type: Scripter
RM Skill: Advanced




Not bad, though this is simple...

Though XD a true day/night can be done by events, scripting is lame since not EVERYTHING needs to be scripted, menu's, movement sure, but battle systems can be evented with the help a few scripts, I prefer evented battles because it's your own and all an abs really is, is just detecting X/Y, now if you play LOG, Som, SD, you'll notice if you hit it at a high point in the sprite it'll move diagonal well that's natural in an abs and all it is, is X/Y detection.

Though for stretching an image... that might require a script"I'd ask for help on that one"

Great system overall, but I'll share my own tomorrow since I'm a bit busy now, also RMXP can be compared to Game Maker if you have pixel-movement added, I actually find XP's scripts to be better than GM, GM for rpg's is just not worth it in a long run.


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
Nuque
post Oct 20 2008, 12:29 PM
Post #6


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




uh, Night_runner, quite frankly, you are completely wrong.

It is a parrallel process meaning that it works along side all other events. You activate the switch once,
and it goes on forever without ever being interrupted by anything. Tho only way that could happen is if you
turn off then turn on the switch in one event (Then it would restart)

Also, im not a scripter, I can only do basic stuff.
Im a developer, writer, spriter, and eventer

This post has been edited by shantanu: Oct 22 2008, 01:50 PM


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Oct 21 2008, 05:56 PM
Post #7


Level 50
Group Icon

Group: +Gold Member
Posts: 1,521
Type: Scripter
RM Skill: Undisclosed




No problems shantanu, but did you actually physically try it?
(Don't you hate it when the only thing someone congratulates you on is the bit you didn't do? Sorry, it just irritates me aswell...)

EDIT: Have it running, wait until like 11 or something, then teleport to another map, and you'll see what I mean (Hopefully)!

This post has been edited by Night_Runner: Oct 21 2008, 09:00 PM


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Libelnon
post Oct 22 2008, 11:51 AM
Post #8


Level 5
Group Icon

Group: Member
Posts: 73
Type: Event Designer
RM Skill: Advanced




Hei - Shantanu - I wrote a tutorial on a event based time system, so have a look at it, the link is in my sig. It may allow you to do things you didn't know you could on time events, and compress that script for you. It's a good concept tho, If I can get it working it may appear in my present 'secret' project, not the one I talk about in my sig. tongue.gif

Edit
Ok, one very big problem here. If this event ran as a paralell process it would slow the game considerably as wait command practically freezes the game. You should instead put in a 'seconds' variable, and that adds 1 every frame (wait then doesn't freeze game as it is only one frame) and then when it gets to 25 (or 60) you add on another minite, also, your screen colour tone is a bit dark, try not to reduce blue much as 'night' black isn't pure - it's more like an incredibly dark purple colour.

This post has been edited by Libelnon: Oct 22 2008, 11:57 AM


__________________________
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

I have returned!... sort of. I probably won't stick around long, but...
Go to the top of the page
 
+Quote Post
   
Nuque
post Oct 22 2008, 01:34 PM
Post #9


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




Libelnon, thank you, I think I will add that in to make the sytem less laggy. Ill add it now!


Night_Runner, you are not right.
I checked it seconds after your first post on this thread just to make sure. Now I am positive of one thing, and that is that it works
I think maybe you copied something wrong?

This post has been edited by shantanu: Oct 22 2008, 01:43 PM


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Oct 22 2008, 02:08 PM
Post #10


Level 50
Group Icon

Group: +Gold Member
Posts: 1,521
Type: Scripter
RM Skill: Undisclosed




Here's a link
Project2.zip

Sorry I'm so much trouble, hopefully someone will be able to resolve this for me sad.gif


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Libelnon
post Oct 23 2008, 11:50 AM
Post #11


Level 5
Group Icon

Group: Member
Posts: 73
Type: Event Designer
RM Skill: Advanced




Heh, just a note - When you use time scripts, I used one that it waits 2 frames then adds 1 seconds, and the game ran at half frame rate - that is the effect of wait commands on the game. Also, you should include a vairiable to decide if it is AM or PM in a 12 hour clock, as then you can take out the need for a long wait in the day script. Then you can say 'If variable AM/PM = 2 (PM) and variable Hours = 6 (nighttime) then activate switch 'night' and change screen colour tone to -20,-20,0,10.'


__________________________
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

I have returned!... sort of. I probably won't stick around long, but...
Go to the top of the page
 
+Quote Post
   
Nuque
post Oct 23 2008, 01:31 PM
Post #12


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




Night_Runner, I checked that out, and there doesnt appear to be anything wrong with your common events. Perhaps the problem is something hard to notice. Try redoing the Day/Night system and trying again. It works perfectly fine in my project, and mine looks exactly like yours...

Libelnon, thanks for that! That even makes the system more customizable. I tested it and works pretty well. I think Ill put it in very
soon! You are turning out to be a real help.


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
hackje
post Oct 24 2008, 02:05 AM
Post #13



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Undisclosed




ho do i add the script i've never used scripts before
Go to the top of the page
 
+Quote Post
   
Libelnon
post Oct 25 2008, 02:41 AM
Post #14


Level 5
Group Icon

Group: Member
Posts: 73
Type: Event Designer
RM Skill: Advanced




do us a favour - PM me when you've fully updated it - I want to put it into my RPG, including the script. Does the script use windowskins? or has it got no background?
Oh, and another thing... You can do Lycanthropy with a script like this. If you set a switch for 'night', you can then remove the bitten player from the party and replace him/her with a werewolf character (Initialize, so that you don't get a lvl 1 lycan every night) and then when it's day again you can remove him from the party and replace him with (an initalized) player character. As for the bite, set up a skill that uses no MP, and call it 'Lycan Bite', and assign it a common event, in that event, you want to activate a switch called 'lycan ON'. You can cure yourself by turning that off, and the common event for day/night should check if that is on - I'll get u a full command list, just don't merge this with the night/day script, plz!


__________________________
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

I have returned!... sort of. I probably won't stick around long, but...
Go to the top of the page
 
+Quote Post
   
Nuque
post Oct 25 2008, 04:29 PM
Post #15


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




Im pmed you, libelnon. I modified the events and now it is fully customizable! I also added a Night switch that is turned on when the screen gets dark.


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Oct 30 2008, 01:54 PM
Post #16


Level 50
Group Icon

Group: +Gold Member
Posts: 1,521
Type: Scripter
RM Skill: Undisclosed




Where did you get that HUD from?
I get the overwhelming feeling that you didn't actually make it, but you didn't credit anyone else for it.....

@ hackje: It's easer to just tell you than to try and find it, lol
1. Highlight everything in that 'And lastly, a HUD' codebox, starting from class Window_...... down to that last end
2. Open the rpg maker xp project you want to put the script into, and that 3rd last icon along the top is the Script Editor (shortcut key F11), open it
3. On the left hand side it says Script >> Game_Temp, etc, scroll that side down to the bottom, and the last item there should be Main
4. Right click Main, and select insert
5. You can name your new new script whatever you like, and just paste the script you coppied into that massive blank section on the right hand side.
If you aren't too confident, download that Project 2 posted above, it has the script, and you can just check off that

EDIT: Actually, here's a more updated version, I edited the script a bit so it works with my sleeping system, that's all
Project1.zip


This post has been edited by Night_Runner: Oct 30 2008, 02:43 PM


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Achilles
post Oct 30 2008, 05:05 PM
Post #17


I can (usually) answer any event based question!
Group Icon

Group: Revolutionary
Posts: 381
Type: Scripter
RM Skill: Masterful




Putting anything besides the time in the HUD was a little unnecessary since most people have their own HUDs they like to use for their character status, so having to go in and delete the hp/sp is a hassle. Good idea about the time though.


__________________________
Go to the top of the page
 
+Quote Post
   
Omegas7
post Oct 30 2008, 05:07 PM
Post #18


Awesome. Epic. Fantastic. Did someone call me?
Group Icon

Group: Revolutionary
Posts: 977
Type: Scripter
RM Skill: Advanced




Nice, but you should move this to the tutorials section laugh.gif.


__________________________
Go to the top of the page
 
+Quote Post
   
Libelnon
post Nov 9 2008, 03:25 AM
Post #19


Level 5
Group Icon

Group: Member
Posts: 73
Type: Event Designer
RM Skill: Advanced




well, maybe when we have perfected this, we should make a tutorial, hmm?

also, shantantu, have a look at my tutorial - it could give you ideas to include in your tutorial.

EDIT:
Spotted a problem: if say... you rested, and it added on 80 seconds, 20 seconds would be shaved off - the conditional branches must be GREATER THAN or equal to, and the time should be minused rather than set.
Also, a 24 hour clock would be easier to understand.


This post has been edited by Libelnon: Nov 9 2008, 06:31 AM


__________________________
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

I have returned!... sort of. I probably won't stick around long, but...
Go to the top of the page
 
+Quote Post
   
Nuque
post Nov 20 2008, 03:26 PM
Post #20


Level 8
Group Icon

Group: Revolutionary
Posts: 118
Type: Developer
RM Skill: Skilled




Bed System is now available!!!
And also...
After a long time I have released my very own Day/Night Demo. Go ahead and check it out!


__________________________
[Show/Hide] Koushaku Productions

Current Koushaku Productions Members:
2
Current Koushaku Productions Projects: 3
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 04:05 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker