Fetching variables from a XML file

Post » Mon Jul 11, 2011 4:16 pm

I aim to toggle the crosshair on and off by pressing a key and I plan to do so by toggling the value of a XML variable found in hudmainmenu_config.xml, part of DarnUI:

<!-- Crosshair (def. 1,0) -->	<_chvisible> 0 


_chvisible can be changed in-game within the DarnUI interface config. Can OBSE handle such a variable in some way?

ScriptName ToggleCrosshairfloat fQuestDelayTimeshort chvisibleBegin GameModeset fQuestDelayTime to .01if ( IsKeyPressed3 52 )	set chvisible to 1	Message "Crosshair is on, current value is %.0f", chvisible, 10; code to set _chvisible to 1 as wellendifif ( IsKeyPressed3 51 )	set chvisible to 0	Message "Crosshair is off, current value is %.0f", chvisible, 10; code to set _chvisible to 0 as wellendifEnd

User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm

Post » Mon Jul 11, 2011 9:06 am

Yes. Have a look at the http://obse.silverlock.org/obse_command_doc.html. See the menu functions.
User avatar
Enny Labinjo
 
Posts: 3480
Joined: Tue Aug 01, 2006 3:04 pm

Post » Mon Jul 11, 2011 4:10 am

Thanks, that's just what I was looking for : )

ScriptName ToggleCrosshairfloat fQuestDelayTimefloat chvisibleBegin GameModeset fQuestDelayTime to .01set chvisible to GetMenuFloatValue "darnui_settings\_chvisible" 1004if ( IsKeyPressed3 52 )	set chvisible to 1	SetMenuFloatValue "darnui_settings\_chvisible" 1004 1	Message "Crosshair is on, current value is %.0f", chvisible, 10endifif ( IsKeyPressed3 51 )	set chvisible to 0	SetMenuFloatValue "darnui_settings\_chvisible" 1004 0	Message "Crosshair is off, current value is %.0f", chvisible, 10endifEnd


Now I just need to optimize the code a bit, I'm going to test the ClickMenuButton function and see how it goes.

edit: ClickMenuButton doesn't seem to work this way.. am I missing something?

if ( IsKeyPressed3 37 )	ClickMenuButton "darnui_settings\_chvisible" 1004	Message "Crosshair is toggled", 10endif

User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Mon Jul 11, 2011 3:19 am

ClickMenuButton is supposed to simulate a left click on the button. "_chvisible" is not a button.

ScriptName ToggleCrosshairfloat fQuestDelayTimefloat chvisibleBegin GameModeif ( fquestdelaytime != 0.01 )	set fQuestDelayTime to .01endifif ( IsKeyPressed3 37 )	set chvisible to GetMenuFloatValue "darnui_settings\_chvisible" 1004	if ( chvisible == 1 )		SetMenuFloatValue "darnui_settings\_chvisible" 1004 0	else		SetMenuFloatValue "darnui_settings\_chvisible" 1004 1	endif	Message "Crosshair is toggled."endifEnd

User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am


Return to IV - Oblivion