Jump to content

Photo

Unsure about interscript communication with Aliases

script properties quest alias

  • Please log in to reply
12 replies to this topic

#1
Hoamaii

Hoamaii

    Resident poster

  • Premium Member
  • 3,225 posts

Hi guys,

 

I need a second brain to figure out how to properly fill a property for InterScript communication from a dummy quest to some other quest's aliases script.

 

Here's how I'd like it to work:

 

Let's say I have one script called "MySendingInfoScript" wanting to send some bool info (true or false) to another script "MyReceivingInfoAliasScript" attached to several aliases.

 

"MyReceivingInfoAliasScript" attached to several aliases would go something like that:

Scriptname MyReceivingInfoAliasScript extends AliasReference

bool Property InfoSent = false

Event OnSomeEvent()
	If InfoSent
		DoSomeStuff()
	Else
		DoSomethingElse()
	EndIf
EndEvent

Then I need "MySendingInfoScript" to properly reference the Aliases scripts which are going to use that info. Same script attached to several Aliases, they all need to get the info. I've done something like:

Scriptname MySendingInfoScript extends MyDummyQuest 

MyReceivingInfoAliasScript Property Alias_MyAlias00 Auto
MyReceivingInfoAliasScript Property Alias_MyAlias01 Auto
MyReceivingInfoAliasScript Property Alias_MyAlias01 Auto

Event OnUpdate() ; for the sake of the example

	Alias_MyAlias00.InfoSent = true
	Alias_MyAlias01.InfoSent = true
	Alias_MyAlias02.InfoSent = true

EndEvent

Somehow, the way I fill the properties doesn't look right - I also need to reference the quest which uses these aliases, right? I can't figure out how to do that...

 

Could a kind soul help me avoid brain CTD here?...

 

A thousand thanks in advance!

 

 

 

Edit: Uh... could it be just adding something like "Alias_MyAlias00 = MyDummyQuest.GetAlias(1) as MyReceivingInfoAliasScript " to the script?



#2
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,547 posts

What you have looks right.  When filling the property there should automatically be a quest drop down and an alias drop down. Well, it depends on the object that holds the target script but in your case it should be quest and alias boxes. 

 

However, you might want to consider taking it the other way.  Storing the variable(s) on the main script, then have the alias script(s) reference the variable(s) on the main script and change it.  This would have three alias scripts each referencing the same main script, rather than one main script trying to reference three scripts and possibly getting confused on which data it should be working with.



#3
Hoamaii

Hoamaii

    Resident poster

  • Premium Member
  • 3,225 posts

Hey thanks a lot for your help, IsharaMeradin - I'm always grateful you're still "lurking" ;)

 

As you may have noticed, I don't quite have the appropriate scripting vocabulary (French here), sometimes my English fails me.

 

I'm not quite sure I entirely get what you mean by "Storing the variable(s) on the main script, then have the alias script(s) reference the variable(s) on the main script and change it" - you mean, like create a globalVariable to store the info value (true it's a bool...) and having the Alias script fetch that value?



#4
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,547 posts

Here is an example using your example and flipping it about.

Spoiler


#5
Hoamaii

Hoamaii

    Resident poster

  • Premium Member
  • 3,225 posts

Oh, right, I get it now - I didn't know it could work the other way around. That's very handy in this case if I get a lot of Aliases to fill.

 

Thanks a LOT again, IsharaMeradin :).



#6
DarthWayne

DarthWayne

    Dark Lord

  • Premium Member
  • 620 posts

Be careful with properties here. They will reset after restarting the game (or was it after reloading the cell?). If you want the boolean values to be stored permanently, declare them as simple variable:

Scriptname MySendingInfoScript extends MyDummyQuest 

bool InfoSentAlias00 = false
bool InfoSentAlias01 = false
bool InfoSentAlias02 = false	

Event OnUpdate() ; for the sake of the example

	InfoSentAlias00 = true
	InfoSentAlias01 = true
	InfoSentAlias02 = true

EndEvent 


#7
Hoamaii

Hoamaii

    Resident poster

  • Premium Member
  • 3,225 posts

@ DarthWayne:

 

Really? I've used bools a lot on switches, buttons, lights... I've never seen them reset to their default values neither on cells being reloaded nor on quitting and reloading a save... From what I've seen, the only time they will reset after OnInit() is when you call Reset() from a script. Or maybe my English is failing me again and I'm not quite getting what you mean?



#8
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,547 posts

If the object holding the script does not get unloaded in any way the values will remain set.  The reverse is true, if for some reason the object holding the script is unloaded, a future reload will reset the values.

 

An object sitting in a cell will reset the properties each time the cell is reloaded.

A running quest will retain properties for as long as the quest is running despite changing cells or even reloading the game.

 

This is one reason why I made the suggestion that I did.  Aliases can change via ForceRefTo and subsequently have their script properties reset while the quest itself only resets when it is restarted.

 

This may be a case where you'll need a start game enabled controlling quest that contains scripts used throughout the mod.  It would keep the properties safe for use by multiple objects no matter when they are loaded into the game.



#9
Hoamaii

Hoamaii

    Resident poster

  • Premium Member
  • 3,225 posts

Thanks for the clarification, IsharaMeradin. I'm probably mistaken then but I honestly can't remember seeing them resetting on reloading a cell or a save. Was a while back anyway, maybe I was also also using States in these scripts I'm thinking about...

 

Yes, I'm using a controlling quest - but I also want to be able to let the user stop the mod via MCM, starting with the controlling quest.

 

It goes like this: MCMconfiQuest controls -> ControllingQuest, controls -> MainRadiantQuest (the one which does all the work). The Controlling quest is there to reset, stop and restart my main quest when needed.

 

Actually, the whole purpose of this is that I need to leave some time to my radiant quest to run some "cleanup" functions before fully stopping. Thus, when MCM says "Stop" to the Controlling Quest, I need that Controlling Quest to send a warning to the Main Quest before calling it to stop, and finally stopping the controlling quest too. Uh... It's kind of late, I'm sorry if I'm being unclear... 



#10
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,547 posts

A Creation Kit filled property won't actually change, but if you change the value of that property it might revert to the CK value.  Most of the time you are using CK defined properties that you do not change.  But in this case you're setting up an empty or script default property that you modify during run-time.  Should the object containing the script get reloaded/restarted/reinitialized it will obtain the CK defined value rather than what you have modified.

 

Done rewording for further clarification... :P

 

As far as the controlling quest thing, seems like you've got a fairly clear grasp on the idea. I understood what you were saying at any rate.







Also tagged with one or more of these keywords: script, properties, quest, alias

IPB skins by Skinbox
Page loaded in: 1.097 seconds