Can't get it working..

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Can't get it working..

Post by Damien. »

Hello...

I have been trying to create a skilljournal, but there is a little problem.. while clicking a button, the foreach wont list the skills.. and I can't understand why. I have been trying to fix it testing different methods, but they always fail :(
It wont print nor send a message, therefore the showskill_function wont trigger.. what am I doing wrong?

Code: Select all

use uo;
use os;
include ":attributes:attributes";
include ":gumps:gumps";
include ":gumps:gumps_ex";

program GumpTest(who)

	var gump := GFCreateGump();
	GFDisposable(gump, 0);
	
	GFResizePic(gump, 120, 150, 2520, 450, 400);

	GFTextLine(gump, 300, 160, hue:=1050, text:="Skill Journal");	
	
	GFTextLine(gump, 195, 193, hue:=1153, text:="All skills"); 
	GFAddButton(gump, 170, 196, 2117, 2118, GF_DUMMY_BTN, 1);
	
	GFTextLine(gump, 195, 210, hue:=1153, text:="Miscellaneous"); 
	GFAddButton(gump, 170, 213, 2117, 2118, GF_DUMMY_BTN, 2);
	
	GFTextLine(gump, 195, 227, hue:=1153, text:="Combat Skills");
	GFAddButton(gump, 170, 230, 2117, 2118, GF_DUMMY_BTN, 3);
	
	GFTextLine(gump, 195, 244, hue:=1153, text:="Actions");	
	GFAddButton(gump, 170, 247, 2117, 2118, GF_DUMMY_BTN, 4);
	
	GFTextLine(gump, 195, 261, hue:=1153, text:="Lore & Knowledge");
	GFAddButton(gump, 170, 264, 2117, 2118, GF_DUMMY_BTN, 5);
	
	show_skill(who, gump, "_allskills");	

	var input := GFSendGump(who, gump);
	case (input[0])
		1: show_skill(who, gump, "_allskills");
		2: show_skill(who, gump, "_misc");
		3: show_skill(who, gump, "_combat");
		4: show_skill(who, gump, "_actions");
		5: show_skill(who, gump, "_lore");
	endcase
	
endprogram

function show_skill(who, gump, skill_type)

GFPage(gump, 1);
var y_pos := 300;
var x_pos := 400;
var counter := 0;

var getclass := GetObjProperty(who, "profession");
var config := ReadConfigFile(":professions:AllSkills");
var elem := FindConfigElem(config, (getclass["class"]+skill_type));
if(!elem)
Print("Cannot find element");
else
SendSysMessage(who, elem);
endif
var skill_list := GetConfigStringArray(elem, "Skill");
	foreach key in ( skill_list )
		GFTextLine(gump, 175, y_pos, 2100, key);
		var skill_value := GetAttributeBaseValue(who, key);
		GFTextLine(gump, x_pos, y_pos, 2100, ((skill_value)/10));
		var skill_change := GetAttributeTemporaryMod(who, key);
		if(skill_change > 0)
		GFTextLine(gump, x_pos+35, y_pos, 2100, ("(+" + (skill_change)*0.1 + ")"));
		endif
		
		counter += 1;
		y_pos += 20;
			if ( counter >= 10 && _key_iter < skill_list.Size() )
			GFAddButton(gump, 520, 490, 2706, 2707, 0, gump.cur_page+1);
			GFPage(gump, gump.cur_page+1);
			GFAddButton(gump, 520, 280, 2704, 2705, 0, gump.cur_page-1);
			counter := 0;
			y_pos := 300;
			endif
		SleepMS(2);
	endforeach	

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

Re: Can't get it working..

Post by CWO »

Is it only when you're trying to press a button? Its probably because of the GF_DUMMY_BTN. It has to be GF_CLOSE_BTN to return something.

If you're talking about the show_skill before the gump is displayed, try SendSysMessage(who, CStr(elem)); in the success part of the if.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: Can't get it working..

Post by Damien. »

ah.. so I added SendSysMessage(who, Ctr(elem)); (thanks for that :) )
I receive message: <appobj:ConfigElemRef> (what does it mean?)ingame while opening the gump and while pressing a button, but there is something that troubles me...
About the CLOSE_BTN instead of DUMMY_BTN, well yeah you're right about that one (no message will appear using DUMMY_BTN) but the problem is that I do not want to close the gump while pressing the buttons I just want to add the Show_Skill function in the gump, that will say add (gump, 1) but not close the constant (gump, 0). the thing is that I dont wanna create a new page for each skill_type to make the gump more, um, effective, but is it possible?

appreciate the help :)
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: Can't get it working..

Post by Damien. »

Oww :) Tomi told me that <appobj:ConfigElemRef> means success! So that means it DOES find the element, but the problem must be somewhere in the foreach then, because it wont list any skills... back to testing then! :]
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Can't get it working..

Post by CWO »

It is not possible to get a return without closing the gump. The only thing you can do is build each different thing in show_skill as a different page in the gump or rebuild the gump entirely and resend it every time they press the button.
Post Reply