GetMenuFloatValue and XML

Post » Thu Nov 12, 2009 8:58 pm

I'm trying to alter a script from Oblivion XP to add a condition. I thought it was easy, but of course it is not. The script below is what happens when you click on a button in the stats menu to level up once you have enough experience points. The whole gold condition thing was added by me (set pgold to a value depending on player level, if player has enough gold remove gold and show level up menu, otherwise messagebox).

if ( getActiveMenuMode == 1003 )	let tempFloat := getMenuFloatValue "stat_layout\stat_background\stat_p1\ObXP_level_marker\_value_scrolled_to" 1003	if ( tempFloat > 0 )            set pgold to (player.getlevel + 1) * (player.getlevel + 1) * 25              if player.getitemcount gold001 >= pgold                player.removeitem gold001 pgold            	setMenuFloatValue "stat_layout\stat_background\stat_p1\ObXP_layout\_levelprogress" 1003 10 		let ObXPSettings.showLevelUp := 1		CloseAllMenus              else                      messagebox "You need %.0f gold to level up!", pgold                ; here I tried several things to make the messagebox appear only once and still keep the level up button intact                    endif	endifendif


If the player has enough gold everything works fine. The gold is removed and the level up menu appears. But if he doesn't have enough gold the script doesn't work as expected. No matter what I do, either the messagebox gets stuck in a loop (if you press 'ok' it immediately pops up again) or the level up button ceases to work another time once the message box came up, which means you can't level up anymore. I tried the following:

1. set tempFloat to 0 after the messagebox. Doesn't work, it seems there is a variable set inside the xml file when you click on the button and when the script runs the next time tempFloat is immediately set to > 0.

so I thought I could maybe add this after the messagebox instead...

2. setMenuFloatValue "stat_layout\stat_background\stat_p1\ObXP_level_marker\_value_scrolled_to" 1003 0

That gets rid of the messagebox problem (it comes up once only), but afterwards clicking on the level up button does nothing. I think this is the correct approach (setting a variable in the xml file to the correct value), but I have no idea which variable\value is the correct one.

So I downloaded an xml editor and opened the xml file. I found the parts that the script points to, but I can't see any variables there or anything that makes sense to me. I also looked through the xml file and scripts to find the trigger for the level up button, but no luck. Here is the part of the xml file that the script utilizes:

							 &generic; 					 &false; 					 1 					 1 					 0 					 0 					<_value_scrolled_to>																				 1 																							 99 																											 1 																							 100 																										 0 						 1 										 3 				


Does anyone have an idea how to keep the button intact and still have the messagebox pop up once only each time you click on the button.?
User avatar
Ludivine Poussineau
 
Posts: 3353
Joined: Fri Mar 30, 2007 2:49 pm

Post » Fri Nov 13, 2009 8:06 am

IIRC a float can't ever be exactly zero, and comparisons are slightly fuzzy anyway. Instead of comparing to 0 the way you are now, try a 0.4 or something appropriate to the scale of values represented. (I'm guessing that the value is rounded to the nearest whole percent, so 0.5 would show as 1)

I'm assuming that value represents the percentage progress to the next level, and if so, you never get an exact zero there. At each level of each skill or stat you can't get exactly the experience to match the threshold, so you overshoot a little, even if it's not enough to show a whole percent on the display after the level-up. It might not even be zero at the start of the game!

Can you explain what this condition is intended to do? It looks like you're allowing them to purchase a level only if they have absolutely no experience at all.
User avatar
Rachel Hall
 
Posts: 3396
Joined: Thu Jun 22, 2006 3:41 pm

Post » Fri Nov 13, 2009 5:38 am

Ah no, the tempFloat variable was in the script right from the start. I only added the gold requirement. Since the script triggers the level up menu when you click on the level up button (where you can distribute your skill and attribute points) I'd say that tempFloat becomes larger than 0 if the button was pressed. But that is handled inside the xml file and I don't know where to look. Setting tempFloat to 0 in the script doesn't work, because the variable is still larger than 0 in the xml file and gets reset immediately. If I use SetMenuFloatValue to set the variable that tempFloat holds to 0 the messagebox comes up once only, but the level up button is disabled. I can still hear the click sound when I click on it, but nothing happens.

EDIT: I also tried to set tempFloat or the xml value to -1 btw.
User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am


Return to IV - Oblivion