last compile error! (yewww!)

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

last compile error! (yewww!)

Post by gundamwing84 »

ok so the last one is a real toughy...(for me at least :s)

so this is with various scripts but i will just give one as usual because its the same problem in all of them

im really baffled with this because i cant find anything like it in any modules in any core :(

ecompile error:

Code: Select all

Compiling: d:/shard2/Broken Blade/pkg/skills/craftingskills/blacksmithy/make_blacksmith_items.src
Non-identifier declared as a variable: 'max'
Token: Func(6,1): max
Error compiling statement at d:\shard2\Broken Blade\pkg\skills\craftingskills\blacksmithy\make_blacksmith_items.src, Line 93
Error in function 'MakeBlacksmithyItems', File: d:\shard2\Broken Blade\pkg\skills\craftingskills\blacksmithy\make_blacksmith_items.src, Line 93

Error in function 'MakeBlacksmithyItems'.
File: d:\shard2\Broken Blade\pkg\skills\craftingskills\blacksmithy\make_blacksmith_items.src, Line 93
the script part:

Code: Select all

	var characterx := character.x;
	var charactery := character.y;
	var max := CINT (material.amount/material_needed);
	if (!max)
		SendSysMessage (character, "You don't have enough material to make that!");
		return;
	elseif (max > 10)
		max := 10;
	endif
it seems to me the variable max hasnt been declared properly but i cant gather why...i cant see any problems with it :s

full function:

Code: Select all

function MakeBlacksmithyItems (byref character, byref hammer, byref material)
	if (!SearchForAnvilInArea (character) )
		SendSysmessage (character, "You must be near an anvil to make anything.");
		return;
	endif

	if (!CheckSkillForDifferentMetals (character, material.objtype) )
		SendSysmessage (character, "You have no chance to successfully work with that metal.");
		return;
	endif

	//calls the SelectWhatToMakeFromMenu function found in makemenu.inc, in /scripts/include
	var smith_cfg_file := ReadConfigFile ("blacksmithy");
	var chosen_item := SelectWhatToMakeFromMenu (character, "mainmenu", smith_cfg_file, GetAttribute (character, ATTRIBUTEID_BLACKSMITHY), material.amount, "Blacksmithy:" );
	if (!chosen_item)
		SendSysmessage (character, "Canceled.");
		return;
	endif

	//find the item in blacksmithy.cfg file
	var selection := FindConfigElem (smith_cfg_file, chosen_item);
	if (!selection)
		SendSysMessage (character, "That was an invalid selection");
		return;
	endif

	var material_needed := CINT (selection.material);
	var item_skill := CINT (selection.skill);
	var time_delay := CINT (selection.time);
	var item_name := selection.name;
	SendSysMessage(character, "(skill: " + item_skill + ", Ingots: " + material_needed + ")");

	//save the character's position and ask them how many they want to make
	var characterx := character.x;
	var charactery := character.y;
	var max := CINT (material.amount/material_needed);
	if (!max)
		SendSysMessage (character, "You don't have enough material to make that!");
		return;
	elseif (max > 10)
		max := 10;
	endif
	var items_to_make := CINT (Sendtextentrygump (character, "How many do you want to make?:", 
				TE_CANCEL_DISABLE, TE_STYLE_NORMAL, 10, "(Max: " + max + ", 0 to cancel)"));
	if (!items_to_make)
		SendSysMessage (character, "Canceled.");
		return;
	endif

	//save the character's position and ask them if they want to autoloop
	var found_material, autoupgrade := 0;
	if (selection.hasquality)
		autoupgrade := 1;
		SendSysmessage (character, "Target the ingots to use to upgrade:");
		SendSysmessage (character, "(Press Esc. key to create item but not upgrade it)");
		found_material := Target (character);
		if (!found_material)
			autoupgrade := 0;
		else
			if (!IsIngot (found_material.objtype) )
				SendSysMessage (character, "That's not an ingot!");
				return;
			endif
			if (!ReserveItem (found_material) )
				SendSysMessage (character, "You cannot use that right now.");
				return;
			endif
			if (!Accessible (character, found_material) )
				SendSysMessage (character, "You can't reach that.");
				return;
			endif
			if (found_material.amount < material_needed)
				SendSysMessage (character, "You need " + material_needed + " ingots.  That's only " + found_material.amount + "!");
				return;
			endif
		endif
	endif

	var created_item;
	repeat
		created_item := 0;
		for i := 1 to time_delay
			PlaySoundEffect (character, SFX_ANVIL);
			sleep (2);
		endfor
		PlaySoundEffect (character, SFX_ANVIL);

		if (!CheckSkill (character, SKILLID_BLACKSMITHY, item_skill, 0))
			var lossamount := RandomInt (CINT ( material_needed/3) )+1;
			SubtractAmount (material, lossamount);
			SendSysmessage (character, "You fail, destroying some ingots.");
		else
			created_item := CreateItemInBackpack (character, chosen_item, 1);
			if (!created_item)
				PrintTextAbovePrivate (character, "*Your backpack is full!*", character);
				return;
			endif

			SendSysMessage (character, "You place the item in your backpack.");

			//set the color
			if (material.color)
				created_item.color := material.color;
			endif
			SubtractAmount (material, material_needed);
			created_item.buyprice := 0;
			
			if (autoupgrade)
				var upgrade_material := CINT (material_needed/2);
				if (found_material.amount < upgrade_material)
					SendSysMessage (character, "You don't have enough material to upgrade that item!");
					return;
				endif
				
				var upgrade_skill := item_skill + 15;
				if (upgrade_skill > 110)
					upgrade_skill := 110;
				endif
				if (upgrade_skill >= GetAttribute (character, ATTRIBUTEID_BLACKSMITHY) + 20)
					SendSysMessage (character, "Your skill is too low to upgrade that item.");
					return;
				endif
				
				var upgrade_timedelay := time_delay - 1;
				if (!upgrade_timedelay or upgrade_timedelay < 0)
					upgrade_timedelay := 1;
				endif

				if (characterx != character.x or charactery != character.y)
					SendSysMessage (character, "You stop smithing.");
					return;
				endif

				PerformBlacksmithyItemUpgrade (character, created_item, found_material, upgrade_material,
						SKILLID_BLACKSMITHY, upgrade_skill, upgrade_timedelay, item_name);
			endif
		endif
		
		if (characterx != character.x or charactery != character.y)
			SendSysMessage (character, "You stop smithing.");
			return;
		endif

		// DR-03/18/02	Added check for enough material
		if ( material.amount < material_needed )
			SendSysMessage ( character, "You ran out of material." );
			return;
		endif

		if (created_item)
			items_to_make := items_to_make - 1;
		endif
		sleep (2);
	until (!items_to_make);
	SendSysMessage (character, "You stop smithing.");
endfunction
please help as this is the last error im having until there are no compile errors, then i can get to work on the warnings and then release the script pakage :D
User avatar
AsYlum
Grandmaster Poster
Posts: 115
Joined: Sun Feb 05, 2006 5:24 am

Re: last compile error! (yewww!)

Post by AsYlum »

You can't name your variables after function names ;)

Math.em
ACos
ASin
ATan
Abs
Ceil
ConstE
ConstPi
Cos
DegToRad
Floor
FormatRealToString
Log10
LogE
Max
Min
Pow
RadToDeg
Root
Sin
Sqrt
Tan
As you can see there are Min, Max functions already ;)
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: last compile error! (yewww!)

Post by gundamwing84 »

ohhh i see so i just need to change the name of the variable, thanks! you've been a great help to me today :D
Post Reply