Jump to content

Scripting Help - Sorting Containers


wizardmirth

Recommended Posts

Hello, I'm trying to learn Papyrus and want to write scripts for sorting containers grouped by themed objects. The only problem is I can't even seem to get my first script to show up in the add script list for the container. When I try and drag and drop my script from the Papyrus Manager I get a message saying the script has errors and will not be loaded.

 

I'm not planning on doing any scripting for this game beyond this and will probably stop with it there. Given that, I'm not really sure I want to take the time to learn it for the only one type of script I need.

 

So is there anyone out there who would be willing to write this script for me? And then I can simply recreate it for all the other containers once I have a working format that I can adjust myself. This is for a detailed house mod planned for release and I will of course credit you for your help.

 

Or at the very least I'm wondering if there is a way to check the script for errors -- notepad++ doesn't seem to check for errors and I can't seem to figure out how to do this while still editing my script?

 

(Basically what I want to do is have the container check for any one of a certain Form List item in the player's inventory, and if there to open up a message box with button options for sorting or just opening the container. If at least one of those items are not in the player's inventory then the container will open as normal. I also would like to include inventory counts for those items in the message box if at least one of the List items are there. I can attach and do all the other work myself -- I just need someone to write the actual script for me that I can then use as a template. I did this with my FO3 house mod but this newer scripting format for Skyrim is really puzzling me....)

Link to comment
Share on other sites

I tried a bit more reading and took another stab at trying to get something vaguely working. So now the script compiles with no errors but in-game when activating this container which is referenced here it just opens normally and acts like there is no script attached. At this point I am only trying to get my message box to show if the player has at least one of the items in the list (any one out of all the ingots in the list) but I'm probably calling it wrong?

Scriptname wmIngotTestSCRIPT extends ObjectReference  

FormList Property wmMHHSorterIngotsFLST Auto
Message Property wmMHHSorterIngotsMSG Auto
ObjectReference wmIngotsSafe2Ref
 
Event OnActivate(ObjectReference akActionRef)
	if (Game.GetPlayer().GetItemCount(wmMHHSorterIngotsFLST) > 0)
		wmMHHSorterIngotsMSG.Show()
	else
		wmIngotsSafe2Ref.Activate(Game.GetPlayer())
	endif
EndEvent
Link to comment
Share on other sites

Thanks that helps but I still have problems. One, my FormList check is not returning ">= 1" when I have at least one of the form list item in my inventory. Two, when I temporarily reverse this and make it "== 0" (just to test the other part of the script) I don't get anything other than my debug notifications happening. Any ideas what I'm doing wrong here? (again, no compile errors)

 

 

 

 

Scriptname wmIngotTestSCRIPT extends ObjectReference  


{11 Ingots Sorter}

	Import Game
	Import Utility
	Import Debug

	Message Property wmMHHSorterIngotsMSG Auto
	FormList Property wmMHHSorterIngotsFLST Auto

	Int IngotCount0
	
Event OnActivate(ObjectReference IngotCount)
	Actor Player = GetPlayer()
	IngotCount0 = Player.GetItemCount(wmMHHSorterIngotsFLST)

	If IngotCount0 >= 1

			Debug.Notification("Run Line ONE...")

		If IngotCount == Player
			WaitMenuMode(0.8)
			Home()
		EndIf	

	else
			Debug.Notification("Count failed...")
	Endif
EndEvent



Function Home()
	Actor Player = GetPlayer()
	Int Button = wmMHHSorterIngotsMSG.Show()

	If Button == 0
		Return StoreIngots()
	ElseIf Button == 1
		Self.Activate(Game.GetPlayer())
	EndIf
Endfunction


Function StoreIngots()

			Actor Player = GetPlayer()
			IngotCount0 = Player.GetItemCount(wmMHHSorterIngotsFLST)
			Player.RemoveItem(wmMHHSorterIngotsFLST,IngotCount0,True,Self)

Debug.Notification("Run Line THREE...")

Endfunction	

 

 

Edited by wizardmirth
Link to comment
Share on other sites

I must have missed that part in my readings but thanks for pointing it out to me. It works, but only once I loaded a save from an outside cell and before the container was loaded (in case anyone else is troubleshooting their own script and needs to do the same). I'd post a screen shot from within my mod to thank you but right now I have totally skewed screenshots for some reason. So thanks (without screens) and kudos for your link suggestions and thoughts!

Link to comment
Share on other sites

I can't see any reason why your calling Self.Activate(Game.GetPlayer()) if the player doesn't want to add ingots.

 

Since the container is already been activated, it shouldn't be needed.

The container inventory would show reqardless without calling activate again.

 

It looks like it has the potential to get stuck in a loop.

User activates container and they have ingots in their inventory..

Script asks do you want to add your ingots?

User say no (script activates again)..

Script asks do you want to add your ingots?

User say no (script activates again)..

Script asks do you want to add your ingots?

User say no (script activates again)..

Script asks do you want to add your ingots?

User say no (script activates again)..

Script asks do you want to add your ingots?

User say no (script activates again)..

etc..

 

Right up until the user finally says yes and the ingots get added to the container and they no longer have ingots in their inventory....

Then they can escape the loop...

 

Here's your script from above.

I have compiled it an tested it and it works fine for me:

Scriptname wmIngotTestSCRIPT extends ObjectReference
{11 Ingots Sorter}

Message Property wmMHHSorterIngotsMSG Auto
FormList Property wmMHHSorterIngotsFLST Auto
Actor Player

Event OnInit()
    Player = Game.GetPlayer()
EndEvent

Event OnActivate(ObjectReference akActionRef)
    If akActionRef == Player
        Int iCnt = Player.GetItemCount(wmMHHSorterIngotsFLST)
        If iCnt > 0 && wmMHHSorterIngotsMSG.Show() == 0
            Player.RemoveItem(wmMHHSorterIngotsFLST, iCnt, True, Self)
        EndIf
    Endif
EndEvent

Here's my test esp with the compiled and uncompiled script.

Chest in Whiterun Bannered Mare Inn behind counter:

 

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

Hey thanks for pointing that out. I went back and certainly failed to test that aspect before my last comment -- mostly because I was too excited to get anything else to work which pretty much sums up me learning anything Skyrim modding related.

 

The example I worked off of is of course more complicated than I need, though for their own intentions quite perfect I'm sure. Can you at least show me how I should trim my existing script so it doesn't do that? This way I can compare with yours and see how to better streamline my efforts.

 

P.S. I should also note that I'm only now just seeing that calling a script on a container in Skyrim does not nullify its activation unless you call it again as with previous games by the studio.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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