Jump to content

Script not working


zebai

Recommended Posts

Posted

I have a perk with an attached script and I've verified that the script is indeed being executed however I cannot seem to get it to work right.

 

This is a very simplified version of the script trying to heal the player, the values and everying is just for testing. Unfortunately this does absolutely nothing, it heals for crap, I've tracked the problem down to the simple fact that the player.restoreav is not parsing the variable CF, or any other variable or function I put in there. Can someone tell me why or what I'm doing wrong (if theres another way to heal using a variable amount let me know ).

 

float cf

set cf to 500

Player.RestoreAv Health cf

Posted

If i remove the variable completely and have it set to

 

player.restoreav health 500

 

It works perfectly well with as a static number, and the script is being called. The script also is changing the radiation amount slightly and that is a static number and works every time. So like I said I've verified the script is being called and that the syntax works perfectly using a static number, I just can't get it to parse a variable.

Posted

I don't have access to GECK at the moment, just throwing crazy ideas out:

 

1) Maybe try declaring the var as a "short" integer instead of a "float"?

 

2) add a % sign when calling the variable? ie player.restoreav health %cf

 

3) If all else fails, you can work around it -

 

if cf == 500

player.restoreav health 500

endif

 

if cf == 400

player.restoreav health 400

endif

 

if cf == 300

player.restoreav health 300

endif

Posted
I think I may have found the issue, it appears that you cannot use local variables when dealing with perk scripts, I made it a global and it works fine.
Posted

There are some problems with using variables in result scripts. In some situations it seems to work alright, as "ref" variables are declared and used successfully in some vanilla result scripts, but this doesn't always seem to be the case.

 

Cipscis

Posted

Local variables must be filled before use, with a set statement or a get function (in the same block it'll be used)... The use of global variables is discouraged, but you can use quest variables to emulate them. Variables in a quest script can be accessed from any place in your mod and retain values between sessions, better yet they can be of any valid type (int, float, ref...)

 

That quest may be a dummy quest, don't need even be active anymore and it's script don't need more than the variables declaration block.

 

Indeed quest script variables are like the global ones. The difference being they are restricted to your mod (unless you load the mod that have that quest together yours in the CS/GECK and make sure it's loaded in game too... what isn't a good code or modding practice).

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...