Jump to content

GetStage() scripting error


rossjcorbett

Recommended Posts

I am having a weird scripting error. If the player chooses a specific option within a Message Box, a function with a series of if statements gets called. I can confirm that the function is getting called with a debug message, but the logic for the if statements doesn't seem to work.

 

 

 

 

 

Scriptname MTWritingTable extends ObjectReference

 

Quest Property MTQ020 Auto

Quest Property MTQ030 Auto

Quest Property MTQ030a Auto

Quest Property MTQ045 Auto

Quest Property MTQ048 Auto

Quest Property MTQ050 Auto

Quest Property MTQ051 Auto

Quest Property MTQ052 Auto

Quest Property MTQ060 Auto

Quest Property MTQ070 Auto

Quest Property MTQ080 Auto

Quest Property MTQ085 Auto

Quest Property MTQ090 Auto

Quest Property MTQ095 Auto

Quest Property MTQ100 Auto

Quest Property MTQ110 Auto

Quest Property MTQ120 Auto

Quest Property MTQ140 Auto

 

 

Message Property MTWritingDeskMessage Auto

 

bool showMessageAgain = TRUE

 

function displayMessage()

int option = MTWritingDeskMessage.show()

if option == 1

MTQ020.setstage(25)

Utility.wait(5)

elseif option == 2

MTQ030.setstage(5)

Utility.wait(5)

elseif option == 3

MTQ030a.setstage(5)

Utility.wait(5)

elseif option == 4

deliverOrnateWrit()

Utility.wait(5)

elseif option == 0

showMessageAgain = FALSE

endIf

endFunction

 

function deliverOrnateWrit()

if MTQ045.getStage() == 20

MTQ045.setStage(30)

elseif MTQ048.getStage() == 20

MTQ048.setStage(30)

elseif MTQ050.getStage() == 20

MTQ050.setStage(30)

MTQ051.setStage(30)

MTQ052.setStage(30)

elseif MTQ060.getStage() == 40

MTQ060.setstage(50)

elseif MTQ070.getStage() == 20

MTQ070.setStage(30)

elseif MTQ080.getStage() == 20

MTQ080.setStage(30)

elseif MTQ085.getStage() == 20

MTQ085.setStage(30)

elseif MTQ090.getStage() == 20

MTQ090.setStage(30)

elseif MTQ095.getStage() >= 20 && MTQ095.getStage() < 50

(MTQ095 as MTQ095QuestScript).getWrit()

elseif MTQ100.getStage() == 20

MTQ100.setStage(30)

elseif MTQ110.getStage() == 20

MTQ100.setStage(30)

elseif MTQ120.getStage() == 20

MTQ100.setStage(30)

elseif MTQ140.getStage() == 20

MTQ140.setStage(30)

else

Debug.Trace(self + "Logic failure in deliverOrnateWrit.")

endIf

endFunction

 

 

 

The script compiles and all the properties are filled correctly on the object base to which the script is attached. In the deliverOrnateWrit() function, though, the logic tree goes to else. Outputting getStage() to a debug box shows that it returns 0. Checking with sqv in the console, the quest is running and the stage is higher than 0. The logic attached to the MessageBox itself that determines which buttons will be displayed also gets a sensible return from getStage(). I've also tried making it so the script extends Furniture rather than ObjectReference (it is attached to the base object rather than each instance of it)

 

Is there something that I'm missing, like ObjectReference not being allowed to see a quest stage?

Link to comment
Share on other sites

I know little about scripting, However last time I created a script as a quest i wrote on top "extends ObjectReference" and someone told me to turn it to "extends ReferenceAlias"

 

Thanks, but this script isn't attached to a quest alias. It is attached to an object instantiated at several places in the world that checks the status of various quests and acts accordingly.

Link to comment
Share on other sites

Sometimes, when adding/removing/renaming properties in scripts, I've noticed that they don't update correctly in the esp. This can cause some odd errors about missing properties in the Papyrus log. The fix is to remove the script from the Form, then add it back, refill the properties and then save the esp again.

 

Also, I've found that roughly 1 out of 10 times when loading a save game, I'll get a lot of "none object" errors like you describe (properties not filling correctly). This seems to be a bug - I think data sometimes randomly gets misread or corrupted when loading savegames. Maybe this is one way that savegame bloat/corruption is caused? The solution was simply to restart the game and reload the save.

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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