Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple counter code not working... help please. #215559
07/12/08 01:10
07/12/08 01:10
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Ok I am losing my mind here. It's been years since I last did a lot of work in 3DGS and I swear I'm not an idiot hahaha (I won third place in a 3DGS contest way back when so I at least know something lol).

Anyway, I have the following code:

Code:
action animate_this()
{
   while(1) 
   {
      my.skill1 += 2*time_step;
           
      if (my.skill1 > 100)  // if the animation section is finished playing...
      { 

      	my.skill1 -= 100; // start the animation over...
			
	thePicker +=1;
	show_Picker();

      	}

      ent_animate(me,"dance",my.skill1,ANM_CYCLE);

      wait(1);
   }
}

It's just a simple animation code that plays through a scene in an MDL file. It works fine, but...

The part where I have "thePicker +=1;" is throwing me for a loop. It's supposed to count up by one every time the animation reaches 100% and loops back. Then the "show_Picker" just prints the current value of thePicker to the screen.

The problem is, instead of it counting by 1 it's counting by 4. No matter what I change it refuses to count by one. Instead it goes: 4, 8, 12, 16, 18, and so on.

So...

How do I set a counter that will increase by 1 when a single cycle of an animation is finished playing?

Bonus points for telling me why this counter only counts by 4s.

Re: Simple counter code not working... help please. [Re: jaknine] #215565
07/12/08 01:55
07/12/08 01:55
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Try thePicker = thePicker + 1;

Re: Simple counter code not working... help please. [Re: JazzDude] #215568
07/12/08 04:01
07/12/08 04:01
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

Joined: Dec 2005
Posts: 478
India
show_Picker();

post the code related to show_Picker(). There must be some fault in there.


My Specialities Limited.
Re: Simple counter code not working... help please. [Re: JazzDude] #215571
07/12/08 05:14
07/12/08 05:14
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Originally Posted By: JazzDude
Try thePicker = thePicker + 1;


Tried that and it does the same thing.

Re: Simple counter code not working... help please. [Re: msl_manni] #215573
07/12/08 05:18
07/12/08 05:18
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Originally Posted By: msl_manni
show_Picker();

post the code related to show_Picker(). There must be some fault in there.

Here it is...

Code:
STRING theTempString = "#64";
STRING theNumString = "#4"; 

text showthis_txt
{
    layer = 15;
    pos_x = 200;
    pos_y = 5;
    font = _a4font;

}

function show_Picker()
{
    str_cpy(theTempString,"Picker = ");

    str_for_num(theNumString,thePicker);

    str_cat(theTempString, theNumString); 

    showthis_txt.string = theTempString;
    showthis_txt.visible = on;

}

I have theTempString set to a high number because I use it to test various strings on screen, not all of them so short.

I should also add that my MDL file has 200 frames of animation in it with 12 scenes named from "AAA" to "LLL" if that makes a difference.

Re: Simple counter code not working... help please. [Re: jaknine] #215583
07/12/08 08:01
07/12/08 08:01
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116

Quote:
I swear I'm not an idiot hahaha

That's a shame.
Certainly, manni and I might like a few peers as company in the thread.
wink
Code:
define _ani1, skill52;   // don't use skill 1, or share skills

var ani_nPicker = 0;

STRING s1[256];
STRING s2[256];
TEXT ani_t1 {
	strings = 1;
	pos_x = 0;
	pos_y = 0;
	layer = 15;
	font = _a4font;
}

function anif_showPicker() {
	str_cpy(ani_t1.string[0], "Picker: ");
	str_for_num(s2, ani_nPicker);
	str_cat(ani_t1.string[0], s2);
	ani_t1.visible = ON;
}
// no parenthesis for action
action animate_this {
	ani_nPicker = 0;
	while(me != NULL) {  // 
		my._ani1 += 2*time_step;  // well...
		//ani_nPicker += (ani_nPicker >= 99.998);
		ani_nPicker += (ani_nPicker >= 100);
		my._ani1 %= 100;
		ent_animate(me,"dance", my._ani1, ANM_CYCLE);
		anif_showPicker();
		wait(1);
	}
}
// model and / or this code could be a problem





Re: Simple counter code not working... help please. [Re: tD_Datura_v] #215730
07/13/08 01:58
07/13/08 01:58
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Originally Posted By: tD_Datura_v

Quote:
I swear I'm not an idiot hahaha

That's a shame.
Certainly, manni and I might like a few peers as company in the thread.
wink
Code:
...


Thanks for that code; even though the counter didn't work (heh) it got me thinking in different ways and I got done what I needed to get done in my program.

Re: Simple counter code not working... help please. [Re: jaknine] #215790
07/13/08 12:53
07/13/08 12:53
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
Probably you have 4 entities with the action animate_this.
As ThePicker is just a global variable it's counted by everyone of these entities

Re: Simple counter code not working... help please. [Re: TechMuc] #216099
07/15/08 06:43
07/15/08 06:43
Joined: Feb 2002
Posts: 288
California, USA
J
jaknine Offline OP
Member
jaknine  Offline OP
Member
J

Joined: Feb 2002
Posts: 288
California, USA
Originally Posted By: TechMuc
Probably you have 4 entities with the action animate_this.
As ThePicker is just a global variable it's counted by everyone of these entities


Hah! I do have 4 entities controlled by it and that would indeed explain it. You get the bonus points. Thanks. smile


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1