Fraction rounded to 0 when set in quest stage

Post » Mon Jul 19, 2010 10:06 am

Edit: The problem went away for no apparent reason. See my last post for details. Thanks guys for your time.

Hi all, my first post on these forums, although I have been a lurker for some time and has learned much from you!

I am using a quest stage to set some default variables as per the excellent tutorial on the GECK wiki (http://geck.gamesas.com/index.php/Adding_an_Options_Menu).

I have one variable (lets call it myVariable) that I want to set to 0.5, but when I load the mod and do a "show myVariable" it has the value 0.0

If I use "set myVariable to 0.5" in the console the variable is set to 0.5 with no problem.

Setting it to 0.5 inside a "regular" script also works. It seems the problem is only when I try to set it to less than 1 in a Quest Stage scriptbox.

I have other variables set in the exact same way but to values of 1 and higher and they work fine.

Some details:
I have a quest called "myQuest"
I have a script called "myQuestScript" that is selected in myQuest
I have a script "myOtherScript" that wants to use the variables from myQuestScript

Variable declaration in myQuestScript
float myVariable

Set command in the stage 10 scriptbox of myQuest (myQuest has myQuestScript selected)
set myQuest.myVariable to 0.5

Declaration and set command in myOtherScript
float myVariable
set myVariable to myQuest.myVariable

Edit from questions below:
myQuest starts enabled
The variable is not overwritten in a different stage or by another script
It is not a rounding issue - a value of 5.5 works fine


Any help would be greatly appreciated, I'm at the edge of sanity here :banghead:

Regards,
The Nonsense Factory
User avatar
Stay-C
 
Posts: 3514
Joined: Sun Jul 16, 2006 2:04 am

Post » Mon Jul 19, 2010 12:31 am

Interesting, I never knew there was a show command. I normally always use PrintC with FOSE.

Anyway, so you have a quest stage setup with a result script that sets a variable in the attached quest script?

- Are you sure that the quest is actually getting to the correct stage to fire the result script?
- Have you tried setting the variable to a different number? Is it still 0?

I take it you are using the function "setStage"?
http://cs.elderscrolls.com/constwiki/index.php/SetStage

- Are you sure a stage after it is not resetting the variable?
- Is there something in the quest script itself which is setting the variable to 0?
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Mon Jul 19, 2010 5:55 am

Is your quest "start game enabled"? If not you would have to start the quest with the "StartQuest" command or nothing in the quest will work.

I also agreee to try setting your variable to 5.5 just to see if its working and not a rounding issue (which I doubt).
User avatar
emma sweeney
 
Posts: 3396
Joined: Fri Sep 22, 2006 7:02 pm

Post » Mon Jul 19, 2010 6:57 am

Thank you for your quick reply, mw_junkie!

Anyway, so you have a quest stage setup with a result script that sets a variable in the attached quest script?

Exactly.

- Are you sure that the quest is actually getting to the correct stage to fire the result script?

Yes, the other variables set in the same script block get their intended values. They are all above 1 though.

- Have you tried setting the variable to a different number? Is it still 0?

If set to 1 or more it successfully gets that value.

You can see why I am puzzled.

Edit:

- Are you sure a stage after it is not resetting the variable?

Stage 10 sets the quest to stage 20 after setting the variables. Stage 20 is empty. There are no other stages.

- Is there something in the quest script itself which is setting the variable to 0?

No, the variable is not used at all in the quest script, only in myOtherScript, and only to set a local copy.

Regards,
The Nonsense Factory
User avatar
Elea Rossi
 
Posts: 3554
Joined: Tue Mar 27, 2007 1:39 am

Post » Mon Jul 19, 2010 9:25 am

I think you said that the variable in question was a float but like pkleiss said if you set it to 5.5 does it keep that value or does it get set to the nearest whole number?
User avatar
Mel E
 
Posts: 3354
Joined: Mon Apr 09, 2007 11:23 pm

Post » Mon Jul 19, 2010 10:39 am

Hi pkleiss, thank you for joining the fray!

Is your quest "start game enabled"? If not you would have to start the quest with the "StartQuest" command or nothing in the quest will work.

Yes, quest starts enabled.

I also agreee to try setting your variable to 5.5 just to see if its working and not a rounding issue (which I doubt).

Just checked and 5.5 works, it is not rounded off.

Regards,
The Nonsense Factory
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm

Post » Sun Jul 18, 2010 11:46 pm

tbh I dunno. There is a lot of weird stuff that happens in the geck, most of which just doesn't seem to be logical in any way. I'm used to it by now and accept that fallout modding normally deteriorates into bodging stuff.

It could be a bug in the show function. Perhaps try doing something like this:

set varA to 0.5
set varB to 1
set varC to varA + varB

then in game do the show varC and see if it comes out as 1.5.

Personally I can't live without PrintC. With it you can put it in a script and do something like:

PrintC "varA: %.2f | varB: %.2f | varC: %.2f" varA varB varC

And in theory it should display:

varA: 0.5 | varB: 1 | varC: 1.5

Can make debugging stuff a million times easier
User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Mon Jul 19, 2010 7:29 am

I will try out your suggestions at once, mw_junkie. I will get back here with an edit after the tests!

Edit:

Interesting...

I introduced a third variable, and in the stage script I set it to the sum of myVariable (0.5) and another variable I use that has the value of 1.

The output was varA 0.5 | VarB 1.0 | VarC 1.5

I concluded that the "show" command was broken, but it also showed 0.5.

I then concluded that the changes made to print the variables were responsible (there is normally no code in that block), so I went back to the GECK and undid all my changes, saved and loaded the game again. And it still works :blink:

I can only see two options:
A ) I made a mistake somewhere that did not generate a compiler error, and that I somehow managed to fix by changing and un-changing the code.
B ) The GECK corrupted the .esp, and the issue was fixed once it managed to do a correct save - possibly triggered by swapping the code back and forth.

I am new to fallout scripting, but not to programming, so option A would really make me squirm :embarrass:

Anyway, it looks like the problem is solved, even if I have no idea why it happened. A big thanks to both of you for stepping in and trying to help, I really appreciate it!

Regards,
The Nonsense Factory
User avatar
Sharra Llenos
 
Posts: 3399
Joined: Wed Jan 17, 2007 1:09 pm


Return to Fallout 3