File wanted:day to night
Yeah I'm making my first dmod(a simple quest),and I need something that can wrap Dink in another screen when it is time(so a count up timer is needed).And it would be better that the script can be attached to a certain item(a watch maybe).
I have no idea how it should be written...
check out the dink c reference listing all the dink c commands, download day and night demonstrations and timer demonstrations they all exist for free
no,I mean I have two similar maps,one is normal tile,the other is night tile.and I have a timer that can count the time,calculate hours and minutes.What I want is when the timer points "8:00" the file would wrap Dink to normal map,and when it's "20:00" Dink would be wraped to night map...
The word Wrapped being replaced by Warped...
None the less, a VERY interesting concept, this idea could herald the beginning to Weather effects for the entire Dink Smallwood gaming style!
None the less, a VERY interesting concept, this idea could herald the beginning to Weather effects for the entire Dink Smallwood gaming style!
you dont need to switch your maps you can just change the color pallete or load the new "night" tiles
... okay good point, but don't blame me for not knowing of that file's existence lol >.>
You can find out the time without needing a count-up timer or anything, just use get_time_real();
From the DinkC Reference: get_time_real returns the number of minutes in the day. If it was 3 pm, or 15:00, it would return 900.
Take a look here as well!
Maybe some loop to check the time, something like...
...Ok after several edits I think that's right, it's almost 4am here
From the DinkC Reference: get_time_real returns the number of minutes in the day. If it was 3 pm, or 15:00, it would return 900.
Take a look here as well!
Maybe some loop to check the time, something like...
int &time; loop: wait(10000); &time = get_time_real(); //480 mins = 8am, 1200 mins = 8pm if (&time >= 480) { if (&time < 1200) { //check if already day, if not change to day //only skip if changing to day goto skip; } } //check if already night, if not change to night skip: goto loop;
...Ok after several edits I think that's right, it's almost 4am here
But in which procedure should I put this?main?or use?
The main procedure is the 'automatic procedure'; it runs when you run the script.
The use procedure is a specific procedure for weapons/magic that is activated when you use the weapon/magic.
The use procedure is a specific procedure for weapons/magic that is activated when you use the weapon/magic.
Why don't you make a timer that calls the <namehere>.c script when night begins? You could make a new procedure there, and in the main() you could just add the custom one (if you want to add an condition for it's run, do so there).
I believe that there are a few timer scripts on the file section.
I believe that there are a few timer scripts on the file section.
In fact,I need the script to warp Dink to the night map automatically,but I came across some problems...Nothing happend when it is time...I'll show you the script later.
Not sure exactly what you want, an item or what, I'll wait to see your script
What I would do is either have that loop script attached to sprite 1000 and always running, or attached to a sprite on every screen.
Edit: Also, instead of having a whole new map, you could do what joshriot mentioned and load new tilesets using load_tile().
I've never tried but I think this is how it works: say you want to replace TS01.bmp with night01.bmp.
I dunno, experiment
What I would do is either have that loop script attached to sprite 1000 and always running, or attached to a sprite on every screen.
Edit: Also, instead of having a whole new map, you could do what joshriot mentioned and load new tilesets using load_tile().
I've never tried but I think this is how it works: say you want to replace TS01.bmp with night01.bmp.
//don't know if the .bmp is needed... load_tile("night01.bmp", 1); draw_background();
I dunno, experiment
But how to attach script to script 1000?I'm not sure about that...
But should I place "script_attach(1000)" in the beginning or the end or a script?
Beginning somewhere, in a script like this. Before the first wait() anyway.
Sprite 1000 isn't a real sprite, it just means any script attached to it will keep running after changing screens so if you put it at the end of a script it might be that the player changes screen and kills the script before it's attached to sprite 1000... simple
Sprite 1000 isn't a real sprite, it just means any script attached to it will keep running after changing screens so if you put it at the end of a script it might be that the player changes screen and kills the script before it's attached to sprite 1000... simple
I don't know what's wrong...Just please help me check it...
//for start button
void main( void )
{
int &crap;
}
void buttonon( void )
{
sp_pframe(¤t_sprite, 2);
Playsound(20,22050,0,0,0);
}
void buttonoff( void )
{
sp_pframe(¤t_sprite, 1);
Playsound(21,22050,0,0,0);
}
void click ( void )
{
//lets start a new game
Say_xy("`%Please wait. (Creating new game)", 0, 394);
wait(1);
//This is where you would change the room Dink starts in!!
&player_map = 1;
//This is where you would change the location Dink is going to show up
//on this first screen...
sp_x(1, 180);
sp_y(1, 250);
//Change dink from a mouse pointer into a human being.
sp_base_walk(1, 70);
sp_base_attack(1, 100);
set_mode(2); //turn game on
reset_timer();
sp_dir(1, 8);
sp_brain(1, 1);
sp_que(1, 0);
sp_noclip(1, 0);
//Now, if you WANTED, you could set Dink's orininal variables so he
//could start out with a little money & power if you want... Simply
//comment out these lines if you want Dink to have nothing as far as
//stats go when the game begins. Also, Dink starts with 10 LifeMax
//(hit points).
&strength = 30;
&defense = 20;
&magic = 1;
&gold = 25;
&don = 1;
//&lifemax = 20;
//&life = &lifemax;
//&level = 2;
//lets give him fists to start out with, and arm him with the fists.
add_item("item-fst",438, 1);
add_magic("watch",438, 14);
&cur_weapon = 1;
&cur_magic = 1;
arm_weapon();
//Clear the screen black in preparation for the first room of the game.
fill_screen(0);
//This turns on the "status bar" for the beginning of the game. If you
//want to have an "intro", simply comment out the next two lines, then
//do them both after your intro is over...
&update_status = 1;
draw_status();
//We're done, so let's kill this task & the game will begin!
kill_this_task();
script_attach(1000)
loop:
wait(10000);
&time = get_time_real();
//480 mins = 8am, 1200 mins = 8pm
if (&time = 480)
{
&don = 2;
}
if (&time = 1200)
{
&don = 1;
}
skip:
goto loop;
}
//for start button
void main( void )
{
int &crap;
}
void buttonon( void )
{
sp_pframe(¤t_sprite, 2);
Playsound(20,22050,0,0,0);
}
void buttonoff( void )
{
sp_pframe(¤t_sprite, 1);
Playsound(21,22050,0,0,0);
}
void click ( void )
{
//lets start a new game
Say_xy("`%Please wait. (Creating new game)", 0, 394);
wait(1);
//This is where you would change the room Dink starts in!!
&player_map = 1;
//This is where you would change the location Dink is going to show up
//on this first screen...
sp_x(1, 180);
sp_y(1, 250);
//Change dink from a mouse pointer into a human being.
sp_base_walk(1, 70);
sp_base_attack(1, 100);
set_mode(2); //turn game on
reset_timer();
sp_dir(1, 8);
sp_brain(1, 1);
sp_que(1, 0);
sp_noclip(1, 0);
//Now, if you WANTED, you could set Dink's orininal variables so he
//could start out with a little money & power if you want... Simply
//comment out these lines if you want Dink to have nothing as far as
//stats go when the game begins. Also, Dink starts with 10 LifeMax
//(hit points).
&strength = 30;
&defense = 20;
&magic = 1;
&gold = 25;
&don = 1;
//&lifemax = 20;
//&life = &lifemax;
//&level = 2;
//lets give him fists to start out with, and arm him with the fists.
add_item("item-fst",438, 1);
add_magic("watch",438, 14);
&cur_weapon = 1;
&cur_magic = 1;
arm_weapon();
//Clear the screen black in preparation for the first room of the game.
fill_screen(0);
//This turns on the "status bar" for the beginning of the game. If you
//want to have an "intro", simply comment out the next two lines, then
//do them both after your intro is over...
&update_status = 1;
draw_status();
//We're done, so let's kill this task & the game will begin!
kill_this_task();
script_attach(1000)
loop:
wait(10000);
&time = get_time_real();
//480 mins = 8am, 1200 mins = 8pm
if (&time = 480)
{
&don = 2;
}
if (&time = 1200)
{
&don = 1;
}
skip:
goto loop;
}
And this is the script attached to map.
void main(void)
{
if (&don == 1)
{
&don = 2;
fade_down();
// screen to warp to, 1 to 768:
&player_map = &player_map + 9;
// Dink's X,Y coordinates on the new screen:
// face Dink in an appropriate direction, usually toward the player:
// load screen specified by &player_map:
load_screen();
// draw the screen's tiles and sprites:
draw_screen();
// if sp_noclip() is in use in this dmod, redraw the status area:
draw_status();
// undo fade_down(), or do a sp_nodraw(1,0) to undo a sp_nodraw(1,1):
fade_up();
// kill script manually, since we did a script_attach(1000) earlier:
kill_this_task();
}
}
void main(void)
{
if (&don == 1)
{
&don = 2;
fade_down();
// screen to warp to, 1 to 768:
&player_map = &player_map + 9;
// Dink's X,Y coordinates on the new screen:
// face Dink in an appropriate direction, usually toward the player:
// load screen specified by &player_map:
load_screen();
// draw the screen's tiles and sprites:
draw_screen();
// if sp_noclip() is in use in this dmod, redraw the status area:
draw_status();
// undo fade_down(), or do a sp_nodraw(1,0) to undo a sp_nodraw(1,1):
fade_up();
// kill script manually, since we did a script_attach(1000) earlier:
kill_this_task();
}
}
Urk.
There are many reasons why that won't work... Maybe later I'll have a go at making a fully workable version for you, or just run through this in detail if you'd prefer (to see what's wrong?).
There are many reasons why that won't work... Maybe later I'll have a go at making a fully workable version for you, or just run through this in detail if you'd prefer (to see what's wrong?).
Tell me what's wrong is better...Thanks.
Not much time recently... Ok I'll just copy those scripts exactly and put in comments about changes, not saying it'll work afterwards but at least (hopefully) you'll know the problems! Call it constructive criticism
Doing it this way, 2 things will happen that might not be what you wanted. This is because you changed my loop thingy, so maybe you did want this? Not sure...
1, it will only change from day to night (or other way) at exactly 8 o'clock. So if you start playing the game at 9pm it could look like day for example.
2, it will also only change day/night when you move to a different screen.
And my mistake, wait(10000) is actually 10 seconds Use wait(60000).
//blah blah blah &update_status = 1; draw_status(); kill_this_task(); //You've just killed the script! Nothing after this line will run. //Get rid of kill_this_task() //In fact, spawning a new script may be better than running the next bit in start.c //Need semi-colon: script_attach(1000); script_attach(1000) //Why did you change my example loop so much? //If there's a reason, I need to know it in order to know what to suggest here loop: wait(10000); &time = get_time_real(); //need == not just = in an 'if'. And see above comment! if (&time = 480) { &don = 2; } if (&time = 1200) { &don = 1; } //This skip: isn't being used, harmless but pointless to leave it here. skip: goto loop; }
void main(void) { if (&don == 1) { //Must have a script_attach(1000); before the load_screen() somewhere, //otherwise the script will die when the screen changes! &don = 2; fade_down(); //This won't work AFAIK. Better and simpler to do it this way: //&player_map += 9; &player_map = &player_map + 9; load_screen(); draw_screen(); //draw_status not needed unless they are actually changing. draw_status(); fade_up(); kill_this_task(); } }
Doing it this way, 2 things will happen that might not be what you wanted. This is because you changed my loop thingy, so maybe you did want this? Not sure...
1, it will only change from day to night (or other way) at exactly 8 o'clock. So if you start playing the game at 9pm it could look like day for example.
2, it will also only change day/night when you move to a different screen.
And my mistake, wait(10000) is actually 10 seconds Use wait(60000).
Sorry for being late,I'm just back from a trip...
Firstly thanks for these effort,and yeah,the two things you listed is exactly what I wanted.But don't worry,there is other script that will guarantee that if I play it at 9pm,it will be night.
But there is some small questions I want to ask:
1.How should I use this script?Attach to the map or something?
2.I'm not sure what this means:
&update_status = 1;
draw_status();
In the last,thank you again!
Firstly thanks for these effort,and yeah,the two things you listed is exactly what I wanted.But don't worry,there is other script that will guarantee that if I play it at 9pm,it will be night.
But there is some small questions I want to ask:
1.How should I use this script?Attach to the map or something?
2.I'm not sure what this means:
&update_status = 1;
draw_status();
In the last,thank you again!
Hope you had a nice trip
1. Which one?
2. I only included that because it's part of start.c, nothing to do with your script. All it does here is make sure the status bar is ready for starting the game.
1. Which one?
2. I only included that because it's part of start.c, nothing to do with your script. All it does here is make sure the status bar is ready for starting the game.
Er...thanks,but I don't really know how to use them...all of them...I don't know much about DinkC,you know...