JustChill Posted June 29, 2018 Share Posted June 29, 2018 Hey there, I am about to make a custom container which should only allow the player to put "Aid" inside. However, this turns out to be some trouble.I haven't found a function which forces the player inventory (the one on the left side) to only show "Aid". So I rather show a short message before the player opens the container that only aid is allowed and then disable the mouse control."DisableKey 256".This works fine. Any inventory object which is highlighted but not GetType == 47 will automatically disable the mouse button.If there is no inventory object highlighted or one which is actually aid the mouse button will be enabled again. Now I've the problem that the "Return / Enter" button still allows the player to move any other stuff than aid into the container.I've triedDisableKey 28 ;==> Regular "Return / Enter"DisableKey 156 ;==>NUM Pad "Return / Enter" But these both don't work. The player can still move stuff by using those keys even if they should be disabled by those functions. Easiest way would be to simply show the "Aid" filter and disallow any filter change.I am very bad with XML coding, so I have literally no idea how to do that. :(Just found a function to check which filter is currently active:https://geckwiki.com/index.php/GetMenuItemFilterBut there is no "Set" equivalent available. I appreciate any idea. :) Cheers Link to comment Share on other sites More sharing options...
JustChill Posted June 29, 2018 Author Share Posted June 29, 2018 Just out of curiosity... The scancodes are global, aren't they? I use a QWERTZ keyboard instead of an english QWERTY. Yet the "Enter / Return" button should have the same scancode for these, no? Link to comment Share on other sites More sharing options...
dubiousintent Posted June 29, 2018 Share Posted June 29, 2018 I'm afraid it's a bit more complicated than that. See this Wikipedia article. And it's not a static target. MS has evolved it's approach and documentation over time. Now it uses "virtual key codes". Current list is here. Also, see this (though it does appear the "Enter" key is not affected). And that's just from a quick search on the phrase "microsoft directx key scancode". The key question appears to be: "what was the standard in use at the time the game was designed/released (2010)?" -Dubious- Link to comment Share on other sites More sharing options...
JustChill Posted June 29, 2018 Author Share Posted June 29, 2018 Hey thanks for the input... The funny thing is I definitely verified the scancode to be correct ingame.I got the scancodes from here:https://geckwiki.com/index.php/IsKeyPressed In addition I have used this in the game mode block: If IsKeyPressed 28 MessageEx "YOU SUCK!" endif Everytime I pressed enter, the game told me that I suck.But somehow the disabling of the keys doesn't work in container view even if I use the exact same scancode. It works for the mouse button "256". I cannot click on any item which is no aid item.But with "Enter / Return" or "NUM PAD Enter / Return" I still can add any item I want into the container, even though the keys should be disabled. :sad: Link to comment Share on other sites More sharing options...
Mktavish Posted June 29, 2018 Share Posted June 29, 2018 How about a script on the container like this using these 2 functions ... http://geck.bethsoft.com/index.php?title=RemoveAllTypedItems#List_of_type_codeshttp://geck.bethsoft.com/index.php?title=MenuTapKey SCN MyAidContainerScript Int DoOnce Begin OnActivate Player Set DoOnce to 0Activate End Begin MenuMode 1008 RemoveAllTypedItems Player MyAidList ; not sure if or what int codes needed ? If DoOnce == 0 MTK 208 ; to get it cycling the player inventory MTK 205 MTK 205 MTK 205 ; this 3rd key press will leave it filtered for Aid items Set DoOnce to 1 endifEnd ~~~~~~~~~~~~~~ So basically you are just putting items back in the player inventory if they are not in your aid list. And when you open the container , it will filter to show only aid items in the player inventory. But they can still change it and try putting items in. Add edit: sorry that first link is showing you the int code list first , but just scroll up and you will see the syntax for the function. Link to comment Share on other sites More sharing options...
EPDGaffney Posted June 30, 2018 Share Posted June 30, 2018 Haven't done much with menus, but just a guess, could it be that you were navigating with the directions and the mouse pointer wasn't technically highlighting the menu item? You could post the script maybe, because this sounds really odd. Link to comment Share on other sites More sharing options...
JustChill Posted June 30, 2018 Author Share Posted June 30, 2018 Sure thing. That's how far I got until I discovered the script errors in console with my planting script. :sad: scn GSFarmFoodLockerScript Float GSWasOpened float GSMessTime Ref rWhoAmI Ref rContCheck Ref rMenuItem Begin OnActivate Player if GetOpenState == 3 ;=> We only want to activate / open the locker when it is closed. Set rWhoAmI to GetSelf ;=> ONLY THE FOOD LOCKER WILL PROCESS THE SCRIPT, by using that variable! Set GSWasOpened to -1 ;=> To ensure the reference is not set to zero during opening animation (as that counts as game mode). Playsound DRSFootLockerOpen if GSMessTime == 0 Set GSMessTime to 5 ;=> This is basically useless, as the menu view blocks messages. MessageExAlt GSMessTime "You only can store aid in the food locker!" Set GSMessTime to GSMessTime / 2 elseif GSMessTime != -1 ;=> But I also use this variable to turn off the message after a few times. So I leave it. MessageExAlt GSMessTime "You only can store aid in the food locker!" Set GSMessTime to GSMessTime / 2 if GSMessTime < 1.25 Set GSMessTime to -1 endif endif Activate Player endif End Begin MenuMode 1008 if rWhoAmI != 0 ;=> This is necessary as otherwise any other container would also process this block Set GSWasOpened to 1 ;=> And there are plenty container in this interior, but only one will return an actual reference. Set rMenuItem to GetSelectedItemRef If IsFormValid rMenuItem ;=> 101 if rMenuItem.GetType == 47 EnableKey 256 EnableKey 28 else DisableKey 28 ;=> This doesn't work. "Return / Enter" key still functional. DisableKey 256 ;=> This works. Left mouse button doesn't do anything as long a wrong item is highlighted. endif else EnableKey 256 EnableKey 28 endif endif End Begin GameMode if rWhoAmI != 0 && GSWasOpened != -1 Set rWhoAmI to 0 ;=> When things are done (menu closed), the reference is cleared again. endif If GSWasOpened >= 1 && GSWasOpened < 2 Set GSWasOpened to GSWasOpened + GetSecondsPassed elseif GSWasOpened >= 2 Set GSWasOpened to 0 Playsound DRSFootLockerClose ;=> This will make the closing sound at the right moment. endif End Link to comment Share on other sites More sharing options...
Mktavish Posted June 30, 2018 Share Posted June 30, 2018 Well even if you can get the method of disabling non aid items to be clickable.You could still auto filter the player menu to their aid items upon opening the container with the DoOnce variable and the 4 MenuTapKey's. And maybe somehow you could then disable the menu interface button that changes the inventory filter , therefore not needing to disable inventory items.IDK , thought it worth a mention. Add edit : so a quick look , and me not really knowing how event handlers work. But would these 2 functions work to disable the menu filter ? http://geck.bethsoft.com/index.php?title=GetActiveUIComponentNamehttp://geck.bethsoft.com/index.php?title=SetOnMenuClickEventHandler And maybe this one will help also http://geck.bethsoft.com/index.php?title=GetMenuItemFilter Link to comment Share on other sites More sharing options...
JustChill Posted June 30, 2018 Author Share Posted June 30, 2018 Thanks for that input.I'm gonna try it out. :) Link to comment Share on other sites More sharing options...
EPDGaffney Posted June 30, 2018 Share Posted June 30, 2018 Can someone with an American keyboard try these? I tested and it's not working for me, either. I have a sort of elegant workaround, but I would prefer to do it properly and only use this if absolutely necessary: When the player activates the container, have them actually open the container of an NPC.Whenever the player is highlighting an aid item, set the NPC's carryweight to its default, which you can make 5 bajillion or something.Whenever the player is highlighting a non-aid item, set the NPC's carryweight to whatever their current inventory weight is.Set it back to 5 bajillion (or something) once the player is no longer highlighting the non-aid item. I would prefer an event handler for this as well, personally, as Mktavish suggests. But I would like all links to point to the more updated geckwiki.com (or geck.technodeep.net), rather than the old wiki, if we could do that. Link to comment Share on other sites More sharing options...
Recommended Posts