Jump to content

A few quick scripting questions


Philosophiac

Recommended Posts

Alright, so here's where I'm at right now. I've been working on a mod to completely change the feel of the vanilla crafting/scavenging experience for something close to four years now. In that time, I've lost all my progress... lost my password and account information here on the Nexus... and forced myself to learn how to do some very rudimentary scripting. So far, so good...

 

Now, I've got a script I'm working on... basically a cannibalized version of the laboratory script, which SHOULD allow the player to use a distillery in order to craft their own alcohol. I'm trying to set it up like the laboratory did, where there' a time delay, but I don't understand enough about what I'm doing to actually know what the variables I'm playing around with are sometimes. In this case, the vanilla My First Laboratory looks like this:

 

 

 

	
scn HD00LabScript

short Done
short Button
short HDLab0															1= The laboratory is now "brewing" a drug
float HDLabTime0														x.x= Float for how much time has passed
short ProcessButton


;Globals used here


begin OnActivate
if IsActionRef player == 1

	if ( HDLab0 == 0 )	
		set ProcessButton to 1
		ShowMessage HD00LabMessage
	elseif ( HDLab0 == 1 )
		ShowMessage HD00LabMessage01
	elseif ( HDLab0 == 2 )
		Set HDLab0 to 0
		ShowMessage HD00LabMessage02
		Player.AddItem LootChemsAll100 1
	endif

endif
end

begin gamemode

;This section of the gamemode block handles all of the button presses on the Laboratory kit

set Button to GetButtonPressed
if Button > -1
	if ProcessButton == 1
		if ( Button == 0 )
			Set HDLab0 to 1
			Set HDLabTime0 to GameDaysPassed
		elseif ( Button == 1 )
			Player.RemoveSpell WithdrawalQuantumNukacola
			Player.RemoveSpell WithdrawalAlcohol
			Player.RemoveSpell WithdrawalBuffout
			Player.RemoveSpell WithdrawalJet
			Player.RemoveSpell WithdrawalMentats
			Player.RemoveSpell WithdrawalMorphine
			Player.RemoveSpell WithdrawalPsycho
			ShowMessage HDLabDetoxify
		elseif ( Button == 2 )
		endif
	endif
	; clear button variable
	set ProcessButton to 0
endif


if ( HDLab0 == 1 )
	if ( GameDaysPassed - HDLabTime0 >= 1 )
		Set HDLab0 to 2
	endif
endif

end

 

 

 

Now, so far... my script looks like this:

 

 

scn TSYHomeDistillery

short Done
short Button
short TSYDistill0Ready													1= The Distillery is currently inactive and ready to use
short TSYDistill0Absinthe												1= The Distillery is currently brewing a batch of absinthe
short TSYDistill0AbsintheComplete									1= The Distillery has finished brewing a batch of absinthe
short TSYDistill0Beer														1= The Distillery is currently brewing a batch of beer
short TSYDistill0BeerComplete											1= The Distillery has finished brewing a batch of beer
short TSYDistill0Moonshine												1= The Distillery is currently brewing a batch of moonshine
short TSYDistill0MoonshineComplete									1= The Distillery has finished brewing a batch of moonshine
short TSYDistill0Scotch													1= The Distillery is currently brewing a batch of scotch
short TSYDistill0ScotchComplete										1= The Distillery has finished brewing a batch of scotch
short TSYDistill0Whiskey													1= The Distillery is currently brewing a batch of whiskey
short TSYDistill0WhiskeyComplete										1= The Distillery has finished brewing a batch of whiskey
float TSYDistillTime0														x.x= Float for how much time has passed
short ProcessButton


;Globals used here


begin OnActivate
if IsActionRef player == 1

	if ( TSYDistill0Ready == 1 )	
		set ProcessButton to 1
		ShowMessage 05xTSYxHomeDistillery01
	elseif ( TSYDistill0Absinthe == 1 )
		ShowMessage 05xTSYxHomeDistillery02
	elseif ( TSYDistill0Beer == 1 )
		ShowMessage 05xTSYxHomeDistillery03
	elseif ( TSYDistill0Moonshine == 1 )
		ShowMessage 05xTSYxHomeDistillery04
	elseif ( TSYDistill0Scotch == 1 )
		ShowMessage 05xTSYxHomeDistillery05
	elseif ( TSYDistill0Whiskey == 1 )
		ShowMessage 05xTSYxHomeDistillery06
	elseif ( TSYDistill0AbsintheComplete == 1 )
		Set TSYDistill0Ready to 1
		Set TSYDistill0AbsintheComplete to 0
		ShowMessage 05xTSYxHomeDistilleryComplete
		Player.AddItem Absinthe 5
	elseif ( TSYDistill0BeerComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0BeerComplete to 0 )
		Player.AddItem Beer 24
	elseif ( TSYDistill0MoonshineComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0MoonshineComplete to 0 )
		Player.AddItem Moonshine 10

	endif
endif
end

begin gamemode

;This section of the gamemode block handles all of the button presses on the Laboratory kit

set Button to GetButtonPressed
if Button > -1
	if ProcessButton == 1
		if ( Button == 0 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Absinthe to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 1 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Beer to 1
			Set TSY DistillTime0 to GameDaysPassed
		elseif ( Button == 2 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Moonshine to 1
			Set TSY DistillTime0 to GameDaysPassed
		elseif ( Button == 3 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Scotch to 1
			Set TSY DistillTime0 to GameDaysPassed
		elseif ( Button == 4 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Whiskey to 1
			Set TSY DistillTime0 to GameDaysPassed
		elseif ( Button == 5 )
		endif
	endif
	; clear button variable
	set ProcessButton to 0
endif


if ( TSYDistill0Absinthe == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 1 )
		Set TSYDistill0Absinthe to 0
		Set TSYDistill0AbsintheComplete to 1
elseif ( TSYDistill0Beer == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 1 )
		Set TSYDistill0Beer to 0
		Set TSYDistill0BeerComplete to 1	
elseif ( TSYDistill0Moonshine == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Moonshine to 0
		Set TSYDistill0MoonshineComplete to 1
	endif
endif

end

 

 

 

 

Now, obviously it's far from complete... and it's certainly not an elegant piece of work by any stretch of the imagination... but hopefully it will do the trick once it's ready to go. What I really need right now is someone who can take a look over what I have here and point out any glaringly obvious errors I have almost certainly made. For instance, I'd love to know why it still refuses to SAVE said script. Is it so poorly done that there's no way of redeeming it?

 

I've tried my hand at bits of code in the past, but this is by far the most effort I've put into anything short of adjusting a couple of numbers here and there. So feel free to talk to me like I'm an idiot.

 

I just want to get this script into workable form so that I can move onto other, slightly less text-based portions of my project.

 

Thanks in advance for any help I might get!

Link to comment
Share on other sites

I stuck your script in Cipscis's Fallout Script Validator. Some of the warnings it gave back were wrong, but the one thing it did point out was that this line that occurs 3 times:

 

Set TSY DistillTime0 to GameDaysPassed

 

You have a space between TSY and DistillTime0 in each line.

 

Lastly, you can try using the GECK 1 4 PowerUp for Fallout New Vegas to help show scripting errors.

Link to comment
Share on other sites

I stuck your script in Cipscis's Fallout Script Validator. Some of the warnings it gave back were wrong, but the one thing it did point out was that this line that occurs 3 times:

 

Set TSY DistillTime0 to GameDaysPassed

 

You have a space between TSY and DistillTime0 in each line.

 

Lastly, you can try using the GECK 1 4 PowerUp for Fallout New Vegas to help show scripting errors.

 

 

Thanks to your help, I went back through and found a rather surprising number of lines where I had copy/pasted that same space error. I also corrected a few other problems, and managed to get the script to a savable state! I'm definitely going to be bookmarking that script validator for further use in the future. I've no doubt I'll be making many mistakes which it can help me find and sort out.

 

@rickerhk - I noticed that, too, when I was looking at the script validator! The original script, as it existed in the game before I began tinkering with it for my own use, had the same error! For whatever reason, it doesn't seem to have affected the MyFirstLaboratory script in any negative way... but the error in the validator disappeared just as soon as I put a semi-colon before all of them. And now that it's saved, I've learned a valuable lesson about not trusting everything that's already in the game!

 

Anyways... this is what I've got so far:

 

 

 

scn TSYHomeDistillery

short Button
short TSYDistill0Ready													;1= The Distillery is currently inactive and ready to use
short TSYDistill0Absinthe												;1= The Distillery is currently brewing a batch of absinthe
short TSYDistill0AbsintheComplete									;1= The Distillery has finished brewing a batch of absinthe
short TSYDistill0Beer														;1= The Distillery is currently brewing a batch of beer
short TSYDistill0BeerComplete											;1= The Distillery has finished brewing a batch of beer
short TSYDistill0Moonshine												;1= The Distillery is currently brewing a batch of moonshine
short TSYDistill0MoonshineComplete									;1= The Distillery has finished brewing a batch of moonshine
short TSYDistill0Scotch													;1= The Distillery is currently brewing a batch of scotch
short TSYDistill0ScotchComplete										;1= The Distillery has finished brewing a batch of scotch
short TSYDistill0Whiskey													;1= The Distillery is currently brewing a batch of whiskey
short TSYDistill0WhiskeyComplete										;1= The Distillery has finished brewing a batch of whiskey
float TSYDistillTime0														;x.x= Float for how much time has passed
short ProcessButton


;Globals used here


begin OnActivate
if IsActionRef player == 1
	if ( TSYDistill0Ready == 1 )	
		set ProcessButton to 1
		ShowMessage 05xTSYxHomeDistillery01
	elseif ( TSYDistill0Absinthe == 1 )
		ShowMessage 05xTSYxHomeDistillery02
	elseif ( TSYDistill0Beer == 1 )
		ShowMessage 05xTSYxHomeDistillery03
	elseif ( TSYDistill0Moonshine == 1 )
		ShowMessage 05xTSYxHomeDistillery04
	elseif ( TSYDistill0Scotch == 1 )
		ShowMessage 05xTSYxHomeDistillery05
	elseif ( TSYDistill0Whiskey == 1 )
		ShowMessage 05xTSYxHomeDistillery06
	elseif ( TSYDistill0AbsintheComplete == 1 )
		Set TSYDistill0Ready to 1
		Set TSYDistill0AbsintheComplete to 0
		ShowMessage 05xTSYxHomeDistilleryComplete
		Player.AddItem Absinthe 5
	elseif ( TSYDistill0BeerComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0BeerComplete to 0
		Player.AddItem Beer 24
	elseif ( TSYDistill0MoonshineComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0MoonshineComplete to 0
		Player.AddItem Moonshine 10
	endif
endif
end

begin gamemode

;This section of the gamemode block handles all of the button presses on the Laboratory kit

set Button to GetButtonPressed
if Button > -1
	if ProcessButton == 1
		if ( Button == 0 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Absinthe to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 1 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Beer to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 2 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Moonshine to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 3 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Scotch to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 4 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Whiskey to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 5 )
		endif
	endif
	; clear button variable
	set ProcessButton to 0
endif


if ( TSYDistill0Absinthe == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 1 )
		Set TSYDistill0Absinthe to 0
		Set TSYDistill0AbsintheComplete to 1
elseif ( TSYDistill0Beer == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 1 )
		Set TSYDistill0Beer to 0
		Set TSYDistill0BeerComplete to 1	
elseif ( TSYDistill0Moonshine == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Moonshine to 0
		Set TSYDistill0MoonshineComplete to 1
	endif
endif
endif
endif

end

 

 

 

 

Now I'll just finish adding in all the missing parts, test it, and see if it doesn't explode my game!

Link to comment
Share on other sites

The two last endifs are in a strange spot. Should be under the

Set TSYDistill0AbsintheComplete to 1

 

Set TSYDistill0BeerComplete to 1

 

lines

 

 

Link to comment
Share on other sites

So, I've been making very slow progress thus far... but progress nonetheless!

 

 

Here's what I've got, so far.

 

What remains to be added into the script, in terms of its functionality, is the removal of ingredients required to distill the booze. Hopefully that part will be as easy as inserting a few removeitem lines to each of the button-detection blocks, yes? I figure it's safe to do it that way because the OPTION to brew any given variety of booze won't appear unless the player already has the required ingredients on him/her when he/she activates it.

 

I hope that the longer I keep at this scripting business, the easier it'll come to me... because right now I'm looking and it's all a bunch of gobledegook to me!

 

 

 

scn TSYHomeDistillery

short Button
short TSYDistill0Ready													;1= The Distillery is currently inactive and ready to use
short TSYDistill0Absinthe												;1= The Distillery is currently brewing a batch of absinthe
short TSYDistill0AbsintheComplete									;1= The Distillery has finished brewing a batch of absinthe
short TSYDistill0Beer														;1= The Distillery is currently brewing a batch of beer
short TSYDistill0BeerComplete											;1= The Distillery has finished brewing a batch of beer
short TSYDistill0Moonshine												;1= The Distillery is currently brewing a batch of moonshine
short TSYDistill0MoonshineComplete									;1= The Distillery has finished brewing a batch of moonshine
short TSYDistill0Scotch													;1= The Distillery is currently brewing a batch of scotch
short TSYDistill0ScotchComplete										;1= The Distillery has finished brewing a batch of scotch
short TSYDistill0Whiskey													;1= The Distillery is currently brewing a batch of whiskey
short TSYDistill0WhiskeyComplete										;1= The Distillery has finished brewing a batch of whiskey
float TSYDistillTime0														;x.x= Float for how much time has passed
short ProcessButton


;Globals used here


begin OnActivate
if IsActionRef player == 1
	if ( TSYDistill0Ready == 1 )	
		set ProcessButton to 1
		ShowMessage 05xTSYxHomeDistillery01
	elseif ( TSYDistill0Absinthe == 1 )
		ShowMessage 05xTSYxHomeDistillery02
	elseif ( TSYDistill0Beer == 1 )
		ShowMessage 05xTSYxHomeDistillery03
	elseif ( TSYDistill0Moonshine == 1 )
		ShowMessage 05xTSYxHomeDistillery04
	elseif ( TSYDistill0Scotch == 1 )
		ShowMessage 05xTSYxHomeDistillery05
	elseif ( TSYDistill0Whiskey == 1 )
		ShowMessage 05xTSYxHomeDistillery06
	elseif ( TSYDistill0AbsintheComplete == 1 )
		Set TSYDistill0Ready to 1
		Set TSYDistill0AbsintheComplete to 0
		ShowMessage 05xTSYxHomeDistilleryComplete
		Player.AddItem Absinthe 5
	elseif ( TSYDistill0BeerComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0BeerComplete to 0
		Player.AddItem Beer 24
	elseif ( TSYDistill0MoonshineComplete == 1 )
		ShowMessage 05xTSYxHomeDistilleryComplete
		Set TSYDistill0Ready to 1
		Set TSYDistill0MoonshineComplete to 0
		Player.AddItem Moonshine 10
	endif
endif
end

begin gamemode

;This section of the gamemode block handles all of the button presses on the Laboratory kit

set Button to GetButtonPressed
if Button > -1
	if ProcessButton == 1
		if ( Button == 0 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Absinthe to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 1 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Beer to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 2 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Moonshine to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 3 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Scotch to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 4 )
			Set TSYDistill0Ready to 0
			Set TSYDistill0Whiskey to 1
			Set TSYDistillTime0 to GameDaysPassed
		elseif ( Button == 5 )
		endif
	endif
	; clear button variable
	set ProcessButton to 0
endif


if ( TSYDistill0Absinthe == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Absinthe to 0
		Set TSYDistill0AbsintheComplete to 1
	endif
elseif ( TSYDistill0Beer == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Beer to 0
		Set TSYDistill0BeerComplete to 1	
	endif
elseif ( TSYDistill0Moonshine == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Moonshine to 0
		Set TSYDistill0MoonshineComplete to 1
	endif
elseif ( TSYDistill0Scotch == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Scotch to 0
		Set TSYDistill0ScotchComplete to 1
	endif
elseif ( TSYDistill0Whiskey == 1 )
	if ( GameDaysPassed - TSYDistillTime0 >= 3 )
		Set TSYDistill0Whiskey to 0
		Set TSYDistill0WhiskeyComplete to 1
	endif
endif
end


 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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