the Sim Settlements forums!

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Quest scripting questions...

msalaba

Well-Known Member
Staff member
Community Rockstar
Verified Builder
HQ Support
Messages
4,425
This sub forum is quite lonely. I'll add the first post to it. Does that make me special?

Anyway, I'm trying to wrap my head around creating a 'master' quest script. (Script tab of the quest) It is pretty simple and straight forward to use fragments. I'm trying to learn how to move all this into one script.

So far this is the general layout I have come up with:

QuestControllerScript Extends Quest ;Properties... blah blah Event OnSetStage(iStage) if (iStage == 10) ;stuff happens Elseif (iStage == 20) ;other stuff happens Elseif (iStage == 30) ;even more stuff happens Endif EndEvent Function myFunction () ;my function stuff happens EndFunction
Is this the proper way to do this? Is there a better way? Or do I just use fragments?

If the previous code is proper, how do you add events to it. i.e. There is a note where the player reads it and sets a stage. The Player reads an entry in a holotape and it sets a stage. The Player picks up an item and it sets a stage. Are these better left in fragments?

And finally, calling a function I made from a fragment. I search and still can't wrap my head around it and the compiler is starting to wear out from my numerous attempts.
What is the proper syntax for calling myFunction() in the namespace myMod:myQuest with the script name myQuestControllerScript? Can this be done from a fragment?

Thanks in advance for the help! :drinks
 
I understand how to spawn an ActorBase into the world. How do you remove them, both before and after death? Can you enable/disable like ObjectReferences?

How do you spawn a LeveledCharacter? I'm assuming there is some form shenanigans involved...
 
For your first question on the master script - I highly recommend looking at the template for a controller script that kinggath has in the Bethesda mod school series. It's included in the mod here, and described in episode 23 "Scripting 101" here. This way you both include a failsafe to start up your quest (so it doesn't get overrun by other start game enabled quests) and a controller that keeps track of which version of your mod players have, so you can update your scripts for them accordingly.

After that it depends on how you structure your mod. You usually register for events with OnInit() or OnLoad() and as you have in your code - react to things on stage set etc. I definitely prefer having all the reactions (player picks up holotape etc) in a quest script rather than in fragments, just because it quickly gets unwieldy and hard to keep track.

For your other questions, many of them are dealt with in the BTK scripting episodes - the parts with "Deployable turrets". And with your experience you will likely easily translate them to your needs. Otherwise - I just saw that you have requested access to the BTK Discord, super! There's more activity regarding mod making there than here on the forums. The forums are excellent for all questions regarding playing the mod(s) and for valuable feedback from players.
 
For your first question on the master script - I highly recommend looking at the template for a controller script that kinggath has in the Bethesda mod school series. It's included in the mod here, and described in episode 23 "Scripting 101" here. This way you both include a failsafe to start up your quest (so it doesn't get overrun by other start game enabled quests) and a controller that keeps track of which version of your mod players have, so you can update your scripts for them accordingly.
This part is easy. My quest is not game start enabled. It has a hard startup dependancy on the SS2 questline.
I definitely prefer having all the reactions (player picks up holotape etc) in a quest script rather than in fragments, just because it quickly gets unwieldy and hard to keep track.
This x 50. I was having the problem of remembering what fired when and by the time I was done looking through the fragments, I forgot waht I was looking for to begin with! So far I have it down to activation of objects sets a quest stage and the rest is in the main quest script. I have not yet figured out how to put Events where the player interacts with ObjectReference happen in a Quest script or vice versa.

You usually register for events with OnInit() or OnLoad() and as you have in your code
More things to learn... I just wrapped my head around OnQuestInit()

I just saw that you have requested access to the BTK Discord
That's all well and good, but I have no clue how Discord works. Pickysaurus was trying to help me get setup for the Nexus server and things went wrong and I gave up...

Thanks for the reply. At least I know I'm heading in the right direction!
 
As you have noticed, the functions extend different type of objects so sometimes it's easier (or even necessary) to have the script on the object - like on an activator if you use OnActivate(). There are ways to re-write functions adding the object as an argument, and keep them either in a global script or one that is on a quest. Looking at how Bethesda has done it helps, but it's mostly done in a way that a non-programmer (their level designers) can get things to happen in game. If you have more coding experience you may prefer to keep things in your own scripts, but it's not necessary. Mostly it's the fragments I tend to avoid, because they get more "hidden". There are some cases were it seems fragments are necessary (or just easier) - I can't think of any right now, but there have been cases where I couldn't move the function calls to an OnStageSet event etc.

Discord should be possible to download as an app for your desktop or for mobile, sign up and then it's mostly following the link from the request response and you should be good to go. There are veteran mod authors there that generously help out with all types of questions (and they aren't usually around here as much) so it might be worth giving it a go again, despite the earlier setback :)
 
There are some cases were it seems fragments are necessary (or just easier)
Terminal Entries.

I have not found any other method for firing code triggered by reading an individual terminal entry.
 
Top