YAY! Problem time!!!!!!!!

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
chaoscentral
Posts: 677
Joined: Sun Feb 27, 2005 4:32 pm
Location: Revere, MA
Contact:

YAY! Problem time!!!!!!!!

Post by chaoscentral »

ok... I got two problems now. First things first... BRIDGES!
How do I make em. I've screwed around and cant figure it out. Dont say RTM or RTFW, I live there so I always read it.

Second, I need help with this script. I'm making a vending machine that gives you heath for the first 3 times you use it. Then after that it displays "they ran out". Now I'm pretty good with ACS, but I cant get it to work. It either always works, or youcan only use it once. If you want the script let me know ill post it. Thanks in advance for any help.
LK873
Posts: 274
Joined: Mon Aug 30, 2004 10:54 am
Location: Ontario, Canada

Post by LK873 »

Post it.
User avatar
chaoscentral
Posts: 677
Joined: Sun Feb 27, 2005 4:32 pm
Location: Revere, MA
Contact:

Post by chaoscentral »

Code: Select all


int i;

script 999 OPEN
{
	i = 0;
}


script 255 (void)
{
	If(i == 0) {
		GiveInventory("HealthBonus", 5);
		Print(s: "You got a snack!");
		i++;
	}
	If(i == 1) {
		GiveInventory("HealthBonus", 5);
		Print(s: "You got another snack!");
		i++;
	}
	If(i == 2) {
		GiveInventory("HealthBonus", 5);
		Print(s: "You got another snack!");
		i++;
	}
	If(i >= 3) {
		Print(s: "They ran out!");
	}
}

LK873
Posts: 274
Joined: Mon Aug 30, 2004 10:54 am
Location: Ontario, Canada

Post by LK873 »

Try declaring the variable inside the script so it's a script variable, like

Code: Select all

#include "zcommon.acs"

script 255 (void)
{
   int i = 0;
   If(i == 0) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got a snack!");
      i++;
   }
   If(i == 1) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++;
   }
   If(i == 2) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++;
   }
   If(i >= 3) {
      Print(s: "They ran out!");
   }
}
[edit]
Crap, didn't work, I'm trying out an idea, I'll get back on this
LK873
Posts: 274
Joined: Mon Aug 30, 2004 10:54 am
Location: Ontario, Canada

Post by LK873 »

Finally got a good working way to do it:

Code: Select all

#include "zcommon.acs"

int i = 0;
  
script 254 (void)
{
    acs_execute(255,0);
    acs_execute(256,0);
    acs_execute(257,0);
    acs_execute(258,0);
}

script 255 (void)
{
   If(i == 0) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got a snack!");
      i++;
   }
}

script 256 (void)
{
   If(i == 1) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++;
   }
} 
 
script 257 (void)
{
  If(i == 2) {
     GiveInventory("HealthBonus", 5);
     Print(s: "You got another snack!");
     i++;
   }
}

script 258 (void)
{
   If(i >= 3) {
      Print(s: "They ran out!");
   }
}
killingblair
Posts: 937
Joined: Mon Oct 04, 2004 9:16 pm

Post by killingblair »

Hehe ACS, like an old girlfriend, sneaks up on you and bites you in the ass if you're not careful. :P
LK873
Posts: 274
Joined: Mon Aug 30, 2004 10:54 am
Location: Ontario, Canada

Post by LK873 »

It took me 15 minutes to come up with that, I feel stupid :P
User avatar
chaoscentral
Posts: 677
Joined: Sun Feb 27, 2005 4:32 pm
Location: Revere, MA
Contact:

Post by chaoscentral »

heh , havent tryed it out yet, ill get back to ya on that one. Now about the damned bridges... arg
User avatar
chaoscentral
Posts: 677
Joined: Sun Feb 27, 2005 4:32 pm
Location: Revere, MA
Contact:

Post by chaoscentral »

that script works perfectly... thank you so much. I owe ya one... maybe a little decorate help lol
LK873
Posts: 274
Joined: Mon Aug 30, 2004 10:54 am
Location: Ontario, Canada

Post by LK873 »

AS A MATTER OF FACT!...
I DO need DECORATE help, but I don't have AIM. Damn
User avatar
Phobus
Posts: 5984
Joined: Thu May 05, 2005 10:56 am
Location: London
Contact:

Post by Phobus »

You just put in the bridge things in Hexen format and move them up and down to fit the height you want. After that you can put a STEP sized wall texture round it and tadaa! (This is how you'd do it in DB I think, though I don't know for certain)
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

:shock: Why that script works?
AFAIK it should be equal to the initial script. And the initial script doesn't work because:

Code: Select all

script 255 (void)
{
   If(i == 0) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got a snack!");
      i++; //now i is 1
   }
   If(i == 1) { //so it's true
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++; //now i is 2
   }
   If(i == 2) { //so it's true
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++; //now i is 3
   }
   If(i >= 3) { //so it's true
      Print(s: "They ran out!");
   }
} 
So it works as if there was no IFs.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

See my comment in the bug thread you started. It's a synchronization issue. Starting a script with ACS_Execute simply doesn't execute it immediately. If you replace ACS_Execute with ACS_ExecuteResult which does execute the called script synchronously you will get the same incorrect result.
User avatar
Doomguy0505
Posts: 625
Joined: Tue Mar 29, 2005 4:53 am
Contact:

Post by Doomguy0505 »

Code: Select all

script 255 (void) 
{ 
   If(i == 0) { 
      GiveInventory("HealthBonus", 5); 
      Print(s: "You got a snack!"); 
      i++; //now i is 1 
      terminate;
   } 
   If(i == 1) { //so it's true 
      GiveInventory("HealthBonus", 5); 
      Print(s: "You got another snack!"); 
      i++; //now i is 2
      terminate; 
   } 
   If(i == 2) { //so it's true 
      GiveInventory("HealthBonus", 5); 
      Print(s: "You got another snack!"); 
      i++; //now i is 3 
      terminate;
   } 
   If(i >= 3) { //so it's true 
      Print(s: "They ran out!"); 
      terminate;
   } 
} 
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

This is better, isn't it? ;)

Code: Select all

//not tested
script 255 (void)
{
   if(i == 0) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got a snack!");
      i++;
   }
   else if(i == 1 || i == 2) {
      GiveInventory("HealthBonus", 5);
      Print(s: "You got another snack!");
      i++;
   }
   else {
      Print(s: "They ran out!");
   }
}
But I think chaoscentral uses LK873's script (and doesn't need our answers)
Locked

Return to “Editing (Archive)”