Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gralats class... (https://forums.graalonline.com/forums/showthread.php?t=61283)

Torankusu_2002 09-18-2005 07:17 AM

Gralats class...
 
NPC Code:

if (created) {
setshape 1,32,32;
showcharacter;
//dontblock;
updategani();
}

if (updategani) {
updategani();
}

function updategani() {
type = 1;
//if (rupees>=350) type = 5;
//else
if (rupees>=100) type = 4;
else if (rupees>=30) type = 3;
else if (rupees>=5) type = 2;
setcharani gralats,#v(type);
}

if (rupees>1 || playerenters){
setcharprop #c,#v(rupees);
}


if (playertouchsme) {
playerrupees += rupees;
rupees = 0;
destroy;
}




This works for me.
The part I am having a problem with is this:
NPC Code:

if (rupees>1 || playerenters){
setcharprop #c,#v(rupees);
sleep 5;
setcharprop #c,;
}


That will show the amount of gralats that are there, and it will stop showing after .5 seconds, but it won't let the player pick them up anymore. Can anyone tell me why?

Lance 09-18-2005 07:25 AM

Quote:

Originally Posted by Torankusu_2002
The part I am having a problem with is this:
NPC Code:

if (rupees>1 || playerenters){
setcharprop #c,#v(rupees);
sleep 5;
setcharprop #c,;
}


That will show the amount of gralats that are there, and it will stop showing after .5 seconds, but it won't let the player pick them up anymore. Can anyone tell me why?

rupees>1 is not an event and it is being checked outside of an event block. Perhaps you meant to and those two conditions together instead of or them?

Torankusu_2002 09-18-2005 07:33 AM

Quote:

Originally Posted by Lance
rupees>1 is not an event and it is being checked outside of an event block. Perhaps you meant to and those two conditions together instead of or them?

I don't understand what you mean? With the first class script I posted (without the sleep, etc), if the player drops a gralat and there is only 1 gralat there, it doesn't display anything, but can be picked up. If you put more than one gralat there (2,5,etc), then it shows how much.

I want that text to show and after 5 seconds disappear, but also show if the player enters, and then disappear.

hold on, playing around with it.

Okay, got it to work.

NPC Code:



if (created) {
setshape 1,32,32;
showcharacter;
//dontblock;

updategani();

}

if (updategani) {

updategani();
setcharprop #c,#v(rupees);
sleep 5;
setcharprop #c,;

}


Lance 09-18-2005 07:39 AM

Quote:

Originally Posted by Torankusu_2002
I don't understand what you mean? With the first class script I posted (without the sleep, etc), if the player drops a gralat and there is only 1 gralat there, it doesn't display anything, but can be picked up. If you put more than one gralat there (2,5,etc), then it shows how much.

The way you had it structured, you were checking a condition outside of an event block (Not Good). See: this thread for more information.

Quote:

I want that text to show and after 5 seconds disappear, but also show if the player enters, and then disappear.

hold on, playing around with it.
A timeout might be better than a sleep for this.

calani 09-19-2005 07:32 AM

Quote:

Originally Posted by Lance
A timeout might be better than a sleep for this.

good habit to get into. v4 doesn't like sleeps in loops.

xAndrewx 09-19-2005 09:35 AM

Not too sure, but which one would be better here:
message #v(rupees); ?
setcharprop #c,#v(rupees);
not too sure, can someone answer this question and say why.

calani 09-19-2005 07:53 PM

setcharprop would be the optimal choice in this case becase the npc is a showcharacter.
if it were a normal npc (non-gani), then setcharprop would do nothing.

Skyld 09-19-2005 07:54 PM

Quote:

Originally Posted by calani
setcharprop would be the optimal choice in this case becase the npc is a showcharacter.
if it were a normal npc (non-gani), then setcharprop would do nothing.

Optimal choice?

calani 09-19-2005 07:57 PM

as in 'better of the two,' 'perferred,' 'best,' etc.

Skyld 09-19-2005 08:22 PM

Quote:

Originally Posted by calani
as in 'better of the two,' 'perferred,' 'best,' etc.

Is there any valid reason to prefer it? I'm not sure "because it's showcharacter;" is really a valid reason.

ForgottenLegacy 09-20-2005 02:31 AM

Quote:

Originally Posted by Skyld
Is there any valid reason to prefer it? I'm not sure "because it's showcharacter;" is really a valid reason.

For my scripts, setcharprop on an NPC without calling showcharacter, even if the prop is #c, does absolutely nothing. That's why it would be better to use message() instead, so it works regardless of the NPC being a showcharacter.

Although this thing might have been fixed!

Edit: Reverse what I just said, for the reason I just stated. <3 (Use setcharprop #c)

Ajira 09-20-2005 04:10 AM

Quote:

Originally Posted by ForgottenLegacy
For my scripts, setcharprop on an NPC without calling showcharacter, even if the prop is #c, does absolutely nothing. That's why it would be better to use message() instead, so it works regardless of the NPC being a showcharacter.

Although this thing might have been fixed!

But showcharacter is being called here, so why not use it.

xAndrewx 09-20-2005 01:14 PM

That's cool. Thanks

Torankusu_2002 09-20-2005 07:01 PM

not trying to be a ****, but i took the old graal2001 gralats class which was probably scripted by stefan, so ask him?


All times are GMT +2. The time now is 07:28 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.