[Help] MessageBox

Post » Mon Mar 15, 2010 7:14 am

Hello! I m new on scripting in oblivion...
I experiment on how to make a messagebox that will give npc stats back to player.
They only problem is that i get no number but only the variable letters as text.

For example i made the following script

---------------------------------------
scriptname ABCD

short lev

short hp
short hm
short mp
short mm
short fp
short fm

Begin onadd

set lev to getlevel
set mm to getbaseactorvalue magicka
set mp to getav magicka
set hm to getbaseactorvalue health
set hp to getav health
set fm to getbaseactorvalue fatigue
set fp to getav fatigue

messagebox "Level %.0f, Health %0.f / %0.f, Magicka %0.f / %0.f, Fatigue %0.f / %0.f" lev hp hm mp mm fp fm

end
--------------------------------------

The result i get is: Level 0, Health 0 / 0, Magicka 0 / 0 etc....

if i put %v instead of %0.f the message i get is: Level v, Health v / v, Magicka v / v etc....

I really tried everything... but i cant understand why this happens.
Every help will be grateful
Thanks
User avatar
Ray
 
Posts: 3472
Joined: Tue Aug 07, 2007 10:17 am

Post » Mon Mar 15, 2010 4:55 am

You need a reference, otherwise the script will look for the actor values of the object you put it on. Since you have an OnAdd block I guess it is an item. Since items don't have any of the values you listed the script will return 0 for all the values.

You could use a ref and getcontainer to get the reference of the NPC you add the item to. Like:

ref target

set target to getcontainer

set lev to target.getlevel
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Mon Mar 15, 2010 4:47 am

Thanks you very much, that worked for me.
If you will, can you plz tell me how i can get that player's class?
I was thinking of...

ref class
set class to target.getclass
textrurebox "%n = class" class

:S But it doesnt work :P
User avatar
Heather Kush
 
Posts: 3456
Joined: Tue Jun 05, 2007 10:05 pm

Post » Mon Mar 15, 2010 12:03 am

I made the following script that pops up a menu on player when talking with an npc.
Everything is running good but i get the following problem
I want to make it appear to me the "menu20" or "menu21" or "menu22" and when i finish and press [done] to get me back to "button20" "button21" "button22" screen.
Instead of doing this, my script gives me loops all over the "button20" "button21" "button22" screen, again and again.
I wander if it shows me the menus20,21,22 and fast gets back to the buttons screen. I m not sure, some mistake there is here but i can find it.
Can you see it?

scriptname XXX

int button
int skilltab
int buttonPressed

Begin OnAdd

messagebox "What do you want to know of me?" "Button10" "Button11" "Button12" "Done"
set buttonPressed to 1
end

begin menumode
if buttonPressed == 1
set button to getbuttonpressed

if button == 0
messagebox "Menu10"
set buttonPressed to 0

elseif button == 1
messagebox "Menu11"
set buttonPressed to 0

elseif button == 2
set buttonPressed to 2

elseif button == 3
set buttonPressed to 0

endif
endif
end

begin menumode
if buttonPressed == 2
messagebox "Press a button to get the skill" "Button20" Button21" Button22" "Done"
set buttonPressed to 3
endif
end

begin menumode
if buttonPressed == 3
set skilltab to getbuttonpressed

if skilltab > -1
if skilltab == 0
messagebox "Menu20"
set buttonPressed to 2
elseif skilltab == 1
messagebox "Menu21"
set buttonPressed to 2
elseif skilltab == 2
messagebox "Menu22"
set buttonPressed to 2
elseif skilltab == 3
set buttonPressed to 0
endif
endif

endif
end
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am


Return to IV - Oblivion