Jump to content

Need help connecting an Activator to a Workbench


trashgarbage666

Recommended Posts

For context, I'm trying to make a sink that you can drink from that lets you fill empty bottles with water.

Here are the relevant pieces I'm using:

 

An activator: specifically DrinkSinkClean03Purified (from vanilla NV)

A script attached to the activator

A message (message box with three choices, 0 == Drink, 1 == Fill Bottles, 2 == Cancel)

A Workbench (this contains recipes that turn empty bottles into drinkable water)

 

Ideally, If you have no bottles, the sink would behave normally and activating it would cause you to drink from it. But if you did have empty bottles, the message would pop up instead, letting you choose what to do. And if you chose "Fill Bottles", it would bring up the workbench menu.

 

The problem I'm having is that the GameMode block in my script isn't firing for some reason. At least that's what I assume, because it's not showing the PrintToConsole message written at the start of the block. Currently, when you have empty bottles in your inventory, the message will pop up, but none of the choices do anything. If you don't have bottles, then the player drinks from the sink as intended. I've been looking at similar scripts from the vanilla game to see if I'm missing something "obvious", but I haven't found anything yet. Hopefully somebody here will be able to help me spot the problem.

 

Edit: So I may have isolated the problem -- in part, anyways. The non-functional sink I was testing was in Doc Mitchell's house, but when I entered the Prospector Saloon, the console started spitting out my "GameMode..." message over and over. It had me really confused for a second, until I realized the saloon bathroom uses the same sink. So I tested the saloon sink, and it worked perfectly fine! Out of curiosity, I started a new file, and the script attached to Doc Mitchell's sink worked until the game asks you if you want to turn on Hardcore mode. So something about that part of the game intro is interrupting the script. I'll have to investigate further tomorrow.

ScriptName WorkbenchWaterSinkSCRIPT

	Ref rUser
	Short nButton

;==================================================
	BEGIN OnActivate;
;==================================================

	PrintToConsole "OnActivate..."

	Set rUser to (GetActionRef);

	If (rUser == Player) && (Player.GetItemCount ListWaterBottle >= 1);
		ShowMessage MessageWorkbenchWaterSink;

	ElseIf (rUser == Player) && (Player.GetItemCount ListWaterBottle == 0);
		Activate;

	ElseIf (rUser != Player);
		Activate;
	EndIf;

;==================================================
	END;
;==================================================
	BEGIN GameMode;
;==================================================

	PrintToConsole "GameMode..."

	Set nButton to (GetButtonPressed);

	;Drink
	If (nButton == 0);
		Activate;

	;Fill Bottles
	ElseIf (nButton == 1);
		Player.ShowRecipeMenu WorkbenchWaterSink;

	;Cancel
	ElseIf (nButton == 2);
		;Do nothing!

	EndIf;

;==================================================
	END;
;==================================================
Edited by punchbattle
Link to comment
Share on other sites

I'd hoped someone with more direct experience would respond first, but ... Just a guess, however it seems to me that your problem is the "GameMode" block is in the same script as the "OnActivate" block. My reasoning is this.

 

The script "WorkbenchWaterSinkSCRIPT" doesn't get launched until the Activator is triggered, so it's an "Object" script. The "OnActivate" block is a single frame type, so it will only be triggered once for that single frame. The statements you have there are fine for that purpose. But I would suggest adding a "activated gateway variable" that is indicating that it was triggered.

 

The "GameMode" block is a multiframe type. It needs to run repeatedly in order to check "conditions" that will vary between frames (such as "nButton"). Being nested inside an "Activated Object" script doesn't accomplish that because it is only triggered for one frame. Instead I believe you want to move that part of it to a "Quest" script and check for the suggested added "activated gateway variable" there to control when that logic is processed. You will also need to be able to reset the "activated gateway variable" when the workbench is finished so it's logic gets skipped when the sink is no longer activated.

 

-Dubious-

Link to comment
Share on other sites

I'd hoped someone with more direct experience would respond first, but ... Just a guess, however it seems to me that your problem is the "GameMode" block is in the same script as the "OnActivate" block. My reasoning is this.

 

The script "WorkbenchWaterSinkSCRIPT" doesn't get launched until the Activator is triggered, so it's an "Object" script. The "OnActivate" block is a single frame type, so it will only be triggered once for that single frame. The statements you have there are fine for that purpose. But I would suggest adding a "activated gateway variable" that is indicating that it was triggered.

 

The "GameMode" block is a multiframe type. It needs to run repeatedly in order to check "conditions" that will vary between frames (such as "nButton"). Being nested inside an "Activated Object" script doesn't accomplish that because it is only triggered for one frame. Instead I believe you want to move that part of it to a "Quest" script and check for the suggested added "activated gateway variable" there to control when that logic is processed. You will also need to be able to reset the "activated gateway variable" when the workbench is finished so it's logic gets skipped when the sink is no longer activated.

 

-Dubious-

 

Sounds like a good idea, especially if it means the script only runs when needed!

 

But I ended up taking the coward's route. I thought about how you described the process, and thought maybe I could achieve the same thing with a perk. I have very limited experience with quests, so I tend to avoid them like the plague. So I made a small quest that runs at the start of the game, gives the player a hidden perk, and then ends itself. The perk is an Entry Point > Activate > Add Activation Choice that checks if the object the player is interacting with is in my Form List, and then gives the player a popup choice. It worked like a charm!

 

 

I probably wouldn't have tried this without your suggestion, so thank you!!

Edited by punchbattle
Link to comment
Share on other sites

There is usually more than one way to achieve an intended result. Whatever works.

 

I know first hand the value of hearing other suggested approaches to jump your mind out of the well worn rut of your current approach, which is why I offer my thoughts even when I don't have the definitive answer. Glad it was of some help.

 

-Dubious-

Link to comment
Share on other sites

  • Recently Browsing   0 members

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