Basic Scripting Help

Post » Wed Mar 23, 2011 11:00 am

I'm having trouble getting a script to work and I haven't the slightest idea of what I'm doing wrong. I have a conversation topic, which is working fine in game. The Result End of one of the topics has this:
short iHealthSet iHealth to Player.GetActorValue HealthShowMessage despDebugHealth iHealth

The message is defined as:
Player.Health = %g


In game, the result is always a zero, no matter how I set up the message or define the variable. I'm even more puzzled, because I have another topic Result End as this:
set despExperience to despExperience + 1ShowMessage despDebugExp despExperience

This message is defined as:
despExperience = %g

This message always correctly displays a 1.

I'm at a loss as to why I can't get it working. Do actor functions not work properly inside topic scripts, perhaps? If this is true, is there some way to execute a script from some other location, for example an "execute" or "startscript" command?

Any help is greatly appreciated. If I can't even get this to work, I'm wondering why I'm bothering to try at all.


Rig
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Wed Mar 23, 2011 1:29 am

Except for a few types of result script that can make use of "ref" variables, variables declared in result scripts can't be assigned values. There won't be a warning or an error - they'll just keep their initial value of 0. You'll need to declare a variable elsewhere, such as in a quest script or as a global variable, and access it remotely from your result script.

Cipscis
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Wed Mar 23, 2011 3:50 am

As cipscis says - - do not define variables in general within result scripts. Find yourself a quest script or something and define your variable in there, and then call it like, MyQuest.HappyVariable.
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Wed Mar 23, 2011 1:00 am

Excellent! Thank you very much for your help.

Rig
User avatar
Emzy Baby!
 
Posts: 3416
Joined: Wed Oct 18, 2006 5:02 pm


Return to Fallout 3