Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, degenerate_762), 1,430 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
trying to reset entities.... #258792
04/02/09 06:18
04/02/09 06:18
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
Okay this is a very strange questions but bear with me. I have a trigger object (a block) that causes a map entity to tilt roll or pan. Currently the code checks to see what the value of the trigger is (IE if 1 do this if 2 do that) both values cause the map entity to be positioned in a certain manner.

Both work if they are touched first. However I'm trying to "reset" the room back to its original position if the player hits one of the switches. The point that I'm at now is that if the player hits the "reset" switch it causes the action I want. However if the player hits the "roll" switch and THEN tries to hit the "reset" switch nothing happens. The room just stays in one position. I checked to make sure that the value is being changed. It is but nothing happens. Is it because I can't change to position of a map entity more than once?


Here's my code example


action room1rotate // this is the first rotation in the demo
{


while(player_close ==0){wait(1);}
// the way this should work is that it checks to see if the player is clse
// this causes the first room to go to its left 90 degrees this makes the player be able to go into the next room
// my.tilt = my.tilt - 180 * time; // tilt is up pan is horizontal
player.z += 5;
player.x -= 20;
// my.event = roomreset;




if player_close == 1
{

my.tilt = my.tilt + 180 * time;

}

if player_close == 2
{
snd_play (gear_wav, 100, 0);
my.tilt -= 180;
}



}

and these are the triggers driving the action:

action trap_trigger
{
my.enable_touch = on;
// my.event = trap_player;
while(player == null){wait(1);}
while(vec_dist(player.x, my.x) > 100) {wait(1);} // player with the 40
player_close = 1;

}

action room2flip2reset
{
my.enable_touch = on;

while(player == null){wait(1);}

while(vec_dist(player.x, my.x) > 100) {wait(1);} // player with the 40

player_close = 2;
//my.x += 500;

}

Re: trying to reset entities.... [Re: Thehawk] #258891
04/02/09 18:16
04/02/09 18:16
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
so i think i figured out part of it.... when the entity is touched it passes the value player_close 1 or 2.

When i debug the code it stops at one or 2 so its catching the value and performing the action i tell it to. But the problem is once the value of player close is equal to anything else it wont preform the other action. can i only set a variable's value once or something? is there a better way to do this?

Re: trying to reset entities.... [Re: Thehawk] #258928
04/02/09 23:26
04/02/09 23:26
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Quoting Thehawk.
Quote:
But the problem is once the value of player close is equal to anything else it wont preform the other action.

'One-time' evaluation in room1rotate.
Evaluation loops end when player in range. (trap_trigger, room2flip2reset)



Code:
action room1rotate // this is the first rotation in the demo
{
	
	var tilt0; tilt0 = my.tilt;
	
	while(player_close ==0){wait(1);}
	// the way this should work is that it checks to see if the player is close
	// this causes the first room to go to its left 90 degrees this makes the player be able to go into the next room
	// my.tilt = my.tilt - 180 * time; // tilt is up pan is horizontal
	player.z += 5;
	player.x -= 20;
	// my.event = roomreset;
	while(me != NULL) {
		if (player_close == 1) {
			if (my.tilt < (tilt0 + 180)) {
				my.tilt += 5 * time_step;
			}
		}
		if (player_close == 2) {
			snd_play (gear_wav, 100, 0);
			if (my.tilt > tilt0) {
				my.tilt -= 5 * time_step;
			}
		}
		wait(1);
	}
}

// and these are the triggers driving the action:

action trap_trigger {
	my.enable_touch = on;
	// my.event = trap_player;
	while (me != NULL) {
		if (player == NULL) { goto(fNext);}
		if (vec_dist(player.x, my.x) <= 100) {
			player_close = 1;
		}
		fNext:
		wait(1);
	}
}

action room2flip2reset {
	my.enable_touch = on;
	while (me != NULL) {
		if (player == NULL) { goto(fNext);}
		if (vec_dist(player.x, my.x) <= 100) {
			player_close = 2;
		}
		fNext:
		//my.x += 500;
		wait(1);
	}
}


Re: trying to reset entities.... [Re: testDummy] #258929
04/03/09 02:06
04/03/09 02:06
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
my gosh thank you! I was beating my head against a wall trying to figure this one out! much appreciation!!


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