The Dink Network

sprites-editor\sprites-script

November 21st 2005, 07:43 AM
slayer.gif
RANKN67
Peasant He/Him
 
ok, i want sprites made in the editor to be on screen untill a certain global number, cus then i am goin to be makin those exact sprites by making a script is there a way that when its a certain global number that the sprites i made in the editor will go away, i tried using visions but then again, i could be just using vissions wrong......... please help
November 21st 2005, 08:06 AM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
if(&story=x) ?

I believe each sprite has sp_timer(int) as well

hth,
mm
November 21st 2005, 08:40 AM
pig.gif
I think you can't change visions unless you do Fade_down(); or something. I dunno. Anyway, attach this to a script on the screen to check if the variable is equal to the desired number then make a sprite vanish.

Void main(void)
{
loop:
if(&<whatever your variables name is> == <desired number
{
sp_active(&<whatever the variable assigned to your sprite(s)>, 0);
//Change that 0 to a 1 to make a sprite reappear.
}
wait(100);
Goto loop;
}

Also, if you dont know how to assign a variable to a sprite, add this to the sprites (main) function of its script.

&current_sprite= &<variable for this sprite>

Hope that helped/is accurate (i havent really scripted anything in a few months).
November 21st 2005, 11:17 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
To only display the sprites in vision 1 when, for example, &story <= 5, do this:

First place the sprites in the editor in vision 1. Then make a script and attach it to that screen:

void main(void)
{
if (&story <= 5)
{
&vision = 1;
}
kill_this_task();
}

You should also create a script and attach it to a sprite on the screen with:

void main(void)
{
if (&story > 5)
{
// create_sprite(bla...);
// create_sprite(bla...);
}
}
November 21st 2005, 01:33 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
The best way to make a sprite not to appear on a screen after/before something, use this in the void main(void) :
If(&story < 10)//you put here the condition
{
sp_nodraw(&current_sprite, 1);
sp_hard(&current_sprite, 1);
draw_hard_map(&current_sprite);
sp_kill(&current_sprite, 1);
return;
}
November 21st 2005, 03:29 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
For one sprite.. but not for two dozen. You don't want to do that for all the sprites in all the scripts; that's why we have visions
November 21st 2005, 04:22 PM
anon.gif
RANKN67
Ghost They/Them
 
when im using the editor (WDE) I put no sprites on vision 0 but a few sprites on vision 1. but wen i change it back to vision 0 the sprites that i put in vision 1 are in vision 0,.......its weird, am i using visions wrong?
November 21st 2005, 04:33 PM
slayer.gif
RANKN67
Peasant He/Him
 
problem(to simeon)

i put in ur vision script in my dmod but it seems to have messed up my script that i need to use
November 21st 2005, 04:55 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Sprites that are in vision 1 shouldn't be visible when viewing vision 0.. so yeah, something's odd there.
November 21st 2005, 04:57 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
That first script should be attached to the screen, not to a script. And the main procedure in the second script is just a way of how the script should be used: if &story is below or equal to 5 (for example), then the script attached to the screen takes care of showing the sprites and if &story is greater than 5, then the script attached to a sprite on that screen displays/create_sprite();s the sprites;
November 22nd 2005, 12:36 AM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
Not to be rude but why would you want to delete then recreate something that is already there?

Perhaps cypry has the better idea. This would allow you to reuse an existing object based on your scripts needs.

My 2 questions are.
1. Is there performance hit between using a sprite spawned in a script instead of one created in the editor?

2.When does garbage collection take place in the dink engine and how long will Windows take before it finalizes?

Silly anectdote, when I studied Netware 3 they mentioned that 1 of the memory pools did not release unused memory, even when a process was removed. They explained that there were 2 ways to increase this memory. (a) reboot the server (b) install more Ram.
Is there such a thing as hot-swappable Ram?

mm
November 22nd 2005, 06:33 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
1) No.
2) There is no garbage collection. Local variables are only freed when a script dies, and a script dies when a) the sprite that it is attached to dies, b) the player moves to a different screen, or c) the author issues the kill_this_task() command.

In some cases, a script can be set to survive across screens (when it is attached to sprite 1000). If kill_this_task() is not used to end it, it will only free its variables on saving/loading the game (hopefully).
November 22nd 2005, 11:05 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Not to be rude but why would you want to delete then recreate something that is already there?

Perhaps cypry has the better idea. This would allow you to reuse an existing object based on your scripts needs.


It depends on the situation. For small scenes with a small number of sprites (say, n <= 10), it is managable to attach a script to all sprites that should appear (or not). Yet even for this small number, it's not recommended to do this. Because let's say, you have scripted it to display the sprites when &story is greater than or equal to 10.

Later in development, you realize it shouldn't be 10 but 12. What to do now? You'll have to go through all the scripts and change the value. To prevent maintenance and version problems, you don't want to write code twice. The problem because more significant when we're talking about greater numbers (50, 90, and it does not have to end there if someone removes the spriteslimit of 99).

Your argument for not wanting to recreating the same sprites again applies to the recreation of the same code as well. And usually, the scene you'll create through a script will be different from the scene stored in a vision (it will vary either slightly, a lot or they won't be similar at all..).

Of course, a real programming language (and not a scripting language like DinkC), offers enough possibilities to solve this problem: you could create a method higher in the class hierarchy to perform this check. This way, the information is only stored once in the program (or game in this case) for all the sprites that should appear or not on that screen.

As a side note, it's interesting that this game offers people with different (yet sometimes computer-related) backgrounds various topics to talk about, be it the computer or gaming itself
November 22nd 2005, 11:07 AM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
ty for 1

If there is no garbage collection in the engine then at least we only have to wait on windows.

Just the same, deleting an object does not assure us that the memory will be immediately returned to the pool.

I have noticed that after long play sessions, that lag developes on some screen loads. This tells me that available resources are decreasing.

My first computer was a vic20, so I am anal about not wasting resources. I will get over it.

mm
November 22nd 2005, 11:47 AM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
I agree that future updates to source code should be easy to implement, such as using a baseref for a website, rather than hardcoding paths.

In this case though, OP will be deleting the editor created sprites and rercreating these exact same sprites, with a script.

I'm suggesting his alternate script should only be called once the global condition was correct, and would only change necessary attributes to the existing objects rather than replacing them with identical ones.

e.g. If we have sprites 4,5 and 6; we can refer to them as sp(4),sp(5),sp(6) or &man1,&man2,&man3.

Our script then deletes &man1,&man3.
Creates &man3, then deletes &man2, and finally recreates &man1, &man3. This may be different also from OP's needs, but entirely possible.

If the script references at some point by sp(4) then the editor sprite would be &man1, where as the scripted sprite could be &man3, providing no other sprites had been created or disposed of in the interim.

Just the same, I am learning more than I am offering and I appreciate this chance to exchange your knowledge with my ideas. Even a bad idea can be a good thing.

They say the weakest link in a network, is between the keyboard and the chair. With workshare programs, we have increased the number of weak links. The upside is that we will eventually replace the occurence new user glitches with recurring themes.
mm
November 22nd 2005, 12:54 PM
wizardb.gif
Cifra
Peasant He/Him
 
I've got a sprite, which isn't animated and I wanna put it into the editor.
I saved the file into a subdirectory...
graphics/pingvin/pingvin-01.bmp

and iI ptu this at the end of the DINK.ini file;
load_sequence_now graphics\pingvin\pingv- 499 NOTANIM

but it doesn't work...
November 22nd 2005, 12:59 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
The actual filename and the filename in Dink.ini should be the same, yet without the numbers. So if the actual filename is pingvin-01.bmp, then you should have pingvin- in Dink.ini, not pingv-
November 23rd 2005, 01:30 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
What is the sprite number limit?
November 23rd 2005, 01:48 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
99, though I can't remember for sure if that includes or excludes Dink. I think it includes Dink so 98 sprites on a screen plus Dink is allowed.
November 23rd 2005, 04:04 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
The 99 sprite limit is for editor sprites (i.e. sprites placed in Dinkedit or Windinkedit). Therefore, I'm fairly certain that it doesn't include Dink.
November 23rd 2005, 04:09 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Does that mean you can create_sprite() to over 99 sprites? Or is 100 the limit (= 99 + Dink)?
November 23rd 2005, 04:13 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Yep, you can use create_sprite to go over the 99 limit. The limit for active sprites is 299.
November 23rd 2005, 04:15 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Hmm.. the game crashes here when going to a screen with 99 Ah well.