The Dink Network

Changing dink text sprite location

October 26th 2010, 08:13 PM
sob_scorpr.gif
Rilian
Peasant They/Them United States
 
Hi, I have another code question.
For the dmod I am scripting, I am using another character instead of Dink. The character pixel height is shorter than Dink. Whenever the character says something, the text sprite appears way over its head, which is a little distracting. I thought that the text sprite would automatically adjust location to match the height of the sprite, but this doesn't seem to be happening. Is there a way to make the text sprite appear lower down, or closer to the main character sprite if it is a small sprite? Thanks
October 26th 2010, 09:29 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
The text position is directly relative to a sprite's depth dot (100 pixels above). Changing the position Is possible, but you'd have to add an extra line of code after every single line of text he says.

If you're still determined doing it, here's how you'd do so.

say("My text is now lowered",1);
sp_defense(&last_text,80);


I know it sounds weird, but it just so happens to be a secondary function of sp_defense when used with text sprites. The value is the amount of pixels you want. As I said it is 100 by default.

One more thing I forgot- You won't be able to use say_stop with it. It's probably best to just deal with the text being too high.
October 27th 2010, 04:43 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
There we go, learned something new myself Is your new hero similar to Dink in size? If so, just mess with the depth dot until you perfect it. If not, there's always the option of having text displayed in the bottom center during cinematics, though I feel it doesn't work as well without voice acting xD
October 27th 2010, 05:58 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
The depth que should be optimized for combat and walking around. Changing the depth que to get the correct text height is doing major damage to playability for only a small aesthetic improvement.
October 27th 2010, 02:27 PM
burntree.gif
hell7fire1
Peasant He/Him Botswana
It's like that. 
I have never played with a dwarf character before.
October 27th 2010, 10:19 PM
sob_scorpr.gif
Rilian
Peasant They/Them United States
 
Hmmm alright. I guess I either have to go through and readjust the depth doth for each dialogue instance or ignore it. Oh well. Thanks for the replies.

I am really enjoying the convenience of DinkC, but it seems very buggy at times. For example, I was coding a scene where I have two sprites controlled by loops in separate scripts. They were completely independent, but when the touch procedure was called on one of them the other just randomly made a beeline for the edge of the screen. I was like "that just happened...?!?"
October 28th 2010, 07:14 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
That doesn't sound like something buggy in DinkC to be honest I've used almost every command and almost any combination of scripting you can possibly think of and that's not something I've had happen to me xD Not saying it's impossible something in DinkC is not working as intended though because there are a few instances of that too.

Paste the script here, cause it's almost certainly something you overlooked in the scripting
October 28th 2010, 07:25 PM
sob_scorpr.gif
Rilian
Peasant They/Them United States
 
Hm, alright. Here's the scenario:

I have two sprites walking back and forth and making periodic comments. One of the sprites walks left and right, the total distance is randomly determined, and the speak procedure is also random. The procedure is looped in the main of that sprite.

Another sprite is walking up and down, doing the same thing (making random statements).

When you touch a particular sprite, the one that is walking up and down freezes, and talks to you, meanwhile the other is supposed to continue in the back unabated. Instead, what happens is the one that is walking left and right doesn't turn around, it keeps going and ends up on the other side of the screen, at which point it continues merrily along doing what it was originally doing. Here are the appropriate scripts:

[Left and right walker. Basewalk etc. are determined in WDE. The code has been modified so that the character is not walking random distances.]

void main(void)
{
int &sy = 0;
int &wt;
&save_x = sp_x(&current_sprite, -1);
sp_speed(&current_sprite,4);

mov:
&wt = random(1000, 0);
wait(&wt);
&save_x -= 20;
move_stop(&current_sprite, 4, &save_x, 1);
&save_x += 20;
wait(10);

&sy = random(3, 1);
if (&sy == 1)
{
say_stop_npc("`3stuff", &current_sprite);
} else
{
if (&sy == 2)
{
say_stop_npc("`3stuff", &current_sprite);
} else
{
say_stop_npc("`3stuff", &current_sprite);
}
}

&wt = random(1000, 0);
wait(&wt);
move_stop(&current_sprite, 6, &save_x, 1);
wait(10);
&sy = random(3, 1);

if (&sy == 1)
{
say_stop_npc("`3stuff", &current_sprite);
} else
{
if (&sy == 2)
{
say_stop_npc("`3stuff", &current_sprite);
} else
{
say_stop_npc("`3stuff", &current_sprite);
}
}

goto mov;

}

[Script attached to item - touch script]

void main(void)
{
int &whob = sp(22); //Up and down walker. Will be talking.
int &said = 1;
int &ss = sp_seq(&whob, -1);
int &sf = sp_frame(&whob, -1);
int &temp = 0;
int &scrpt;
sp_touch_damage(&current_sprite, -1);

}

void touch(void)
{
sp_touch_damage(&current_sprite, 0);
freeze(1);
freeze(&whob);
sp_speed(&prsna, 0); //&prsna is the left-right walker. I am freezing it
//because it does wierd things if I don't.
sp_script(&whob, "blnk"); //
sp_script(&prsna, "blnk"); // This blank script is being attached because
//... the sprite will walk off the screen without it.

sp_speed(&whob, 0);
wait(10);
&save_x = sp_x(&whob, -1);
wait(10);
&save_y = sp_y(&whob, -1);
wait(10);
sp_speed(&whob, 2);
wait(10);
sp_base_walk(&whob, 350);
wait(10);
if (&save_y < 150)
{
move_stop(&whob, 2, 157, 1);
}
wait(10);
sp_dir(&whob, 4);
wait(10);
say_stop("`0stuff", &whob);
wait(10);
sp_dir(1, 6);

say_stop("stuff!", 1);
wait(100);
say_stop("`0stuff,", &whob);
wait(100);
say_stop("`0stuff.", &whob);
wait(100);
say_stop("`0stuff,", &whob);
wait(100);
say_stop("`0stuff!", &whob);
wait(100);
say_stop("stuff!", 1);
&save_y = sp_y(1, -1);
&save_y += 10;
move(1, 2, &save_y, 1);
wait(100);
&said = 2;
unfreeze(1);
unfreeze(&whob);


sp_script(&whob, "cstl_cook");


wait(10);
sp_speed(&whob, 2);
wait(10);

sp_kill(&prsna, 1); //re-creating the left-and-right walker because I attached
// The blank script.
if (&msc == 1)
{
&prsna = create_sprite(164, 141, 0, 353, 1);
sp_speed(&prsna, 2);
sp_base_walk(&prsna, 350);
sp_speed(&prsna, 2);
sp_script(&prsna, "cstl_cookb2");
} else
{
if (&msc == 2)
{
&prsna = create_sprite(477, 141, 0, 353, 1);
sp_speed(&prsna, 2);
sp_base_walk(&prsna, 350);
sp_speed(&prsna, 2);
sp_script(&prsna, "cstl_cookb1");

} else
{
if (&msc == 3)
{
&prsna = create_sprite(165, 65, 0, 353, 1);
sp_speed(&prsna, 2);
sp_base_walk(&prsna, 350);
sp_speed(&prsna, 2);
sp_script(&prsna, "cstl_cookb4");
} else
{
&prsna = create_sprite(477, 65, 0, 353, 1);
sp_speed(&prsna, 2);
sp_base_walk(&prsna, 350);
sp_speed(&prsna, 2);
sp_script(&prsna, "cstl_cookb3");

}
}
}

sp_touch_damage(&current_sprite, -1);

}

To solve the problem I temporarily attached a blank procedure to it, then after the touch procedure is run, I kill the sprite, recreate it, and attach the appropriate script to it again. This works but I would rather not have to do it at all.
October 28th 2010, 07:48 PM
peasantfr.gif
Is &save_x a global variable? Since it is in used in the script of the left-right walker and in the script of the touchobject for two different values I think it could be the problem.
I do not have a lot of scriptingexperience, but that is what I think. Hope it helps otherwise you have to wait for someone more skillfull to take a look at it. Good luck anyway.
October 28th 2010, 08:01 PM
spike.gif
Yep, that's it.

DinkC: 1
Rilian: 0

( )
October 28th 2010, 08:05 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
There is a good chance anathavia has it right on the spot.

Basically, whenever you use wait(10), you transfer control over to something else for at least 10 milliseconds. If said something else (the left-right-walker, for example) changes &save_x or &save_y, you might as well not have stored anything in it yourself. Does the left-right-walker end up at (roughly) the same x-coordinate as the up-down walker?

In other news, there's FIFO & Variables in DinkC which is more in-depth about how Dink's script scheduler works.

And for future reference, you can use [coode][/coode] (intentionally misspelt, fix this yourself) tags to post DinkC code, and you'll get fancy syntax highlighting and line numbers.
October 28th 2010, 10:49 PM
sob_scorpr.gif
rilian
Peasant They/Them United States
 
Thanks for the responses.
&save_x and &save_y are actually not globals. It seems very weird to me that I could have two separate scripts running, and they are interferring with eachother because the variables have the same name. This isn't how most codes work. I might look at the FIFO link.
October 29th 2010, 02:34 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
&save_x and &save_y are globals. Unless you have removed them, which doesn't sound like a good idea since it's used rather often... Most noticeably in determining where goodies are dropped when an enemy dies.
October 29th 2010, 07:41 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
They are indeed standard globals in use by the default main.c
October 29th 2010, 08:05 AM
sob_scorpr.gif
rilian
Peasant They/Them United States
 
Wow ok, I did not know that, my bad. Thanks for looking over the code, my apologies if my replies were inflammatory
October 29th 2010, 09:46 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
No problem And I don't feel your replies were in any way inflammatory^^ Always here to help