Jump to content

[Skyrim Modding] Displaying Global Variable (Without Checking For Conditions


Ashenfire

Recommended Posts

Surprisingly, I get mostly what you are saying. You are in general terms expressing what I was asking. I needed the correlations and reading the

creation kit wasn't enough. I just learned about the 'variable pointing to another variable', this helps me quite a bit. I grew up thinking only

numbers or strings were held in a variable. So I'm learning slowly.

 

I'm using a lever just to test values in the game when I find out that my scripts are not working.

The problem is, I use the lever to find out what is happening, with no expectations of what a value should be. I want to use the lever to observe

the uncharted territory that I am in so I can evaluate a solution.

 

My current script is trying to pass content of factions (are they 0 or 1) and to pass the content of relationship rank without checking for

every possible out come and writing a message for each condition they can be.

 

I had the globals working fine, the way I originally depicted and now the smarter way which you depicted.

Not so, with variables that are not handled by globalvariables.psc

 

The following is just a taste:

 

 

 

Scriptname leverAshenfireGetTime extends ObjectReference Conditional

import debug
import utility

miscobject property gold001 auto
bool property isInPullPosition = True Auto
GlobalVariable Property HasHirelingGV Auto
GlobalVariable Property PlayerFollowerCount auto
GlobalVariable Property HasHireling auto
Faction Property CurrentHireling Auto
faction property PotentialFollowerFaction auto
faction property CurrentFollowerFaction auto
faction property PotentialMarriageFaction auto
faction property PotentialHireling auto

EVENT OnLoad()
game.getplayer().additem(gold001, 200000664)
SetDefaultState()
endEVENT

Event OnReset()
SetDefaultState()
EndEvent

;This has to be handled as a function, since OnLoad and OnReset can fire in either order, and we can't handle competing animation calls.
Function SetDefaultState()
if (isInPullPosition)
playAnimation("FullPull")
gotoState("pulledPosition")

Else
playAnimation("FullPush")
gotoState("pushedPosition")
EndIf
EndFunction


Auto STATE pulledPosition

EVENT onActivate (objectReference triggerRef)

string HasCurrentHirelingFaction=(CurrentHireling)
string HasPotentialFollowerFaction=(PotentialFollowerFaction)
string HasCurrentFollowerFaction=(CurrentfollowerFaction)
string HasPotentialMarriageFaction=( PotentialMarriageFaction)
string HasPotentialHireling=(PotentialHireling)

Debug.notification("HasHireling #:"+ HasHireling.getValueint() )
Debug.notification("HasHirelingGV: " + HasHirelingGV.GetValueInt() )
Debug.notification("PlayerFollowerCount: " + PlayerFollowerCount.GetValueInt() )
Debug.notification("C HirelingF: " + HasCurrentHirelingFaction)
Debug.notification("PFollower F#: " + HasPotentialFollowerFaction)
Debug.notification("CFollower Fr: " + HasCurrentFollowerFaction)
Debug.notification("P Marriage,#: " + HasPotentialMarriageFaction)
Debug.notification("P Hireling#: " + HasPotentialHireling)


gotoState ("busy")
isInPullPosition = False
playAnimationandWait("FullPush","FullPushedUp")
gotoState("pushedPosition")
endEVENT
endState

STATE pushedPosition
EVENT onActivate (objectReference triggerRef)



Debug.Notification("The current time is: " + Utility.GetCurrentGameTime() + " in game days passed")
;paste this directly, it does not require setting up anyting to make it work.
gotoState ("busy")
isInPullPosition = True
playAnimationandWait("FullPull","FullPulledDown")
gotoState("pulledPosition")
endEVENT
endState

STATE busy
; This is the state when I'm busy animating
EVENT onActivate (objectReference triggerRef)
;do nothing
endEVENT
endSTATE

 

 

 

 

Link to comment
Share on other sites

So, here's what that script is doing when you activate it.

 

It gets the contents of the variable "CurrentHireling" (which is a faction variable), and tries to store that as a string in the variable "HasCurrentHirelingFaction". It will do this without complaint, but it will return [FACTION <ID [iD]>], because the game doesn't know what you want it to do when you tell it this 'thing' needs to be a word. Later, it adds the contents of this variable to a debug message.

 

"HasHireling", however, is a GlobalVariable variable. It's a variable that points to a global variable. So, you've got a box (the global variable, which contains some number) in a bigger box (the variable you named "HasHireling"). You call the contents of "HasHireling" and it returns the GV. You call "GetValue()" on those contents, and it returns the number. "Notification" automatically converts that number to a string it can display, and you're good to go. It works as expected.

 

The difference here is that the faction can't be converted to a string. Are you trying to get the number of members of those factions? If so, why? If it's to check if a particular NPC is in those factions, then you're better off adding the specific NPC as a property and checking directly.

Link to comment
Share on other sites

My biggest concern is to be able to observe the state a variable is in; without determining what I think it should be.

I want to be able to trace the conditions so I can determine whether I leave something alone, create a new script, or modify one.

 

In this case, I want to observe the value contained by any of the factions ( 0, 1, or are they another #). Once I know this, I can

determine where HasHireling is being reset.

 

I want to verify that playerfollowercount is not being reset at the wrong time. I plan on expanding playerfollowercount to be

concantenated to the number of followers that were hired by the player; and not be dismissed every time I hire one.

I am so far, at this time, looking for a way to get the values they are set to.

Link to comment
Share on other sites

The factions don't contain numbers at all is the problem. They're more like a keyword. A specific NPC may have a rank, and there are a certain number of NPCs currently in any given faction, but the faction itself doesn't contain that number. So, you need to see if there are any NPCs currently in the CurrentHireling faction, right? There's no simple way I know of to do that. The simplest way I could think of is if you know the NPC(s) that will be added to the faction, then you can have the level check if one, both, or neither are currently in the factions.

Link to comment
Share on other sites

I figured any of the factions could be set to any number. I will now look at them as a keyword.

I will play with that and see if I can view it without setting conditional statements; via GetFactionRank.

 

Also,

We set the value of currenthireling to zero or one; so I just figured we could view that state without testing it in a conditional statement.

 

What I'm attempting to do is do a blind count, not keep tabs on who actually is in the playerfollowercount / playerteammate.

I just add +1 to playerfollowercount and assign the hireling to a new faction MultipleFollowerFaction.

 

I already did that but the dialogue won't start because playerfollowercount is > 1

 

2. So then I decided to change all code that changed playerfollowercount (make sure it stayed at zero).

This allowed me to have dialogue with other hirelings after I hired one.

The problem is that I would hire my second hireling and the first hireling would update and dismiss herself, no dialogue, no notification.

 

 

 

So, to follow what changes I made in the script, I observe in the game as I play by using levers. The global stuff seems rather easy now.

 

Talking with you has saved me quite a bit of time at least. I hate starting over, I know for instance that a string can't be stored in an integer.

Its just with this new stuff (for me anyways); I don't identify what I'm dealing with efficiently. That means I end up making a fool of myself.

Edited by Ashenfire
Link to comment
Share on other sites

I think I see the problem. You're thinking the factions contain numbers because in the conditions for dialogue they're compared to numbers. Yes?

 

The thing with that is that in the dialogue, those conditions are run with either the speaker, the listener, or the player (or something else specific) in mind. So, those conditions should be checking for true or false based on whether or not the speaker is in the listed faction. Then, it compares that true or false to 1 or 0 to see if the condition is met. Since 1 and 0 can be made bools in a very straightforward way, this works as intended.

Link to comment
Share on other sites

In that case, you'll need to look at the dialogue options you choose and check the variables and functions it calls. Specifically, you're looking for functions it calls from a quest script or something similar, because that's most likely where/how the NPCs are being removed from the CurrentHireling faction. You could also look at the GV that contains how many current hirelings/followers you have and look at its Use Info (right-click it). That should list any quests using it (it'll list ANYTHING that specifically refers to it, so it may take some time to narrow down). Most likely somewhere in that list is what you need to find and remove/alter the prevent them from being removed when you add a new follower/hireling.

 

If what you're wanting to do would work from dialogue, then the reason it would work is because it's calling the condition on that particular speaker and checking if that specific NPC is in the faction the condition checks. What you need to do in order to emulate that is to pick a specific NPC on which to test, and set that Actor as a property for in the lever's script. Instead of calling the faction as a string, call "NPC.IsInFaction(CurrentHireling) as String" and that should return true or false like you're expecting. There's no way that I know of to get the current list of faction members. I've looked at various things, including the Faction functions (both on the wiki, and the undocumented ones from SKSE) and SKSE's new GameData functions (which can list every form of a given type, but Actor isn't one of those types, unfortunately).

 

If you need to do it on a lot of NPCs but you'll know which ones to begin with (you're only working with NPCs that could normally be hirelings, which can be viewed from the Creation Kit's Faction window), my best solution that comes to mind would be to add all of the possible NPCs to a formlist and then iterate through the list when the lever is pulled. When one of the actors is found to be in a faction, add their name to a string variable for that faction. When you're done iterating, call a notification with that string. If this is how you want to do it, I could write up a quick script to do this. It would only take me a few minutes. However, I'll be leaving soon, and I won't have internet again until probably Monday.

Link to comment
Share on other sites

The first part you were saying, is true. I already did that a week ago. It changes back, any changes I make. That is why I wanted the ability to observe all their behaviors before I committed to a script. I was mostly successful.

 

I just duplicated DialogueFollower & HirelingQuest; so I could entertain

what you were mentioning in the second part of your post.

 

I am planning to make a multiple follower mod, so I want it to be versatile for anyone else who makes a follower mod; where there mod

won't require adding their follower to my list.

 

I lose internet too, so I hope you are doing okay without it until Monday. I might ask you for help later. In the meantime, I will change my thinking

due to your help; and go into phase 10 of trial and error. Some of the items in Creationkit.com don't look as 'Greek' to me like they once did.

Edited by Ashenfire
Link to comment
Share on other sites

  • Recently Browsing   0 members

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