ACS TakeInventory not taking the right value.

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.
Locked
User avatar
SFJake
Posts: 531
Joined: Sat Nov 03, 2007 11:28 am

ACS TakeInventory not taking the right value.

Post by SFJake »

Since my mod has a lot of levels, I wanted to make a simple scripts that decides, based on your levels, how much XP is required, and do all that leveling stuff, instead of making them one by one.

My problem? It levels up fine (the first level needs 100 XP, 99 doesn't trigger it, 100 does), and it uses the same variable to remove XP. However, instead of removing 100 XP, it removes 217.

Code: Select all

script 997 ENTER
{
if (level <= 0)
	{
	GiveInventory ("SFLevel", 1);
	delay(1);
	}


exp = CheckInventory ("SFXP");
level = CheckInventory ("SFLevel");
newlevel = level+1;

if (level >= 0 && level < 21)
	{
	addexp = 0;
	pastlevel = 0;
	multexp = 100;
	}
else if (level >= 20 && level < 41)
	{
	addexp = 2000;
	pastlevel = 20;
	multexp = 200;
	}

requiredexp = addexp+((level-pastlevel)*multexp);

if (exp >= requiredexp)
	{
	GiveInventory ("SFLevel", 1);
	GiveInventory ("SFSkillPoint", 5);
	TakeInventory ("SFXP", "requiredexp");
	Print(s:"You have reached Level \cj", d:newlevel);
	delay(1);
	}

delay(35);
Restart;
}
I'm not getting it. Like, at all.
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: ACS TakeInventory not taking the right value.

Post by Isle »

take the quotes off "requiredexp" in takeinventory(), it's not a string
Worst
Posts: 115
Joined: Sat Apr 28, 2007 5:29 am
Location: finland
Contact:

Re: ACS TakeInventory not taking the right value.

Post by Worst »

when you use the quotation marks, it ends up as a string in the stringtable, and when used as an argument there, it returns its index within the table, which probably just happened to be 217.
User avatar
SFJake
Posts: 531
Joined: Sat Nov 03, 2007 11:28 am

Re: ACS TakeInventory not taking the right value.

Post by SFJake »

Oh... Well, thanks, that explains it, not that I really get it. I thought the quotation marks had to be used for it to be read correctly since its not a number. Thats called getting used to decorate functions like A_Jump :/
Locked

Return to “Editing (Archive)”