Jump to content

Script Compiles, Doesn't Work as Intended (noob)


CompGuyJMB

Recommended Posts

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Scripts are not included into .esp. They are saved in the Data->Scripts as pex files (non readable but essential for your mod to work), and psc files in Scripts ->Source->User(readable and essential if you want to edit the appropriate pex file). I can make and compile the script myself by copying your code from this thread, but anyone who is unable to do it won't be able to get your mod working.

 

That's interesting about the generator. I was able to connect your generator to the conduit without problems. You only need it to have the required keywords and actor values to build a wire from it..Though if the model has no special CPA, the wire will grow from the middle bottom point which can make it difficult to connect sometimes.

 

 

Did you try just picking up the radio and moving it? When I did that it triggered a refresh of the power state and it turned on with radiation from the generator. At least I think it was the generator.

 

I'm a bit confused because the radio could not be picked or moved. I did not edit anything, just installed and went to Sanctuary to test. Have you created a crafting recipe for it?

Edited by kitcat81
Link to comment
Share on other sites

Kitcat, do you know how would I be able to "fully compile" this mod with the scripts if I wanted to share it?

 

I'm also not sure how he was able to move it either. I couldn't. Not in Workshop move, and now with the Z key like he mentioned. I did not create a crafting recipe. My experience is nowhere near that yet.

 

Seems like we're all getting different results from the same file :confused:

Edited by CompGuyJMB
Link to comment
Share on other sites

I FINALLY GOT EVERYTHING TO WORK THE WAY I WANT IT TO!

 

I got a little creative disabling the generator on initialize. Basically if the marker is off, it shuts the generator off. This only needs to happen the first time things load. I guess OnInit would not disable the generator - maybe the cell wasn't fully loaded (even with a 5 second wait)

 

Thanks so much guys!

 

ESP is updated for you guys to look at if you like. I still have to figure out how to "compile the scripts into the ESP" so they are present.

 

ESP Ilnk: https://www.dropbox.com/s/3lxifp1pnnz44i8/JMB.esp?dl=0

 

Generator Switch code:

Scriptname JMBBunkerGeneratorSwitchScript extends ObjectReference

ObjectReference Property GeneratorEnableMarker Auto
{Enable / Disable Marker for Generator}

ObjectReference Property Generator Auto
{The generator that is toggled on and off}

ObjectReference Property CellWorkshop Auto
{Link this to the cells Workbench}

; Needed for the “CurrentPowerGeneration” variable to get its value
WorkshopParentScript Property WorkshopParent Auto Const
{Set this to WorkshopParent}

Event OnCellAttach()
	Utility.Wait(1.0) ; Wait 1 second to let cell load
		
	; Retrieve the Current Power Output in the Workshop
	float CurrentPowerGeneration = CellWorkshop.GetValue(WorkshopParent.WorkshopRatings[WorkshopParent.WorkshopRatingPower].resourceValue)

	Generator.BlockActivation(true,true) ; Blocks Player Activation, Disables Activate prompt in game.
	; Generator.Activate(Game.GetPlayer(), true)  will still work, as "true" forces the activation to occur, but also bypasses the OnActivate() event on the generator itself.

	If (GeneratorEnableMarker.IsDisabled()) ; This means that the Generator SHOULD be off
		If (CurrentPowerGeneration > 1.0) ; See if Power is being generated (ie Generator is on)
			Generator.Activate(Game.GetPlayer(), true) ; Activate the generator to turn it off (true disables OnActivate from firing)
			Debug.MessageBox ("Trying to Shut Down Generator")
		EndIf
	EndIf
EndEvent

Event OnActivate(ObjectReference akActionRef)
	If (GeneratorEnableMarker.IsDisabled())
		GeneratorEnableMarker.Enable()
	Else
		GeneratorEnableMarker.Disable()
	EndIf

	Generator.Activate(Game.GetPlayer(), true) ;Toggle Generator State - Have to use True since BlockActivation is used above
EndEvent

Radio Code:

Scriptname JMBBunkerCheckForPower extends ObjectReference
{Checks to see if PowerSource is on before allowing device (self) to turn on}

Event OnCellAttach()
; When Player enters cell
	Utility.Wait(1.0) ; Wait 1 second to give the cell some time to load.  Cannot use OnLoad or OnCellLoad - not fired everytime cell is entered, or OnInit - only fires when ESP is loaded.

	If (IsPowered() == false) ; Check if Device is receiving power from Workshop (not necessarily turned on)
		BlockActivation(true)
	Else
		BlockActivation(false)
	EndIf
EndEvent

Event OnPowerOn(ObjectReference akPowerGenerator)
; When Workshop Power is Turned On
	BlockActivation(false)
EndEvent

Event OnPowerOff()
; When Workshop Power is Turned Off
	BlockActivation(true)
	
	; If Radio is Playing, Turn it Off
	If (IsRadioOn()== true)
		SetRadioOn(false)
	EndIf

EndEvent

Now I just have to add the rest of the details. Thanks again!

Edited by CompGuyJMB
Link to comment
Share on other sites

Glad to know! ;) About scripts. You can't compile scripts into .esp. You have either to add them manually or pack them into BA2 archive. Download some mods manually , extract them to some test folder and see what files and folders they have inside. I.e. 'Invisible Furniture' mod has loose files so you can see how to add scripts as loose files. Many mods has them packed into BA2 which makes your mod esier to manage and remove. There are threads and arcticles that explain how to create an archive etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...