Jump to content

Need help with scripts


Recommended Posts

Thank you very much for the clear explanation, I didn't know it was so difficult((( there are people like you who understand this. I will definitely do everything as you described, test it, and let you know. I think it should work. But I think modding is not my thing((( I don't understand much. In any case, THANK YOU SO MUCH for taking the time to answer the questions.

Link to comment
Share on other sites

13 hours ago, scorrp10 said:

I did as you described. What I got:

This doesn't work, I don't get a .pex file created in Data\Scripts

2.  you can compile resourcefurniturescript.psc - which will generate the .pex file in Data\Scripts.   Gameplay menu - Papyrus Script Manager - filter for resource.   Make sure 'Has Source' says Yes.   Right-click, choose Compile.
image.png.96a45e828edc76e7c82da53d8401ebd2.png

You now should have the .pex file in Data\Scripts.

But I have good news. The script works when I create a new game as you described: Option 1: test it on a new game. No need to suffer the usual cart ride. Launch game, and at main menu, open console, and type: coc whiterunorigin
There is a chopping block by the 3rd house on the right (right after Breezehome)
Option 2: spawn a new chopping block. Load up your save, open console, type: player.placeatme 7022e
This will spawn a brand new chopping block under your feet.

That is, it works in a new game and when I create a new chopping block for firewood (player.placeatme 7022e).

I don't understand what you wrote below. 

11 hours ago, scorrp10 said:

 

NOW.  If you want your change to work seamlessly on a game in progress, on chopping blocks that already been loaded, you need to do a bit more work.   

The most blunt approach:   in 'OnActivate' function, right at the top, add:

ResourceCount = 4
MaxResourcePerActivation = 12 

to make it 3 chops of 4 each. (12 firewood total).    Then, recompile the script.   In fact, if you make this change, you will no longer need the .esp with changed prroperties.

 

 Please sorry for my bad English.
So as not to torment you... How do I get this to work for the old wood chopping areas in my saves?

Edited by vasiliipupkin1
Link to comment
Share on other sites

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.

 

 

 

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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