Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

How to pass a int variable between two different scripts


Tonycubed2
 Share

Recommended Posts

First, the variable is not part of a quest script, and thus the CK wiki does not work for it. So maybe it has to be a quest script for a variable to be passed between two scripts?

I doubt it though. In any case, the following script succesfully summons a ghoul when a potion is picked up the floor. Uses a local counter to only summon the ghoul one time even if picked up again. Works fine. But I need to let a second script elsewhere know that the potion was picked up. That is where I used the "Int Property TookPotion Auto" line.

My script elsewhere needs to query TookPotion and if it is "5" perform stuff. But I cannot get it to do it. I tried using GetLinkedRef() but it confuses me and complained about mismatched types. I tried to "cast" the type using "PotionTaken = GetLinkedRef() as SpawnGhostPotion" and compiled but that does not allow me to query the Int "TookPotion". Help! I spent hours and hours on this.


Scriptname SpawnGhostPotion extends ObjectReference  


Import Game

ActorBase Property UndeadGhost  Auto  

ObjectReference Property bornpoint  Auto  

Int Property PotionCurse  Auto

Int Property TookPotion Auto


Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

if PotionCurse==0

if akNewContainer == Game.GetPlayer() 

bornpoint.PlaceAtMe  (UndeadGhost, 2)

Debug.Notification("Undead!!") 

PotionCurse=PotionCurse+1

TookPotion=5

EndIf

EndIf

EndEvent

Link to comment
Share on other sites

Wow. I will try it and report back. Beats the other solution I found, using a "as" keyword and referring back to another script which takes forever to setup (at least for me :-) ), then calling a function. Any downside to using a global variable? Seems to good to be true. This is me trying to justify the two days I spent on the other solution.

Link to comment
Share on other sites

The only downside is that it stores only float values.

It does not matter though, since you can still store int values in a float. And if you need to convert the float to an int, its easyly done.

int myIntNumber

...

myIntNumber = myGlobalGBL.GetValue() as int

You do not need to 'convert' an int into a float, so no errors there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...