Jump to content

Boolean functions always returning false


GeneralPallas

Recommended Posts

Well I did a standalone mcm plugin test and it works fine for me.

I just did 2 pages in MCM, 1 page is click to update each hold, the other just loads all holds when the page is shown.

This was the MCM quest Script I compiled and attached to a MCM quest.

 

 

scriptName TestThaneOfScript extends SKI_ConfigBase

Quest Property FJMFQuest Auto  ;Assign this property to the FavorJarlsMakeFriends quest in CK

Int[] oiToggle
String[] asHold

Event OnConfigOpen()
    Pages = New String[2]
    Pages[0] = "Test Thane Of"
    Pages[1] = "Test Thane Of All"
    oiToggle = New Int[9]
    asHold = New String[9]
    asHold[0] = "Eastmarch"
    asHold[1] = "Falkreath"
    asHold[2] = "Haafingar"
    asHold[3] = "Hjaalmarch"
    asHold[4] = "Pale"
    asHold[5] = "Reach"
    asHold[6] = "Rift"
    asHold[7] = "Whiterun"
    asHold[8] = "Winterhold"
EndEvent

Event OnPageReset(string Page)
    If Page == Pages[0]
         SetCursorFillMode(TOP_TO_BOTTOM)
        Int iCnt = oiToggle.Length
        Int idx = 0
        While (idx < iCnt)
            oiToggle[idx] = AddTextOption("Is Thane Of " + asHold[idx] + ":", "Click To Update")
            idx += 1
        EndWhile
    ElseIf Page == Pages[1]
        SetCursorFillMode(TOP_TO_BOTTOM)
        Int iCnt = oiToggle.Length
        Int idx = 0
        While (idx < iCnt)
            oiToggle[idx] = AddTextOption("Is Thane Of " + asHold[idx] + ":", isThaneOf(asHold[idx]))
            idx += 1
        EndWhile
    EndIf
EndEvent

Event OnOptionSelect(Int Option)
    If CurrentPage == Pages[0]
        Int idx = oiToggle.Length
        While idx
            idx -= 1
            If oiToggle[idx] == Option
                SetTextOptionValue(Option, isThaneOf(asHold[idx]))
                idx = 0
            EndIf
        EndWhile
    EndIf
EndEvent

Bool Function isThaneOf(String sHold)
    FavorJarlsMakeFriendsScript FJMFS = FJMFQuest As FavorJarlsMakeFriendsScript
    If (sHold == "Eastmarch") && (FJMFS.EastmarchImpGetOutofJail > 0 || FJMFS.EastmarchSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Falkreath") && (FJMFS.FalkreathImpGetOutofJail > 0 || FJMFS.FalkreathSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Haafingar") && (FJMFS.HaafingarImpGetOutofJail > 0 || FJMFS.HaafingarSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Hjaalmarch") && (FJMFS.HjaalmarchImpGetOutofJail > 0 || FJMFS.HjaalmarchSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Pale") && (FJMFS.PaleImpGetOutofJail > 0 || FJMFS.PaleSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Reach") && (FJMFS.ReachImpGetOutofJail > 0 || FJMFS.ReachSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Rift") && (FJMFS.RiftImpGetOutofJail > 0 || FJMFS.RiftSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Whiterun") && (FJMFS.WhiterunImpGetOutofJail > 0 || FJMFS.WhiterunSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Winterhold") && (FJMFS.WinterholdImpGetOutofJail > 0 || FJMFS.WinterholdSonsGetOutofJail > 0)
        Return True
    EndIf
    Return False
EndFunction

 

I really can't see where your going wrong.

 

Edit:

Maybe try put the FJMFQuest property and isThaneOf() function in your ConfigMenu script instead of a separate script?

http://nsae02.casimages.net/img/2015/01/18/150118033915257841.jpg

Edited by smashly
Link to comment
Share on other sites

Really the only difference between mine and yours is that my function is in it's own script (that way I can use it somewhere else for a quest I'm working on as well).

 

My MCM Menu

 

Scriptname ConfigMenu extends SKI_ConfigBase

RKCheckThaneStatusScript Property thaneCheck Auto Hidden

event OnPageReset(string page)
    if (page == "Hold Status")
        ; Add page 1 options
		SetCursorFillMode(TOP_TO_BOTTOM)
		
		If ( thaneCheck.isThaneOf("Eastmarch") )
			AddTextOption("Eastmarch", "Thane")
		Else
			AddTextOption("Eastmarch", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Falkreath") )
			AddTextOption("Falkreath", "Thane")
		Else
			AddTextOption("Falkreath", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Haafingar") )
			AddTextOption("Haafingar", "Thane")
		Else
			AddTextOption("Haafingar", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Hjaalmarch") )
			AddTextOption("Hjaalmarch", "Thane")
		Else
			AddTextOption("Hjaalmarch", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Pale") )
			AddTextOption("Pale", "Thane")
		Else
			AddTextOption("Pale", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Reach") )
			AddTextOption("Reach", "Thane")
		Else
			AddTextOption("Reach", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Rift") )
			AddTextOption("Rift", "Thane")
		Else
			AddTextOption("Rift", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Whiterun") )
			AddTextOption("Whiterun", "Thane")
		Else
			AddTextOption("Whiterun", "Citizen")
		EndIf
		
		If ( thaneCheck.isThaneOf("Winterhold") )
			AddTextOption("Winterhold", "Thane")
		Else
			AddTextOption("Winterhold", "Citizen")
		EndIf
	
    elseIf (page == "Salary Config")
        ; Add page 2 options
    endIf
endEvent

 

 

 

My Function Script

 

 

 

Scriptname RKCheckThaneStatusScript extends Quest

Quest Property FJMFQuest Auto  ;Assign this property to the FavorJarlsMakeFriends quest in CK

Bool Function isThaneOf(String sHold)
	FavorJarlsMakeFriendsScript FJMFS = FJMFQuest As FavorJarlsMakeFriendsScript
	If sHold == "Eastmarch"
		If FJMFS.EastmarchImpGetOutofJail > 0 || FJMFS.EastmarchSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Falkreath"
		If FJMFS.FalkreathImpGetOutofJail > 0 || FJMFS.FalkreathSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Haafingar"
		If FJMFS.HaafingarImpGetOutofJail > 0 || FJMFS.HaafingarSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Hjaalmarch"
		If FJMFS.HjaalmarchImpGetOutofJail > 0 || FJMFS.HjaalmarchSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Pale"
		If FJMFS.PaleImpGetOutofJail > 0 || FJMFS.PaleSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Reach"
		If FJMFS.ReachImpGetOutofJail > 0 || FJMFS.ReachSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Rift"
		If FJMFS.RiftImpGetOutofJail > 0 || FJMFS.RiftSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Whiterun"
		If FJMFS.WhiterunImpGetOutofJail > 0 || FJMFS.WhiterunSonsGetOutofJail > 0
			Return True
		EndIf
	ElseIf sHold == "Winterhold"
		If FJMFS.WinterholdImpGetOutofJail > 0 || FJMFS.WinterholdSonsGetOutofJail > 0
			Return True
		EndIf
	EndIf
	Return False
EndFunction

 

 

 

 

Edit: Sorry, just saw your edit. I'll try that real quick and see if it makes a difference.

Link to comment
Share on other sites

Based on what you showed, this works for me:

Scriptname ConfigMenu extends SKI_ConfigBase

Quest Property FJMFQuest Auto  ;Assign this property to the FavorJarlsMakeFriends quest in CK

String[] asHold

Event OnConfigOpen()
    Pages = New String[2]
    Pages[0] = "Hold Status"
    Pages[1] = "Salary Config"
    asHold = New String[9]
    asHold[0] = "Eastmarch"
    asHold[1] = "Falkreath"
    asHold[2] = "Haafingar"
    asHold[3] = "Hjaalmarch"
    asHold[4] = "Pale"
    asHold[5] = "Reach"
    asHold[6] = "Rift"
    asHold[7] = "Whiterun"
    asHold[8] = "Winterhold"
EndEvent

Event OnPageReset(string Page)
    If Page == Pages[0]
         SetCursorFillMode(TOP_TO_BOTTOM)
        Int iCnt = asHold.Length
        Int idx = 0
         While (idx < iCnt)
            If isThaneOf(asHold[idx])
                AddTextOption(asHold[idx], "Thane")
            Else
                AddTextOption(asHold[idx], "Citizen")
            EndIf
            idx += 1
        EndWhile
    ElseIf Page == Pages[1]
        ;Add page 2 options
    EndIf
EndEvent

Bool Function isThaneOf(String sHold)
    FavorJarlsMakeFriendsScript FJMFS = FJMFQuest As FavorJarlsMakeFriendsScript
    If (sHold == "Eastmarch") && (FJMFS.EastmarchImpGetOutofJail > 0 || FJMFS.EastmarchSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Falkreath") && (FJMFS.FalkreathImpGetOutofJail > 0 || FJMFS.FalkreathSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Haafingar") && (FJMFS.HaafingarImpGetOutofJail > 0 || FJMFS.HaafingarSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Hjaalmarch") && (FJMFS.HjaalmarchImpGetOutofJail > 0 || FJMFS.HjaalmarchSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Pale") && (FJMFS.PaleImpGetOutofJail > 0 || FJMFS.PaleSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Reach") && (FJMFS.ReachImpGetOutofJail > 0 || FJMFS.ReachSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Rift") && (FJMFS.RiftImpGetOutofJail > 0 || FJMFS.RiftSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Whiterun") && (FJMFS.WhiterunImpGetOutofJail > 0 || FJMFS.WhiterunSonsGetOutofJail > 0)
        Return True
    ElseIf (sHold == "Winterhold") && (FJMFS.WinterholdImpGetOutofJail > 0 || FJMFS.WinterholdSonsGetOutofJail > 0)
        Return True
    EndIf
    Return False
EndFunction
Link to comment
Share on other sites

If for example you have another part of your mod that also has a quest and you want to access the isThaneOf function in your ConfigMenu script then you can assign a Quest Property that points to your MCM quest in the other script.

 

Then use that property as the ConfigMenu script to call the function, the same method as you used to call the property in the FavorJarlsMakeFriends script to call EastmarchImpGetOutofJail to get its value.

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the delayed response, I just started a new job and wasn't able to do any testing until today. By doing it the way you did above I was able to get my MCM Menu working. I am; however, still having issues with the quest.

 

If for example you have another part of your mod that also has a quest and you want to access the isThaneOf function in your ConfigMenu script then you can assign a Quest Property that points to your MCM quest in the other script.

 

Then use that property as the ConfigMenu script to call the function, the same method as you used to call the property in the FavorJarlsMakeFriends script to call EastmarchImpGetOutofJail to get its value.

 

As you can see in Fragment_7 I have a Quest property called MCMMenuQuest asn I'm using it to call the ConfigMenu script in order to use the isThaneOf function. I've got the property created at the end of the script.

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 8
Scriptname RKThaneSkyforge_QuestScript Extends Quest Hidden

;BEGIN ALIAS PROPERTY Letter
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Letter Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Jarl
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Jarl Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY HoldCity
;ALIAS PROPERTY TYPE LocationAlias
LocationAlias Property Alias_HoldCity Auto
;END ALIAS PROPERTY

;BEGIN FRAGMENT Fragment_5
Function Fragment_5()
;BEGIN CODE
SetObjectiveCompleted(20)

; Change Eorlund's chest so he starts selling Skyforge weapons
RKThaneSkyforgeCheck.SetValue(0)
EorlundVendorChest.AddItem(RKThaneSkyforgeSteelSet)
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_7
Function Fragment_7()
;BEGIN CODE
; Start the quest

ConfigMenu thaneCheck = MCMMenuQuest As ConfigMenu

If ( thaneCheck.isThaneOf("Whiterun") )
   Debug.Notification("You are the Thane of Whiterun")
  SetStage(10)
EndIf
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_3
Function Fragment_3()
;BEGIN CODE
SetObjectiveDisplayed(20)
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_6
Function Fragment_6()
;BEGIN CODE
; This places the letter at the player's feet as soon as this stage starts which can be bad
; if the player looks down immediately and sees it. A better solution would be to move it
; somewhere else away from the player so the player can't see it

alias_Letter.ForceRefTo(Game.GetPlayer().PlaceAtMe(Letter))
(WICourier as WICourierScript).addAliasToContainer(alias_Letter)

Debug.Notification("Letter Given to Courier")
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Quest Property WICourier  Auto  

Book Property Letter  Auto
GlobalVariable Property RKThaneSkyforgeCheck Auto

ObjectReference Property EorlundVendorChest  Auto  

LeveledItem Property RKThaneSkyforgeSteelSet  Auto

Quest Property MCMMenuQuest Auto

Am I calling this quest correctly in order to get the function's return value?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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