Code: Select all
int LineTrigger1 = 0;
script 1 (void)
{
if(LineTrigger1 == 0)
{
LineTrigger1 = 1;
Stairs_BuildDown(2, 16, 16, 0, 0);
}
else if(LineTrigger1 == 1)
Delay(1);
}
And also Is there a way to improve the code?
Moderator: GZDoom Developers
Code: Select all
int LineTrigger1 = 0;
script 1 (void)
{
if(LineTrigger1 == 0)
{
LineTrigger1 = 1;
Stairs_BuildDown(2, 16, 16, 0, 0);
}
else if(LineTrigger1 == 1)
Delay(1);
}
Code: Select all
int LineTrigger1 = 0;//makes sense to have a variable keep track of wether the script has been executed yet since there is more than one line that could trigger it
script 1 (void)//consider using names scripts instead
{
if(LineTrigger1 == 0)//check if the script has been executed yet
{
LineTrigger1 = 1;//it hasn't, so we make sure it won't execute again.
Stairs_BuildDown(2, 16, 16, 0, 0);
}
else if(LineTrigger1 == 1)
Delay(1);//the script has already been executed, but since we don't want anything to happen in that case, we don't need any code here. In fact, this line and the one before it are unneccessary.
}
Code: Select all
Script "SpawnMonster" (void)
{
SpawnSpotFacingForced
(
"DoomImp",//the class name of the actor to spawn
99,//the tid of the actor (usually a MapSpot) that you want to spawn at, with the spawned actor having the MapSpot's angle
666//the tid you want the spawned actor to have. Useful if you want to access it later. Could be 0 otherwise.
);
}
Code: Select all
[code]
Script "SpawnMonster" (int actorType,int mapSpotTid,int newTid)
{
str className = DoomImp"";//default in case we accidently pass more then 2 or less than 0 as actorType
switch(actorType)
{
case 0:
className = "DoomImp";
break;
case 1:
className = "ZombieMan";
break;
case 2:
className = "Demon";
break;
}
SpawnSpotFacingForced
(
className,//the class name of the actor to spawn
mapSpotTid,
newTid
);
}
The above script to spawn a monster carries the name ''SpawnMonster''.Mav3r1ck wrote:How would you suggest I name my scripts?
Code: Select all
int LineTrigger1 = 0;
script 14 (void)
{
if (LineTrigger1 == 0)
{
LineTrigger1 = 1;
Code: Select all
int LineTrigger1 = 0;
script 14 (void)
{
if (LineTrigger1 == 0)
{
LineTrigger1++;
Yes.Mav3r1ck wrote:
So is the coding on the bottom equivalent to the coding at the top?