Jump to content

Need help with scripts


vasiliipupkin1

Recommended Posts

54 minutes ago, scorrp10 said:

The main question is: did you get to a point where you can edit the script?   That is, did you get all the .psc file from Scripts.zip  to where CK can see them?    

Yes sir! I can now edit the script. But when I right click -> Compile -> the .pex file is not created

Deleted, did everything again, it worked! The .pex file was created

What's the next step, Sir?

I understand that I need to insert this into the script?

ResourceCount = 4
MaxResourcePerActivation = 12

Where exactly, where should I insert it? Can you make a screenshot?

Edited by vasiliipupkin1
Link to comment
Share on other sites

auto STATE normal
Event OnActivate(ObjectReference akActionRef)
	gotoState("busy")
; 	debug.trace(self + "OnActivate")
	if akActionRef == Game.GetPlayer()  || (akActionRef as actor).isInFaction(CurrentFollowerFaction)
; 		debug.trace("akActionRef is either player or a follower")
		if (akActionRef as actor) != game.getPlayer()
; 			debug.trace("It's a follower - store in NPCfollower property")
			; if not the player, must be the follower
			NPCfollower = akActionRef
		endif
		bool allowActivation = true
		; check if player has required item
		if requiredItemList
			if akActionRef.GetItemCount(requiredItemList) == 0
				if akActionRef == game.getPlayer()
					; only require the axe item for the player
					allowActivation = false
; 					debug.trace("allowActivation = "+allowActivation)
					FailureMessage.Show()
				endif
			endif
		endif

		if allowActivation
			ResourceCount = 4		; <<< *** THESE TWO LINES ARE THE NEW ONES ***
			MaxResourcePerActivation = 12	; <<<
			RegisterForEvents(akActionRef)
; 			debug.trace(self + "player/follower activation START")
			Activate(akActionRef, true)
; 			debug.trace(self + "player/follower activation END")
		endif
	else
; 		;debug.trace(self + "non-follower NPC activation START")
		; just activate it
		Activate(akActionRef, true)
; 		;debug.trace(self + "non-follower NPC activation END")
	endif
	gotoState("normal")
endEvent
endState

Like this is probably best.

  • Like 1
Link to comment
Share on other sites

I did as you said! I inserted
ResourceCount = 4 ;
MaxResourcePerActivation = 12 ;
after if allowActivation

Here's what I got 

if allowActivation
            ResourceCount = 4                ;
            MaxResourcePerActivation = 12    ;

            RegisterForEvents(akActionRef)
;             debug.trace(self + "player/follower activation START")
            Activate(akActionRef, true)
;             debug.trace(self + "player/follower activation END")
        endif

Saved the script. Then right-click and "Compile" the file
Data\Scripts\ resourcefurniturescript.pex was created
I went into the game, loaded the saves and everything works great! It works! You are a genius SIR! Thank you so much for helping me and giving me your time. I couldn't have done it without you.
And how did you think of doing this?... Maybe I'm just a little stupid or I don't know a lot of things in terms of modding and programming in general.

I'm finishing school and want to go study to be a programmer, so I'm thinking of doing a little programming in the future, and at the same time learning English better.

 

Link to comment
Share on other sites

Frankly, this specific method is 'the dirtiest' and most primitive.    Those two extra lines could be added almost anywhere in the function, and they change the outcome for anyone using the block (Player, follower NPC, regular NPC), with no way to customize it on the fly.   But hey, it works.      

As to how one knows...    quite a bit of professional experience and a computer science college degree under my belt, and I been messing with Skyrim scripts at least since 2020.    The logic of most scripts is not hard to follow.   You generally learn a lot by example - by looking at games' original scripts and scripts of other modders.  At first it can look completely incomprehensible, but eventually, things start to fall into place.

 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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