Jump to content

Help with sorting script


t0n1x

Recommended Posts

Hi.
I'm new at modding and I hope that some of you could help me with this basic sorting script that I'm writing.

 

Basically the script will use this function when the button is pressed.

game.GetPlayer().RemoveItem(Books as form, TakeCount, true, BooksChest)

Since the script uses a formlist my intention was to add all the books, journals and notes from the CK but then it will remove quest books also.
One solution would be to do some research and find out what are the quest items and remove them from the list. But that has some limitations if some items are used jut once as quest items then after that quest they became ordinary again.

 

My question is.

Is there a way to make the script check if the items can be dropped? If they can be dropped continue with removal, if they cant then skip those items and remove the others.

Edited by t0n1x
Link to comment
Share on other sites

Hi.

I'm new at modding and I hope that some of you could help me with this basic sorting script that I'm writing.

 

Basically the script will use this function when the button is pressed.

game.GetPlayer().RemoveItem(Books as form, TakeCount, true, BooksChest)

Since the script uses a formlist my intention was to add all the books, journals and notes from the CK but then it will remove quest books also.

One solution would be to do some research and find out what are the quest items and remove them from the list. But that has some limitations if some items are used jut once as quest items then after that quest they became ordinary again.

 

My question is.

Is there a way to make the script check if the items can be dropped? If they can be dropped continue with removal, if they cant then skip those items and remove the others.

 

If you want help for a script you need to post the full script. If you add items to a Formlist via the kit you can not remove items from the list.

 

BTW: Does this actually compile? GetPlayer().RemoveItem(Books as form, TakeCount, true, BooksChest)

Link to comment
Share on other sites

 

You can filter quest items by using the abRemoveQuestItems parameter in the RemoveAllItems() function.

To be honest I was trying to implement that function from the wiki but I was not successful. Here is the source of the script. How would you set it. Also will using the RemoveAllItems() actually remove everything from the inventory without checking the formlist?

 

 

If you want help for a script you need to post the full script. If you add items to a Formlist via the kit you can not remove items from the list.

 

BTW: Does this actually compile? GetPlayer().RemoveItem(Books as form, TakeCount, true, BooksChest)

I'm sorry. Here is the source.

My intention is not to remove the items from the list but to check if the items can be dropped. So if they cant, live them alone and remove (from players inventory and place them in the chest) the other items from that list.

 

It does compile and it works great but is not perfect yet.

ObjectReference property Chest auto

Formlist property items1 auto
Formlist property items2 auto
Formlist property items3 auto
Formlist property items4 auto
Formlist property items5 auto


Int property TakeCount = 100000 auto hidden
Int property UseMenu auto hidden

message property MainMenu auto
message property Submenu1 auto
message property Submenu2 auto






function OnActivate(ObjectReference akActionRef)
	Int MenuResponse
	Int Menu = UseMenu
	UseMenu = -1
	if Menu == 0
		MenuResponse = MainMenu.Show(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000)
		if MenuResponse == 0 
			UseMenu = 1 
		elseIf MenuResponse == 1 
			UseMenu = 2	
		endIf
	elseIf Menu == 1
		MenuResponse = Submenu1.Show(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000)
		if MenuResponse == 0
			game.GetPlayer().RemoveItem(items1 as form, TakeCount, true, Chest)
			UseMenu = 1
		elseIf MenuResponse == 1
			game.GetPlayer().RemoveItem(items2 as form, TakeCount, true, Chest)
			UseMenu = 1
		elseIf MenuResponse == 2
			game.GetPlayer().RemoveItem(items3 as form, TakeCount, true, Chest)
			UseMenu = 1
		elseIf MenuResponse == 3
			UseMenu = 2
		elseIf MenuResponse == 4
			UseMenu = 0
		endIf
	elseIf Menu == 2 
		MenuResponse = Submenu2.Show(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000)
		if MenuResponse == 0
			game.GetPlayer().RemoveItem(items4 as form, TakeCount, true, Chest)
			UseMenu = 2
		elseIf MenuResponse == 1
			game.GetPlayer().RemoveItem(items5 as form, TakeCount, true, Chest)
			UseMenu = 2
		elseIf MenuResponse == 2
			UseMenu = 1
		elseIf MenuResponse == 3
			UseMenu = 0
		endIf
	EndIf
	if UseMenu > -1
		self.Activate(akActionRef, false)
	else
		UseMenu = 0
	endIf
endFunction
Edited by t0n1x
Link to comment
Share on other sites

There's a heap you could do to compact the code (as it's currently rather inefficient), and I'm not sure why you're defining the variables you are as script properties (assuming you don't want to manipulate them in foreign scripts). Script properties get baked into save games, so they're only useful when you want them to be remembered each time you run the script, which I'm assuming you don't (going by what you're using them for).

 

Honestly, I'm not sure what you're trying to do, given that your Menu variable will always be equal to the default value of 0. I suggest that you add feedback to various parts of the script and work through it in-game so that you know the script's working as intended. This can be achieved by using the Debug.Trace(""), Debug.Notification("") or Debug.MessageBox("") functions. Just because the script's compiling, it doesn't mean that it's working as intended.

 

As far as I can see, the RemoveItem() function isn't your issue, it's the rest of the script. Also, using the abRemoveQuestItems parameter in the RemoveAllItems() function will remove all items, without allowing you to define which items you want to remove. However, you can use this function in conjunction with the RemoveItem() function to juggle the required items between inventories in order to achieve your goal. There may be another function that allows you to determine whether an item's a quest item, but that's all I know of off hand. In Fallout 4 you don't even have this parameter in the equivalent function, so I'd consider myself lucky to have this parameter in the first place.

 

I'd be happy to help further if you had more specific questions.

Link to comment
Share on other sites

 

I'm sorry. Here is the source.

My intention is not to remove the items from the list but to check if the items can be dropped. So if they cant, live them alone and remove (from players inventory and place them in the chest) the other items from that list.

 

It does compile and it works great but is not perfect yet.

 

Unfortunately , I never scripted a Menu so my help may be limited.

 

But I can help you get the books out of inventory.

 

1. If the books on the list are your books then how are you unable to keep track of them? How are you unable to determine if they are quest items?

 

2. If you fill the lists via script you can remove them when they become a quest item and put them back when they are no longer a quest item.

Link to comment
Share on other sites

I don't believe there is any way to determine if an item is a quest item. For my sorting mod, I simply reject persistent references. That works fine for potions, crafting items, and ingredients because they are rarely persistent. For books you might find your items being rejected more often than they are accepted.
Link to comment
Share on other sites

I don't believe there is any way to determine if an item is a quest item. For my sorting mod, I simply reject persistent references. That works fine for potions, crafting items, and ingredients because they are rarely persistent. For books you might find your items being rejected more often than they are accepted.

 

Ya, If these are not his books from his quests it is going to be very hard to do. I think SKSE has that function but it is not available for SSE yet.

Link to comment
Share on other sites

 

I don't believe there is any way to determine if an item is a quest item. For my sorting mod, I simply reject persistent references. That works fine for potions, crafting items, and ingredients because they are rarely persistent. For books you might find your items being rejected more often than they are accepted.

 

Ya, If these are not his books from his quests it is going to be very hard to do. I think SKSE has that function but it is not available for SSE yet.

 

Through use of the abRemoveQuestItems parameter in the RemoveAllItems() function combined with either a second inventory (to juggle items with) or something like the OnItemRemoved() event, it should prove quite easy to specifically filter quest items. I do like the idea of taking advantage of quest items persistence though, that's not something that I had thought of. That flaw's a bit of a bummer though.

Link to comment
Share on other sites

First off all let me thank you all for finding time to reply on my request.

 

I know that this script is not the best but since my papyrus knowledge is very, very basic i had to use various tutorials and examples from the internet to make it.

Maybe I was not clear from the beginning. I apologize for that.

The script itself is not a problem. It works and I've been using it for several days now.

I'm not using the script for my books or items added by my mod, instead it is used to store vanila items. The script is used to help me unload specific types of items all at once (From players inventory to the chest.)
So when I click the button I get menus asking me what do I want to store (books, soulgems, potions, food, misc items and so on), and to know what items to store it uses formlists

 

I have created formlists for all this types of items (example: I selected all the books, notes and journals in the CK and added them to the "BooksFormList"). Now when I select to store the books it stores all books from the inventory. Even non droppable ones. So one option for me is to search on internet and find the names of all the quest items and remove them from the lists. But this would take me days.

I was hopping to find a way to tell the script to ignore non droppable (quest) items and store only the droppable ones. But apparently it is not so easy to do and I will have to edit my formlists.

Edited by t0n1x
Link to comment
Share on other sites

  • Recently Browsing   0 members

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