Jump to content

[LE] [Script|Newbie] How you call float value from a quest script.


anb2004

Recommended Posts

Don't know if i get the title right but here it goes

First attempt for making my first MCM config, thought i'll give it try with a simple config for the auto close door for my player house.

 

 

  Reveal hidden contents

 

 

The mcm script is chaotic i know, call me dumb or stupid but that's what i could come up with after hours rummaging any mods that i have and learn from it. Do managed to get the door auto close on & off though (yay :wallbash:). So figured i could do more with those 2 setting for delay and actors distance but there are the part that kind of put me back to square one.

 

Question :

1. How can i / is it possible to get each delay & distance float value from the quest script into the door script. How do you transform float into global or vice versa?

2. How to make those 2 delay & distance settings grey out with auto door checkbox uncheck upon first time loading ? just don't know how to connect AutoDoor bool and AutoCloseDoor Global.

3. Delay & disatance Slider are working well but both value are set to 1 instead default value that i assigned at first time loading. Wonder why ?

 

Any help will be appreciated but please bear with me, my IQ isn't exactly higher than my toe with scripting.

Link to comment
Share on other sites

1) make a new property in your script

xxNameOfScriptYouWantToAccess Property mScript Auto *

mScript.myproperty = value **
Or
mScript.myFunction() **


*
xxNameOfScriptYouWantToAccess is the name that is written behind Scriptname right on the header of the script and not the name of the .psc file
When you create a new script you essentially create a new object class along with it and you can then fill the property in the CK to obtain an actual object within your script

**
Since you now have an object you can access any properties and functions like you would do with any other object

you can't convert a float to a global or vice versa. You make a global in the CK and use it as a property and then use .GetValue() and .SetValue() on the global to work with them. These methods return/request float values though.

 

Also Read the Wiki

https://www.creationkit.com/index.php?title=Variables_and_Properties

2)

AutoCloseDoorDelayFlags()

and

AutoCloseDoorDistanceFlags()

 

do exactly the same you only need 1 and can delete the other

 

You can then rewrite that function so that it takes a float

int Function AutoCloseDoorDelayFlags(float fArg)
	if ( fArg ) ;float is implicitly cast as a bool here where 0 equals false and everything else means true
		return OPTION_FLAG_NONE
	else
		return OPTION_FLAG_DISABLED
	endif
EndFunction

you can then call that function like you did with other functions in your script already

AutoCloseDoorDelayFlags(AutoCloseDoorDistance.GetValue())

3)

the slider is initialized with this function

AddSliderOption("Delay", AutoCloseDoorDelay.GetValue(), AutoCloseDoorDelayFlags()) 

you pass AutoCloseDoorDelay.GetValue() as the initial value which likely is 1 by default and then

when OnSliderOptionAccept() gets calles later you update the value and thats why it will show the correct value the next time

 

I would suggest converting all your AutoReadOnly Properties to Auto and then initialize them with a seperate function on the OnPageReset() event

 

something like this

function initVArs()
      variable1 = global1.GetValue()
      variable2 = global2.GetValue()
      ;etc
endfunction

then instead of calling the globals everytime you call your variables directly which also has the advantage of beeing a bit faster

 

Or if you are comfortable with some "advanced scripting" you can link your variables and the globals through defining custom properties as it is explained here: https://www.creationkit.com/index.php?title=Property_Reference

 

Link to comment
Share on other sites

Maybe this is working for you. As testiger2 wrote: "make a new property" and "converting all your AutoReadOnly Properties"

 

anb_AutoDoorScript

  Reveal hidden contents

 

 

anb_AutoDoorMCMConfig

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

  On 3/13/2020 at 4:25 PM, ReDragon2013 said:

Maybe this is working for you. As testiger2 wrote: "make a new property" and "converting all your AutoReadOnly Properties"

 

anb_AutoDoorScript

  Reveal hidden contents

 

 

anb_AutoDoorMCMConfig

  Reveal hidden contents

 

It works :wink:

Though the door will start to self close if an actor is within the distance as it was set by distance slider instead blocking the door to self close, but no biggie i'll see if i can get it reverse.

Didn't expect for someone to write the code all over for me so thank you. Still working with my own code above to get it working, just for once i can do something right by my own from learning someone else code.

 

Anyway this might a little out of topic, interested with the change texture cycle script from modders resource by Darkfox127, tested and it work, unfortunately Darkfox127 didn't really describe how exactly for setting up a quest to update the global everytime we start the game because texture will revert back to the original.

 

Darkfox127 Script

  Reveal hidden contents

 

 

Remember doing something similar with my hunter armor texture swap that i tried to get it working back in the day. Any hint what should i do to accomplish that ?

 

Thanks

Link to comment
Share on other sites

two scripts as base for quest with static aliases by using predefined arrays as properties.. maybe it works, it is a suggestion

 

PM_TSCycle_QuestScript

  Reveal hidden contents

 

 

OnActivate() has been removed, only 3D ready events are used

 

PM_TSCycle_AliasScript

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 3/18/2020 at 6:48 PM, ReDragon2013 said:

two scripts as base for quest with static aliases by using predefined arrays as properties.. maybe it works, it is a suggestion

 

PM_TSCycle_QuestScript

  Reveal hidden contents

 

 

OnActivate() has been removed, only 3D ready events are used

 

PM_TSCycle_AliasScript

  Reveal hidden contents

 

Wow, wonder how your brain works to come up with that complicated code. Your coding is unlike any other code i've ever seen though, quite difficult to understand for beginner like me but i'll get there eventually.

 

Thank you, owe you big time :wink:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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