Script for Choice teleport problem

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
zmarek20
Posts: 12
Joined: Sat Jun 22, 2013 7:43 am

Script for Choice teleport problem

Post by zmarek20 »

I have modified the code but it does not work properly. I wanted to use the teleport feature that uses Nitemare3D
In the game script does nothing.
Image

Code: Select all

/****************************************KEYCONF****************************************/
 
 
/*************************************GLOBAL SCRIPTS************************************/
// Put these (up to the next line) in a library if need be.
#include "zcommon.acs"
 
#define CURSOR 200
 
#define id_cursor               9970
#define id_choices              9980
 
int ThisScript = 0;
int menu = OFF;
int currentchoice = 0;
int maxchoices = 3;
 
function void ClearMsg ( int id )
{
  HudMessage(s:""; 0,id,-1,0,0,0);
}
 
function void Choice ( int number, int name )
{
  SetHudSize(384,256,0);
  SetFont("SmallFont");                    //You may change this...
  HudMessage(d:number+1,s:". \cl",s:name;  // or this, to your liking. Everything else should probably stay the same.
  HUDMSG_PLAIN,id_choices+number,CR_GREEN,67.1,170.1+(number*8.0),9999.0);
  ACS_Execute(CURSOR,0);
  maxchoices = number;
  menu = ON;
 
  for(int x=1; x<=100; x++)
  ClearMsg(id_choices+number+x);
}
 
function void ClearCursor ( void )
{
  ACS_Terminate(CURSOR,0);
  ClearMsg(id_cursor);
  for(int x=0; x<=100; x++)
  ClearMsg(id_choices+x);
  LocalAmbientSound("menu/clear",127); //Get rid of this (or any other LocalAmbientSounds) if it annoys you. :P
  menu = OFF;
}
 
// The following four scripts are best kept as scripts due to:
// (a) functions being unable to handle delays
// (b) "puke" being unable to grab the number of a script as defined in the scripts lump.
 
// You should define CURSOR as a number that won't interfere with your scripts.
script CURSOR ( void )
{
  SetHudSize(384,256,0);;
  HudMessage(s:"\cj*";
  HUDMSG_PLAIN,id_cursor,-1,52.1,170.1+(currentchoice*8.0),0.12);
  delay(5);
  restart;
}
 
script 201 ( void ) NET // MENU UP.
{
  if(menu==ON)
  {
    if(currentchoice>0) currentchoice--;
    LocalAmbientSound("menu/cursor",127);
  }
}
 
script 202 ( void ) NET // MENU DOWN.
{
  if(menu==ON)
  {
    if(currentchoice<=maxchoices-1) currentchoice++;
    LocalAmbientSound("menu/cursor",127);
  }
}
 
script 203 ( void ) NET // MENU SELECT.
{
  if(menu==ON)
  {
    ClearMsg(id_cursor);
    ACS_Execute(ThisScript,0);
    delay(1); // Don't ask me why this needs to be here; it just... does.
    currentchoice = 0;
  }
}
 
/**************************************MAP SCRIPTS**************************************/
 
// Example script to demonstrate setting up this choice menu.
script 52 ( void )
{
  ThisScript = 52; // Feh, stupid hacky way of telling script 203 which script to resume. :(
                   // Set this value to whatever number the script is.
 
  // =========================================================================================
  // WARNING: You shouldn't put this script in a place within your map where the script can be
  // triggered multiple times - it will take effect as if the select key was pressed.
  // =========================================================================================
 
  // Time to set up the choices menu. Choices must be in order and start from 0.
  Choice(0,"Teleport Destination #1");
  Choice(1,"Teleport Destination #2");
  Choice(2,"Cancel Teleport");
  suspend;
  switch(currentchoice) //This can be changed to an "if" statement if you wish.
  {
  // The following cases can do ABSOLUTELY anything you want.
  // I've set them up to give you weapons when selected.
  case 0:
    Teleport(1,1,0);
    break;
  case 1:
    Teleport(2,2,0);
    break;
  case 2:
    suspend;
    switch(currentchoice); //Another switch, within a switch! Have as many of these as you want,
                          //provided you place a "suspend" immediately before each one.
      }
 
  ClearCursor(); //This will get rid of the menu.
}
Post Reply

Return to “Scripting”