Page 1 of 1

Scripting Issue with Switches [SOLVED]

Posted: Mon Jun 09, 2014 11:09 pm
by TheRPGLPer
This problem is fixed

RE: Scripting Issue with Switches

Posted: Tue Jun 10, 2014 12:35 am
by ibm5155
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

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;
}
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 :)

RE: Scripting Issue with Switches

Posted: Tue Jun 10, 2014 2:11 am
by TheRPGLPer
Okay this looks much better than what I came up with. Now if I use this, how do I determine the switches on the script call (determining what level they pick), by setting the first argument or something?
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

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;
}
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 :)

RE: Scripting Issue with Switches

Posted: Tue Jun 10, 2014 3:04 am
by ibm5155
it would be something like
switch 0:
call script 60
argument 1:0
message on screen :To enter the IFINV01 - Technology Facility, press again.

switch 1:
call script 60
argument 1:1
message on screen:To enter the IFINV02 - The Cube, press again.

switch x:
call script 60
argument 1:x
message on screen:To enter the IFINVXX - Mapname X, press again.

If I remember it's action 160 (acs_execute)

so the argument will represent what switch did you actived ...

EDIT:
and ofc, there should be an error on that code xD

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;
}
so switch 0 with argument 0 should show IFINV01 and not IFINV00

RE: Scripting Issue with Switches

Posted: Thu Jun 12, 2014 12:51 am
by TheRPGLPer
Sorry for the late reply, but I only know basic ACS Scripting in ZDoom. My scripting knowledge goes into Invasion mapping.

Where is the error on this script?

I'm getting Invalid Identifier on the line that says Script 60 (int switch)

EDIT:
Nevermind, fixed that problem. Apparently "switch" can't be used as a variable. So replacing all that with "switch1" fixed the error.

However, it shows all the map names correctly, but pressing it twice still does not take me to the level. Here is the entire script if needed:

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;
}
EDIT 2: Now it's working. Except I have another error now. When it teleports me to another level (this is a hub btw), I get a No Cooperative Starts error, when I have 8 player starts in every level.

RE: Scripting Issue with Switches

Posted: Thu Jun 12, 2014 3:03 am
by ibm5155
facepalm, switch already was defined, derp ibm,

Well, if you made the others maps you could set it by acs the type of the map (coop,dm,...) if not, it could be made by creating an external lib that always set the map to coop, dm,...

There may be a better way to do it, but, i'm the acs guy :B (maybe on mapinfo?)

RE: Scripting Issue with Switches

Posted: Fri Jun 13, 2014 7:12 pm
by TheRPGLPer
I would guess it's something wrong with the game trying to teleport to a map that has a different gamemode.

The way I want my game set up is a hub level with the various playable levels accessible once the previous level is beat. I can solve this by setting a script when the level is beat to activate a script on Map 99 (My hub level) with an argument to tell it what level to unlock.

The hub level is of course a co-op gamemode while the levels in my game are invasion gamemode levels, as this is an Invasion wad.

So I don't know if I can't use Teleport_NewMap when the gamemode changes or if it is something I need to put in MapInfo or CMPGNINF.

Here are both files:
Mapinfo.txt

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
}
Cmpgninf.txt

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
}
I wonder if setting my hub level to cooperative with cmpgninf or setting it to invasion would fix the problem, but I'm not sure. I only really know Invasion ACS scripting and some basic complexity ACS functions.

EDIT: Fixed it. The script had Teleport_newmap(x, 1), that 1 needed to be 0. It was trying to teleport me to a map at player position number 1 which didnt exist,