Scripting Issue with Switches [SOLVED]
Posted: Mon Jun 09, 2014 11:09 pm
This problem is fixed
Leading the way in newschool multiplayer Doom online
https://zandronum.com/forum/
Code: Select all
#define TOT_LEVELS 6
int map_names[TOT_LEVELS]={" Technology Facility", "The Cube", "Demon Castle", "Lava Zone Redesign", "The Great Gate", "The Fortress"};
int pressed=0;
int pressed_switch=-1;;
script 60 (int switch){
int tmp1=switch/10;// 9/10=0 || 19/10=1
int tmp2=switch-(tmp1*10); 9-0=9 || 19-(1*10)=9
setfont("ConFont");
if(switch!=pressed_switch){//if a different switch was pressed, resed, data
pressed_switch=-1;
pressed=0;
}if(pressed==0){
delay(1);
printbold(s:"To enter the IFINV",d:tmp1,d:tmp2,s:" - ",s:map_names[switch], s:", press again.");
pressed=1;
pressed_switch=switch;
}else if(pressed==1){
delay(1);
teleport_newmap(51+switch, 1);
pressed=0;}
else pressed=0;
}
ibm5155 wrote: you cannot increment pressed that way, only if it was global, the pressed value that you're changing will die when the script X close/end
EDIT:
some solutions are:
1)Make a global var
2)Make a function where it receive the pressed int and return pressed int.
Also
It's a redux version of your map, the entered switch value should start with 0, and just add a new string into map_names if you need more maps and change the "total_levels 6" to the numbers of required maps, and the rest'll not need a change :)Code: Select all
#define TOT_LEVELS 6 int map_names[TOT_LEVELS]={" Technology Facility", "The Cube", "Demon Castle", "Lava Zone Redesign", "The Great Gate", "The Fortress"}; int pressed=0; int pressed_switch=-1;; script 60 (int switch){ int tmp1=switch/10;// 9/10=0 || 19/10=1 int tmp2=switch-(tmp1*10); 9-0=9 || 19-(1*10)=9 setfont("ConFont"); if(switch!=pressed_switch){//if a different switch was pressed, resed, data pressed_switch=-1; pressed=0; }if(pressed==0){ delay(1); printbold(s:"To enter the IFINV",d:tmp1,d:tmp2,s:" - ",s:map_names[switch], s:", press again."); pressed=1; pressed_switch=switch; }else if(pressed==1){ delay(1); teleport_newmap(51+switch, 1); pressed=0;} else pressed=0; }
Code: Select all
#define TOT_LEVELS 6
int map_names[TOT_LEVELS]={" Technology Facility", "The Cube", "Demon Castle", "Lava Zone Redesign", "The Great Gate", "The Fortress"};
int pressed=0;
int pressed_switch=-1;;
script 60 (int switch){
int tmp1=(switch+1)/10;// 9/10=0 || 19/10=1
int tmp2=(switch+1)-(tmp1*10); 9-0=9 || 19-(1*10)=9
setfont("ConFont");
if(switch!=pressed_switch){//if a different switch was pressed, resed, data
pressed_switch=-1;
pressed=0;
}if(pressed==0){
delay(1);
printbold(s:"To enter the IFINV",d:tmp1,d:tmp2,s:" - ",s:map_names[switch], s:", press again.");
pressed=1;
pressed_switch=switch;
}else if(pressed==1){
delay(1);
teleport_newmap(51+switch, 1);
pressed=0;}
else pressed=0;
}
Code: Select all
#include "zcommon.acs"
#define TOT_LEVELS 6
int map_names[TOT_LEVELS]={" Technology Facility", "The Cube", "Demon Castle", "Lava Zone Redesign", "The Great Gate", "The Fortress"};
int pressed=0;
int pressed_switch=0;
int elevator=0;
script 1 OPEN
{
sector_setcolor(5, 25, 25, 200);
setfont("ConFont");
printbold(s:"Welcome to the RedT0xic HQ. You can either hang around, check out new\n items and weapons, go to the arena, go to invasion levels\nor just start a new game from the main menu.");
}
script 2 (void)
{
if(elevator==0){
delay(1);
floorandceiling_lowerbyvalue(1, 25, 1024);
elevator=1;}
else if(elevator==1){
delay(1);
floorandceiling_raisebyvalue(1, 25, 1024);
elevator=0;}
else acs_terminate(2, 0);
}
script 3 (int arg0) //Door detection script
{
setfont("ConFont");
if(arg0==1){ //door 1
delay(1);
printbold(s:"Episode 1 - Level 1");}
else if(arg0==2){ //door 2
delay(1);
printbold(s:"Episode 1 - Level 2");}
else if(arg0==3){ //door 3
delay(1);
printbold(s:"Episode 1 - Level 3");}
else if(arg0==4){ //door 4
delay(1);
printbold(s:"Episode 1 - Level 4");}
else if(arg0==5){ //door 5
delay(1);
printbold(s:"Episode 1 - Level 5");}
else if(arg0==6){ //door 6
delay(1);
printbold(s:"Episode 1 - Level 6");}
else if(arg0==7){ //door 7
delay(1);
printbold(s:"Episode 1 - Level 7");}
else if(arg0==8){ //door 8
delay(1);
printbold(s:"Episode 1 - Level 8");}
else if(arg0==9){ //door 9
delay(1);
printbold(s:"Episode 1 - Level 9");}
else if(arg0==10){ //door 10
delay(1);
printbold(s:"Episode 1 - Level 10");}
else acs_terminate(3, 0);
}
script 4 (int arg0) //Episode Detection Script
{
setfont("ConFont");
if(arg0==1){
delay(1);
printbold(s:"Episode 1 - Rage of Terror");}
else if(arg0==2){
delay(1);
printbold(s:"Episode 2 - Hell's Army");}
else if(arg0==3){
delay(1);
printbold(s:"Bonus Episode - Inferno Invasion I & II");}
else if(arg0==4){
delay(1);
printbold(s:"Bonus Episode - Inferno Invasion I Maps");}
else if(arg0==5){
delay(1);
printbold(s:"Bonus Episode - Inferno Invasion II Maps");}
else acs_terminate(4, 0);
}
script 60 (int switch1){
int tmp1=(switch1+1)/10;// 9/10=0 || 19/10=1
int tmp2=(switch1+1)-(tmp1*10);// 9-0=9 || 19-(1*10)=9
setfont("ConFont");
if(switch1!=pressed_switch){//if a different switch was pressed, resed, data
pressed_switch=-1;
pressed=0;
}if(pressed==0){
delay(1);
printbold(s:"To enter the IFINV",d:tmp1,d:tmp2,s:" - ",s:map_names[switch1], s:", press again.");
pressed=1;
pressed_switch=switch1;
}else if(pressed==1){
delay(1);
teleport_newmap(51+switch1, 1);
pressed=0;}
else pressed=0;
}
script 61 (int arg0, int pswitch)
{
setfont("ConFont");
}
script 200 OPEN //ambient loop script
{
delay(random(175, 1050));
thing_activate(random(7,13));
restart;
}
Code: Select all
clearepisodes
/*
episode rtinv01
{
name = "Rage of Terror : Episode 1"
}
episode rtinv11
{
name = "Rage of Terror : Episode 2"
}
episode hlinv01
{
name = "Return of Hell : RoT Episode 3"
}
episode redtoxic
{
name = "RedT0xic HQ"
}
*/
episode redtoxic
{
name = "Campaign"
}
episode rtinv01
{
name = "Episode 1"
}
episode rtinv11
{
name = "Episode 2"
}
episode ifinv01
{
name = "Inferno Invasion"
}
//Intermission HQ Map
map redtoxic "RedT0xic HQ"
{
LevelNum = 99
sky1 = sky1, 0.0
music = "music/D_HQ.MP3"
cluster = 1
}
//Start Maps
map rtinv01 "The UAC Stronghold"
{
LevelNum = 1
next = redtoxic
sky1 = sky1, 0.0
music = "music/D_RTINV01.MP3"
cluster = 1
}
map rtinv02 "Heaven's Gate"
{
LevelNum = 2
next = rtinv03
sky1 = sky1, 0.0
music = "music/D_RTINV02.MP3"
}
map rtinv03 "Ancient Ruins"
{
LevelNum = 3
next = rtinv04
sky1 = sky1, 0.0
music = "music/D_RTINV03.MP3"
}
map rtinv04 "Asteroid"
{
LevelNum = 4
next = rtinv05
sky1 = sky1, 0.0
music = "music/D_RTINV04.MP3"
}
map rtinv05 "Paradise Island"
{
LevelNum = 5
next = rtinv06
sky1 = sky1, 0.0
music = "music/D_RTINV05.MP3"
}
map rtinv06 "Mars Fortress"
{
LevelNum = 6
next = rtinv07
sky1 = sky1, 0.0
music = "music/D_RTINV06.MP3"
}
map rtinv07 "Hell's Gate"
{
LevelNum = 7
next = rtinv08
sky1 = sky1, 0.0
music = "music/D_RTINV07.MP3"
}
map rtinv08 "The Doom Elevator"
{
LevelNum = 8
next = rtinv09
sky1 = sky1, 0.0
music = "music/D_RTINV08.MP3"
}
map rtinv09 "The Void"
{
LevelNum = 9
next = rtinv10
sky1 = sky1, 0.0
music = "music/D_RTINV09.MP3"
}
map rtinv10 "The Final Encounter"
{
LevelNum = 10
next = redtoxic
sky1 = sky1, 0.0
music = "music/D_RTINV10.MP3"
}
cluster 1
{
hub
}
//Old Maps
map ifinv01 "Hell Fortress"
{
next = ifinv02
sky1 = sky2a, 0.0
music = "music/D_IFINV01.MP3"
cluster = 1
levelnum = 51
}
map ifinv02 "The Cube"
{
next = ifinv03
sky1 = sky2a, 0.1
music = "music/D_IFINV02.MP3"
cluster = 1
levelnum = 52
}
map ifinv03 "Demon Castle"
{
next = ifinv04
sky1 = sky3, 0.0
music = "music/D_IFINV03.MP3"
cluster = 1
levelnum = 53
}
map ifinv04 "Lava Zone Redesign"
{
next = ifinv05
sky1 = sky1, 0.0
music = "music/D_IFINV04.MP3"
cluster = 1
levelnum = 54
}
map ifinv05 "The Great Gate"
{
next = ifinv06
sky1 = SKY1, 1.0
music = "music/D_IFINV05.MP3"
cluster = 1
levelnum = 55
}
map ifinv06 "The Fortress"
{
next = redtoxic
sky1 = SKY1, 0.0
music = "music/D_IFINV06.MP3"
cluster = 1
levelnum = 56
}
Code: Select all
//Rage of Terror Episode 1 (RedT0xic Invasion)
{
mapname = rtinv01
gamemode = Invasion
wavelimit = 6
}
//Inferno Invasion
{
mapname = ifINV01
gamemode = Invasion
wavelimit = 8
}
{
mapname = ifINV02
gamemode = Invasion
wavelimit = 8
}
{
mapname = ifINV03
gamemode = Invasion
wavelimit = 8
}
{
mapname = ifINV04
gamemode = Invasion
wavelimit = 6
}
{
mapname = ifINV05
gamemode = Invasion
wavelimit = 9
}
{
mapname = ifINV06
gamemode = Invasion
wavelimit = 7
}