function error??

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

function error??

Post by gundamwing84 »

hey guys im installing a .createnpc referenced off the 99 distro into my shard. my shard is fully latest 99 compatible and all, but im having an error i know nothing about..because it doesnt tell me anything????

this is the error im getting from ecompile:

Code: Select all

Compiling: D:/shard/Broken Blade/pkg/commands/seer/createnpc.src
File: D:/shard/Broken Blade/pkg/utils/gumps/include/gumps.inc, Line 335
Error reading function
File: D:/shard/Broken Blade/pkg/utils/gumps/include/gumps.inc, Line 335
Compilation failed.
this is the gumps.inc function:

Code: Select all

function XGFError(text, log:=0)
	if ( log )
		SysLog("Gump Error:: "+text);
	endif

	return error{"errortext":=text};
endfunction
this is the function that calls function:

Code: Select all

function GFGetCfgConst(elem_name, prop_name)
	var cfg := ReadConfigFile(":gumps:GumpInfo");
	if ( cfg.errortext )
		return XGFError("GFGetCfgConst():: Unable to open GumpInfo.cfg -> "+cfg.errortext);
	endif

	var elem := cfg[elem_name];
	if ( elem.errortext )
		return XGFError("GFGetCfgConst():: Unable to find GumpInfo.cfg["+elem_name+"] ->"+elem.errortext);
	endif

	var value := GetConfigInt(elem, prop_name);
	if ( !value )
		return XGFError("GFGetCfgConst():: Unable to find property ["+prop_name+"] in elem ["+elem_name+"]");
	endif

	return value;
endfunction
and again the function that calls that funtion (lol):

Code: Select all

function BuildNPCGump( category_name )

	var npc_list := SortNPCs();
	if( !npc_list.Exists( category_name ))
		return error{ "errortext":="Category name does not exist." };
	endif
	npc_list := npc_list[category_name];

	var gump := GFCreateGump();
	GFPage( gump, 0 );
	GFResizePic( gump, 0, 0, GFGetCfgConst( "Defaults", "BackGround" ), 300, 480 );
	GFResizePic( gump, 15, 15, GFGetCfgConst( "Defaults", "ForeGround" ), 270, 450 );
	GFAddButton( gump, 27, 432, 4014, 4015, GF_CLOSE_BTN, BACK_BTN );
	GFTextLine( gump, 60, 432, 2100, "Back" );

	var y_pos := 60;
	var counter := 1;
	GFTextMid( gump, 15, 30, 290, 2100, "NPC List - "+category_name );
	GFPage( gump, 1 );
	foreach template in ( npc_list[category_name] )
		GFAddButton( gump, 35, y_pos+3, 2117, 2118, GF_CLOSE_BTN, template.pos );
		GFTextLine( gump, 55, y_pos, template.color, template.name );
		y_pos += 20;
		counter += 1;

		if( counter > 18 )
			counter := 1;
			y_pos := 60;
			GFAddButton( gump, 252, 430, 2648, 2649, GF_PAGE_BTN, gump.cur_page+1 );
			GFPage( gump, gump.cur_page+1 );
			GFAddButton( gump, 252, 30, 2650, 2651, GF_PAGE_BTN, gump.cur_page-1 );
		endif
		SleepMS(2);
	endforeach

	var data_elem := DFFindElement( g_datafile, Lower( category_name ), DF_CREATE );
	data_elem.SetProp( "Gump", gump );

	return gump;
endfunction

id try and fix it myself but i really have no clue whats going on because its not giving me an error and the XGFerror function is used by multiple other scripts that work fine :s

thanks,
mat :)
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: function error??

Post by CWO »

I think that error is usually thrown when you're using a reserved name for a function although I see no use of any reserved words in your script...

What I would do is comment one line at a time inside XGFError and seeing if/when the error disappears. The compiler seems to be getting confused somewhere...

Unfortunately I injected the code you've pasted into a skeleton script and it compiled so its gonna be trial and error to track this one down. The error might not even be at the location that ecompile is giving you, it may be cascaded from a different location and this is just where ecompile is tripping up...
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: function error??

Post by gundamwing84 »

hmmm i see i see i thought it was very weird to not give an error..i will do some testing, thanks CWO :)
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: function error??

Post by Yukiko »

I think CWO is right about the actual error being somewhere else. I recently had the same error and it turned out that there was a syntax error in a line of code before the line where eCompile choked up. It wasn't right before but maybe two or three lines prior to the place POL said it was. Look for incorrect punctuation like maybe two colons ( :: ) or something like that. Sometimes eCompile just can make heads nor tails of what we tell it and all it can do is throw up its hands and say "Hey! I can't do what you want me to do! Infact I can't even tell you why because I don't understand what you said." : )
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: function error??

Post by gundamwing84 »

mmm yes i see...this is gonna take alot to play around with :( already tried alot of things unfortunately..oh well perseverance wins the battle :)
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

Re: function error??

Post by andenixa »

I recommend everyone to visit the POL IRC channel http://forums.polserver.com/viewtopic.php?f=7&t=386.
There are numerous discussions where you can get and give help almost real time, learn new things and teach the others.
Post Reply