Jump to content

Item selection menu, some scripting help/ideas needed.


Recommended Posts

So i want to have a menu in which you choose an item in from your inventory and stuff happens depending on your choice. The choice will be by reference, the ones i care about will be persistent and if not it will notify that is has to be dropped, moment in which they stop being "item XX in container YY" and point a variable to itself.

 

Back to the topic, my first idea was a gift menu run on an actor on a holding cell. Him having this script:

Scriptname lalala extends Actor  

Import Game
Import Debug
FormList Property List Auto
ObjectReference ItemSelected

ObjectReference Function ItemSelectMenu()
ItemSelected = None
ShowGiftMenu(true, List , true) ;latent, waits for the menu being closed before returning, which is great
Return ItemSelected
EndFunction


Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) ; send it back, i want to select not loose items.
If (akItemReference) && (akItemReference.GetbaseObject())
ItemSelected = akItemReference
DisablePlayerControls(false, false, false, false, false, true, false, false) ; this is supposed to close the menu since we already have the selection, but no luck...
EnablePlayerControls(false, false, false, false, false, true, false, false)
Else
MessageBox("ref isn't good, can't do stuff")
Endif
EndEvent

The thing is the disable/enable player controls isn't closing this menu (it does on others i've tested) which breaks the whole system since only a single item should be selected.

 

Any ideas of how to close it, or another way to approach this.

 

Another way I considered is doing a brute-force GetNthForm scan of the player inventory in search of the items in the list, form an array with them and use Skyuilib list menu (i'm already using Skyuilib), BUT then realised it's GetNthForm, not GetNthReference, I need to get specific references within the container so this looks like a dead end.

Link to comment
Share on other sites

How about instead of an actor, utilize a bag of holding as it were. A token armor object that when in the player inventory they can equip it when inventory is open or use spell/power/hotkey/favorite key to access a remote container. I know that you can disable/enable player controls when accessing a container in order to access another container.

Link to comment
Share on other sites

So, instead of showgitmenu activate a container thst refuses all items but stores the ref passed and closes?

 

How could i make the script wait for item selection there? One theoretical benefit of showgiftmenu is that it waits for the closing of the menu. (The above script works fine if i manually close the menu after selecting a single item)

 

Would tapping the tab key from the script be a reliable way to do it?

Link to comment
Share on other sites

Maybe I'm not understanding what you are trying to accomplish then.

 

I thought you could simply open a container, player puts an item in and the item is returned. The item reference is checked and either it is persistent and passes or is not and fails. If it is persistent, pass it into your variable and do stuff including testing to see if you can close that menu by disabling player controls. If it is not persistent do whatever else you want.

 

To me it seems to be the same principle only on a container using the container menu instead of on an actor using the gift menu.

 

Yes, you could tap the key. That was going to be my first suggestion but I'm not 100% certain that it will work with those users who use a controller. Not having a controller myself, I've never been able to test it and have to rely on the rumors/reports out there.

Link to comment
Share on other sites

The good thing about the gift menu is that i can filter the items that appear on the menu, not massively important but makes it faster.

 

I'm calling ItemSelectMenu() from an activator, i need it to return the object reference that was selected (given it was valid, otherwise none) So the function would need to wait for the event before returning, a while loop waiting for OnItemAdded to set a variable?, with the container method i'd have to make it register for menu too just in case you don't select any item and close the menu, the function has to return none.

 

Good point about the controllers...

 

On second thought i'd have less problems if i move the whole stuff-doing from the activator calling the ItemSelectMenu function to the onitemadded event itself, so the function that opens the inventory doesn't have to return or wait for anything. I think i was overcomplicating it.

 

The filtering is still a feature that would be nice to add, no way to do that with a container, right?

Link to comment
Share on other sites

All items would be available for the player to put into the container. No way I know of to filter out what is displayed.

 

Have you tried using the barter menu? I don't know how it would behave with the disabling of player controls, and there is the concern of change in player held gold (but that could be dealt with). You would, however, have the ability to filter what appears.

Link to comment
Share on other sites

Haven't tried the barter menu but i'll test if it can be closed by disabling controls, thanks :smile:

 

On another front if i use GetMappedKey to get the code assigned to "Tween Menu" control (i guess it's that one because it's the only menu related one) and tap that, would it solve the controller compatibility isssue?

Link to comment
Share on other sites

I also tried to use DisablePlayerControls to close a container menu, but it doesn't work. I guess it only works for the inventory menu. If you want only one item to be selected, you could store the base object of the last item selected in a variable, and wait until the player closes the menu by himself. If he selects another item, it will replace the variable, so only the last one will be valid.

 

Not sure if I understand what you're trying to do, but if the items that can be selected are not many, perhaps you could try to make a custom crafting menu. Something like what Chesko did with Campfire. When you activate the campfire, a custom crafting menu appears allowing you to craft some stuff, including fake items that improve the campfire. You can add conditions to the recipes (with perks or whatever) to filter what can be selected. A condition could disable all options once one of the items is "crafted".

Link to comment
Share on other sites

Just had a thought... No idea if it will work...

 

Create a formlist with the base form of each object type you want to look for.

Create a script on a player alias that uses an inventory event filter with said formlist as the allowed items

Then use OnItemAdded on that script to obtain object references coming in to the player that are on that formlist and are persistent.

Store those in an array and use that array to populate the SkyUILib menu

Then player picks from that list and do whatever from there

Link to comment
Share on other sites

  • Recently Browsing   0 members

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