[SOLVED] "CheckInventory" fails to execute

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Fabysk
Forum Regular
Posts: 469
Joined: Sat Sep 22, 2012 8:17 pm
Location: In a house...duhh

[SOLVED] "CheckInventory" fails to execute

#1

Post by Fabysk » Sat May 27, 2017 10:48 am

While working on the new update for Despair, the PowerGum system decides to not function correctly. Before this occurrence, it was working just fine without any problems.
Spoiler: This is code (Open)

Code: Select all

 
 bool GumUse1;
 
 Script 61 (void)
 {
	If (GumUse2 == TRUE)
	{
		print(s:"");
	}
 else if(checkinventory("outofsight") >= 1 && checkinventory("money") >= 1250 )
   {
	takeinventory("OutOfSight",999);
    takeinventory("money",1250);
THINGSOUND(21, "sound/GUMBUY", 127);
Delay(40);
acs_execute(66, 0, 0, 0, 0);
GumActive2 = 1;
ThingSound(21, "sound/GUMDISP", 127);
ACS_Terminate(68,0);
}
 else if(checkinventory("LightsOn") >= 1 && checkinventory("money") >= 1250 )
   {
	takeinventory("LightsOn",999);
    takeinventory("money",1250);
THINGSOUND(21, "sound/GUMBUY", 127);
Delay(40);
acs_execute(66, 0, 0, 0, 0);
GumActive2 = 1;
ThingSound(21, "sound/GUMDISP", 127);
ACS_Terminate(68,0);
}
else if (checkinventory("money") >= 500)
{
	ACS_Execute(Random(710, 740), 0,0,0,0);
    takeinventory("money",500);
THINGSOUND(40, "sound/GUMBUY", 127);
Delay(40);
acs_execute(62, 0, 0, 0, 0);
GumActive1 = 1;
ThingSound(40, "sound/GUMDISP", 127);
ACS_Terminate(64,0);
}
}
int newRand2 = 1;
script 66 (void)
{
newRand2 = Random(1, 17);
	GumUse2 = True;//Ensure that the player can not use the PowerGum Machine while a gumball is dispensed
delay(35);
 Thing_SpawnFacing(22, randomGum[newRand2], 1, 993);
    GumActive2 = 0;
    Acs_Execute(67,0,0,0,0);

}

Script 67 (void)
{
		Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Deactivate(21);
	Delay(10);
			Thing_Activate(21);
		ThingSound(22, "sound/PWRGMCLK", 127);
	Delay(10);
	Thing_Activate(21);
	Thing_remove(993);
	Thing_remove(60);
	delay(40);
	Thing_remove(60);
	ACS_Execute(68,0,0,0,0);
	GumUse2 = FALSE;
}

Script 68 (void)
{
	Thing_remove(60);
	Thing_Activate(21);
		ThingSound(21, "sound/GUMFLASH", 127);
	Delay(20);
	Thing_remove(60);
	Thing_Deactivate(21);
	Delay(20);
	RESTART;
}
The problem here is that when Script 61 is executed, it goes straight to else if (checkinventory("money") >= 500) instead of else if(checkinventory("outofsight") >= 1 && checkinventory("money") >= 1250 ) and etc. I am still fixing this. Any assistance is appreciated.
Last edited by Fabysk on Sat May 27, 2017 11:16 am, edited 1 time in total.

User avatar
Fabysk
Forum Regular
Posts: 469
Joined: Sat Sep 22, 2012 8:17 pm
Location: In a house...duhh

Re: [SOLVED] "CheckInventory" fails to execute

#2

Post by Fabysk » Sat May 27, 2017 11:15 am

The easiest way possible for a fix.

Code: Select all

	
else if (checkinventory("money") >= 500 && checkinventory("outofsight") <= 0 && checkinventory("lightson") <= 0
	&& checkinventory("ConcealedFighter") <= 0 && checkinventory("LimitlessClip") <= 0 && checkinventory("WalkingTank") <= 0
	&& checkinventory("Vampirism") <= 0 && checkinventory("QuickPace") <= 0 && checkinventory("SubZeroInterval") <= 0
	&& checkinventory("SwiftDeath") <= 0 && checkinventory("TriggerHappy") <= 0 && checkinventory("Reinstitute") <= 0
	&& checkinventory("EnchantedPurchase") <= 0 && checkinventory("DrinksonMe") <= 0 && checkinventory("ReplenishedArsenal") <= 0
	&& checkinventory("DeathUponThem") <= 0 )
{
	ACS_Execute(Random(710, 740), 0,0,0,0);
    takeinventory("money",500);
THINGSOUND(21, "sound/GUMBUY", 127);
Delay(40);
acs_execute(66, 0, 0, 0, 0);
GumActive2 = 1;
ThingSound(21, "sound/GUMDISP", 127);
ACS_Terminate(68,0);
}
}
Just had to type in the last "else if" if the player had no PowerGums in their inventory. Included all PowerGums available.

Post Reply