Show me string to int script
Submitted by whomisold on Fri, 2013-05-31 14:59 | ||
Here is my last failed attempt to retrieve the string for 'Min Damage' and convert it to a useable integer for simple math stuff.
{ UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_min_damage_value", "character_main_tab" ) ); string tmp1$ = "oops"; //defining the variable type before use } forums: |
||
» |
Get/check once fubi.log for the available functions and the classes they belong too.
To get a number from an UI text field you can try this:
But there's another way to find out the damage since you will need the actor anyway to find out his attack speed:
Nonetheless I hope nobody is going to trust this DPS value blindly. Finally combative abilities are co-determined too by criticals, areas of damage, number of (spell) projectiles, chances to bleed/ignite/stun/freeze, etc. - unfortunately to express such things with a number could turn out to be rather difficult... :o
The number I want displayed is just for quick comparison. I am running low on junk mail scraps from penciling the calc.
Again, my thanks for exceeding my request. Got some more thinking to do with your suggestions.
As you can see, I blended KG's ideas.
I wanted to check the mages too, but the 'offensive' version of ?getselectedweaponorspell seems to be broken in that it only returns for ranged and melee weapon. Perhaps it has an internal use but not one instance is it used for scripted skrit.
The function is called via a small defined rollover window over the 'DPS' text display block.
Not perfect but functionally satisfying for my purposes. Just got to play thru till I get a dualist for final testing.
ShowDPS$()
{
float dps$;
string tmp$;
float interval$;
goid char$ = UIPartyManager.GetSelectedCharacter();
if ( char$.IsValid )
{
go weapon_go$ = char$.Go.Inventory.SelectedWeaponOrSpell;
if ( weapon_go$ != NULL )
{
if ( weapon_go$.IsSpell )
{
interval$ = weapon_go$.Magic.CastReloadDelay;
}
else
{
interval$ = CalcTotalWeaponSpeed$( char$.Go, weapon_go$ );
}
if ( interval$ > 0.0 )
{
UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_min_damage_value", "character_main_tab" ) );
uiText$.GetText( tmp$ ); // this will copy the text into text_num$
int min$ = Stringtool.GetDelimitedInt(tmp$,0);
UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_max_damage_value", "character_main_tab" ) );
uiText$.GetText( tmp$ ); // this will copy the text into text_num$
int max$ = Stringtool.GetDelimitedInt(tmp$,0);
dps$ = ( min$ + max$ ) * 0.5 / interval$;
StringTool.Assignf( tmp$, "%f", dps$ );
SetUITextText$( "character_main_tab", "text_DPS_value", tmp$ );
}
}
}
}