Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 8 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty
Category: CoDUO Mapping
CoD United Offensive mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Trigger without waiting?
jamioflan
General Member
Since: Mar 15, 2007
Posts: 33
Last: Feb 13, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Wednesday, Feb. 10, 2010 05:01 pm
I want to have some looping code that checks whether a button is being pressed at certain time intervals. Rather than use waittill("trigger"); I need to have some code that checks if the button is being pressed, if it is do one thing, and if not then do something else.
Share |
oppdelta
General Member
Since: Jun 3, 2007
Posts: 143
Last: Apr 27, 2011
[view latest posts]
Level 4
Category: CoDUO Mapping
Posted: Wednesday, Feb. 10, 2010 05:39 pm
This might not be correct. Running off the top of my head here...


Code:
main()
{
	level.triggeractive = false;
	
	triggering thread();
}

triggering()
{
	thread check();
	while(1)
	{
		trigger waittill("trigger");
		level.triggeractive = true;
	}
}

check()
{
	while(1)
	{
		if(level.triggeractive)
		{
			//DO STUFF HERE
			level.triggeractive = false;
		}
                else
                {
			//DO OTHER STUFF HERE
			level.triggeractive = false;
		}
		wait 5;
	}
}


edited on Feb. 10, 2010 12:40 pm by oppdelta

edited: Rasta - fixed script changes posted below.
Share |
jamioflan
General Member
Since: Mar 15, 2007
Posts: 33
Last: Feb 13, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Wednesday, Feb. 10, 2010 05:40 pm
That looks good, ill try it.
Thanks

Edit: But should it not be thread check(); rather than check thread();

edited on Feb. 10, 2010 12:41 pm by jamioflan
Share |
oppdelta
General Member
Since: Jun 3, 2007
Posts: 143
Last: Apr 27, 2011
[view latest posts]
Level 4
Category: CoDUO Mapping
Posted: Wednesday, Feb. 10, 2010 05:48 pm
oh yeah. Sorry. Also in teh main. Switch them around. I had a mind block on those bits ^^;

you're right on it though =P
Share |
jamioflan
General Member
Since: Mar 15, 2007
Posts: 33
Last: Feb 13, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 11:24 am
Ok that was quite helpful but I am now stuck elsewhere. I am including my entire script for you to see it and I would like to know how to stop the tetris pieces. I am in a triple for loop and need to break them all at once... It is indicated by a comment but the script is still quite big.

Code:

main()
{ 
	thread letsplaysometetris();
} 



letsplaysometetris()
{

	tetris = [];
	
	tetris[11] = getent ("tetris1_1", "targetname");
	tetris[12] = getent ("tetris1_2", "targetname");
	tetris[13] = getent ("tetris1_3", "targetname");
	tetris[14] = getent ("tetris1_4", "targetname");

	tetris[21] = getent ("tetris2_1", "targetname");
	tetris[22] = getent ("tetris2_2", "targetname");
	tetris[23] = getent ("tetris2_3", "targetname");
	tetris[24] = getent ("tetris2_4", "targetname");

	tetris[31] = getent ("tetris3_1", "targetname");
	tetris[32] = getent ("tetris3_2", "targetname");
	tetris[33] = getent ("tetris3_3", "targetname");
	tetris[34] = getent ("tetris3_4", "targetname");

	tetris[41] = getent ("tetris4_1", "targetname");
	tetris[42] = getent ("tetris4_2", "targetname");
	tetris[43] = getent ("tetris4_3", "targetname");
	tetris[44] = getent ("tetris4_4", "targetname");

	tetris[51] = getent ("tetris5_1", "targetname");
	tetris[52] = getent ("tetris5_2", "targetname");
	tetris[53] = getent ("tetris5_3", "targetname");
	tetris[54] = getent ("tetris5_4", "targetname");

	tetris[61] = getent ("tetris6_1", "targetname");
	tetris[62] = getent ("tetris6_2", "targetname");
	tetris[63] = getent ("tetris6_3", "targetname");
	tetris[64] = getent ("tetris6_4", "targetname");

	tetris[71] = getent ("tetris7_1", "targetname");
	tetris[72] = getent ("tetris7_2", "targetname");
	tetris[73] = getent ("tetris7_3", "targetname");
	tetris[74] = getent ("tetris7_4", "targetname");

	tetris[81] = getent ("tetris8_1", "targetname");
	tetris[82] = getent ("tetris8_2", "targetname");
	tetris[83] = getent ("tetris8_3", "targetname");
	tetris[84] = getent ("tetris8_4", "targetname");

	tetris[91] = getent ("tetris9_1", "targetname");
	tetris[92] = getent ("tetris9_2", "targetname");
	tetris[93] = getent ("tetris9_3", "targetname");
	tetris[94] = getent ("tetris9_4", "targetname");

	tetris[101] = getent ("tetris10_1", "targetname");
	tetris[102] = getent ("tetris10_2", "targetname");
	tetris[103] = getent ("tetris10_3", "targetname");
	tetris[104] = getent ("tetris10_4", "targetname");


	tetris[111] = getent ("tetris12_1", "targetname");
	tetris[112] = getent ("tetris12_2", "targetname");
	tetris[113] = getent ("tetris12_3", "targetname");
	tetris[114] = getent ("tetris12_4", "targetname");

	tetris[121] = getent ("tetris13_1", "targetname");
	tetris[122] = getent ("tetris13_2", "targetname");
	tetris[123] = getent ("tetris13_3", "targetname");
	tetris[124] = getent ("tetris13_4", "targetname");

	rotatebutton = getent ("rotate","targetname");
	leftbutton = getent ("left","targetname");
	rightbutton = getent ("right","targetname");
	controllerspawn = getent ("spawn","targetname");
	spawnorigin = controllerspawn.origin;

	level.rotatepressed = false;
	level.rightpressed = false;
	level.leftpressed = false;

	megaorigin = tetris[11].origin;

	for (p=0; p<12; p++)
	{
		for (s=0; s<4; s++)
		{
			tetris[(p+1) * 10 + s + 1].inplay = 0;
			tetris[(p+1) * 10 + s + 1].rotation = 0;
		}
	}

	wait 60;
	
	for(;;)
	{
		players = getentarray ("player","classname");
		num = randomInt(players.size);
		if(getcvar("g_gametype") == "zom")
		{
			if(players[num].sessionstate == "playing" && players[num].pers["team"] == "axis" && maps\mp\gametypes\_zombie_util::numofplayers("axis") >= 2)
			{
				iPrintlnBold ("^7Let's play some ^2TETRIS^7!");
				iPrintlnBold ("^7" + players[num].name + "^7 was chosen to play!");
				players[num] setorigin(spawnorigin,1);
				break;
			}
		}
		else
		{
			if(players[num].sessionstate == "playing" && players.size >= 1)
			{
				iPrintlnBold ("^7Let's play some ^2TETRIS^7!");
				iPrintlnBold ("^7" + players[num].name + "^7 was chosen to play!");
				players[num] setorigin(spawnorigin,1);
				break;
			}
		}

	}

	thread checkrotate();
	thread checkleft();
	thread checkright();

	while (1)
	{
		for(;;)
		{
			piece = randomInt(12);
			if (tetris[piece * 10 + 1].inplay = 0 && tetris[piece * 10 + 2].inplay = 0 && tetris[piece * 10 + 3].inplay = 0 && tetris[piece * 10 + 4].inplay = 0)
				break;
		}
		
		raisepiece(tetris,piece);
		movepiece(tetris,piece,3);
		
		for(;;)
		{
			for(p=0; p<12; p++)
			{
				for(q=0; q<4; q++)
				{
					if (tetris[piece * 10 + 1].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 2].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 3].origin == tetris[(p+1)*10 + q].origin || tetris[piece * 10 + 4].origin == tetris[(p+1)*10 + q].origin)
						//stop the tetris, but how?		
				}
			}
		
		if (level.rotatepressed == 1)
			rotatepiece(tetris,piece);
		if (level.leftpressed == 1)
			pieceleft(tetris,piece,1);
		if (level.rightpressed == 1)
			pieceright(tetris,piece,1);
		if (level.rotatepressed == 0 && level.leftpressed == 0 && level.rightpressed == 0)
			movepiece(tetris,piece,1);
		}


		

	}

}

checkrotate()
{
	while(1)
	{
		rotatetrig = getent ("rotatetrig","targetname");
		rotatetrig waittill ("trigger");
		level.rotatepressed = true;
		wait 0.1;
	}
}

checkleft()
{
	while(1)
	{
		lefttrig = getent ("lefttrig","targetname");
		lefttrig waittill ("trigger");
		level.leftpressed = true;
		wait 0.1;
	}
}

checkright()
{
	while(1)
	{
		righttrig = getent ("righttrig","targetname");
		righttrig waittill ("trigger");
		level.rightpressed = true;
		wait 0.1;
	}
}

rotatepiece(tetris,piece)
{
tetris[10 * piece + 1] rotateyaw  (90,0.5);
tetris[10 * piece + 1].rotation++;
tetris[10 * piece + 2] rotateyaw  (90,0.5);
tetris[10 * piece + 2].rotation++;
tetris[10 * piece + 3] rotateyaw  (90,0.5);
tetris[10 * piece + 3].rotation++;
tetris[10 * piece + 4] rotateyaw  (90,0.5);
tetris[10 * piece + 4].rotation++;
tetris[10 * piece + 4] waittill ("rotatedone");

tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}

raisepiece(tetris,piece)
{
tetris[10 * piece + 1] movez(256,1);
tetris[10 * piece + 2] movez(256,1);
tetris[10 * piece + 3] movez(256,1);
tetris[10 * piece + 4] movez(256,1);
tetris[10 * piece + 4] waittill("movedone");

tetris[10 * piece +1].inplay = 1;
tetris[10 * piece +2].inplay = 1;
tetris[10 * piece +3].inplay = 1;
tetris[10 * piece +4].inplay = 1;

}

movepiece(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}

pieceright(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movey(128,0.1);
tetris[10 * piece + 2] movey(128,0.1);
tetris[10 * piece + 3] movey(128,0.1);
tetris[10 * piece + 4] movey(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}

pieceleft(tetris,piece,times)
{
for (i=0; i<times; i++)
{
tetris[10 * piece + 1] movey(-128,0.1);
tetris[10 * piece + 2] movey(-128,0.1);
tetris[10 * piece + 3] movey(-128,0.1);
tetris[10 * piece + 4] movey(-128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
tetris[10 * piece + 1] movex(128,0.1);
tetris[10 * piece + 2] movex(128,0.1);
tetris[10 * piece + 3] movex(128,0.1);
tetris[10 * piece + 4] movex(128,0.1);
tetris[10 * piece + 4] waittill("movedone");
wait 0.5;
}
}

killline(piece1,piece2,piece3,piece4,piece5,piece6,piece7,piece8,piece9,origin,tetris)
{

piece1 movez(-256,0.1);
piece2 movez(-256,0.1);
piece3 movez(-256,0.1);
piece4 movez(-256,0.1);
piece5 movez(-256,0.1);
piece6 movez(-256,0.1);
piece7 movez(-256,0.1);
piece8 movez(-256,0.1);
piece9 movez(-256,0.1);
piece9 waittill("movedone");
wait 0.5;
piece1 moveto((origin),0.1);
piece2 moveto((origin),0.1);
piece3 moveto((origin),0.1);
piece4 moveto((origin),0.1);
piece5 moveto((origin),0.1);
piece6 moveto((origin),0.1);
piece7 moveto((origin),0.1);
piece8 moveto((origin),0.1);
piece9 moveto((origin),0.1);
piece9 waittill("movedone");
wait 0.5;

for (y=0; y<3; y++)
{
if (piece1.rotation >= 1)
	{
	piece1.rotation--;
	piece1 rotateyaw(-90,0.01);
	piece1 waittill("rotatedone");
	}
if (piece2.rotation >= 1)
	{
	piece2.rotation--;
	piece2 rotateyaw(-90,0.01);
	piece2 waittill("rotatedone");
	}
if (piece3.rotation >= 1)
	{
	piece3.rotation--;
	piece3 rotateyaw(-90,0.01);
	piece3 waittill("rotatedone");
	}
if (piece4.rotation >= 1)
	{
	piece4.rotation--;
	piece4 rotateyaw(-90,0.01);
	piece4 waittill("rotatedone");
	}
if (piece5.rotation >= 1)
	{
	piece5.rotation--;
	piece5 rotateyaw(-90,0.01);
	piece5 waittill("rotatedone");
	}
if (piece6.rotation >= 1)
	{
	piece6.rotation--;
	piece6 rotateyaw(-90,0.01);
	piece6 waittill("rotatedone");
	}
if (piece7.rotation >= 1)
	{
	piece7.rotation--;
	piece7 rotateyaw(-90,0.01);
	piece7 waittill("rotatedone");
	}
if (piece8.rotation >= 1)
	{
	piece8.rotation--;
	piece8 rotateyaw(-90,0.01);
	piece8 waittill("rotatedone");
	}
if (piece9.rotation >= 1)
	{
	piece9.rotation--;
	piece9 rotateyaw(-90,0.01);
	piece9 waittill("rotatedone");
	}
}


piece1.inplay = 0;
piece2.inplay = 0;
piece3.inplay = 0;
piece4.inplay = 0;
piece5.inplay = 0;
piece6.inplay = 0;
piece7.inplay = 0;
piece8.inplay = 0;
piece9.inplay = 0;

for (p=0; p<12; p++)
{
for (s=0; s<4; s++)
{
if (tetris[(p+1) * 10 + s + 1].inplay == 1)
	{
	tetris[(p+1) * 10 + s + 1] movex(128,0.01);
	tetris[(p+1) * 10 + s + 1] waittill("movedone");
	}
}
}

}

Share |
oppdelta
General Member
Since: Jun 3, 2007
Posts: 143
Last: Apr 27, 2011
[view latest posts]
Level 4
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 03:15 pm
You could use the endon and notify functions.

You put the endon in the loop you want something to endon.

level endon("omg tetris ending");


And somewhere in the script you have to notify that condition is met...

level notify("omg tetris ending");




Gah I can't explain this...
Share |
jamioflan
General Member
Since: Mar 15, 2007
Posts: 33
Last: Feb 13, 2010
[view latest posts]
Level 2
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 03:28 pm
I've seen this before, I know what you mean. Thanks.
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 04:08 pm
oppdelta writes...
Quote:
You could use the endon and notify functions.

You put the endon in the loop you want something to endon.

level endon("omg tetris ending");


And somewhere in the script you have to notify that condition is met...

level notify("omg tetris ending");




Gah I can't explain this...


You cant use endon() inside a loop - only inside a function.
Share |
oppdelta
General Member
Since: Jun 3, 2007
Posts: 143
Last: Apr 27, 2011
[view latest posts]
Level 4
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 04:16 pm
I meant function...


I'm ill...don't judge me! *cries*
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoDUO Mapping
Posted: Saturday, Feb. 13, 2010 04:45 pm
oppdelta writes...
Quote:
I meant function...


I'm ill...don't judge me! *cries*


Oh, in that case: get well soon!
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty : CoDUO Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»