antstubell Posted November 25, 2019 Share Posted November 25, 2019 (edited) I have 8 containers that I have scripted to set a global based on the item's keyword that is placed in them.Example:- Shell and Sextant both have the keyword 'Nautical'. So one of the containers 'reports' when the keyword of an item placed in it matches its accepted keyword and sets a Global Variable to 1. If the item's keyword does not match then the Global Variable is set t 0.The Global Variable of each chest will be checked after player has finished placing items to make sure all Globals = 1 and if they do we proceed to the next stage.I scripted the event and then I thought "What if player removes a matching item?", so I scripted another event to cover this scenario. All of these does work as intended, now the BUT. What if player has placed 2 or more matching items with the correct keyword and removes one of them? This would set the Global to 0 (matching item removed) but in fact there is still a matching item in the container.I'm guessing the solution is that when the check for each container is done - OnActivate… blah, blah, check containers - that the script needs to check if at least 1 of the items in each chest has a matching keyword that corresponds to that particular container. This negates the checking of the global variables.I hope I put this across clear enough.This is the simple script I am using now and help is greatly appreciated. Keyword Property VendorItemWeapon AutoGlobalVariable Property MyGlobal AutoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)If akBaseItem.HasKeyword(VendorItemWeapon)Debug.Notification ("A Matching Keyword Item Was Added.")MyGlobal.SetValue(1)ElseDebug.Notification ("A npn-Matching Keyword Item Was Added.")MyGlobal.SetValue(0)EndifEndevent;-----------------------------------------------------------------------------------Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)If akBaseItem.HasKeyword(VendorItemWeapon)Debug.Notification ("A Matching Keyword Item Was Removed.")MyGlobal.SetValue(0)ElseDebug.Notification ("A Matching Keyword Item Was NOT Removed.")MyGlobal.SetValue(1)EndifEndevent Edited November 25, 2019 by antstubell Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 25, 2019 Share Posted November 25, 2019 Lets use MOD instead of SET for the global variable. And then check for the value to be either 0 or anything greater. This way, if the player adds two or more different items with the correct keyword the value will keep going up. If they remove some, the value will drop but won't get wiped to 0 unless all of them were removed. Using your script: Note that I tweaked the notification string so that it can show the value updating as items are added / removed Keyword Property VendorItemWeapon Auto GlobalVariable Property MyGlobal Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem.HasKeyword(VendorItemWeapon) MyGlobal.ModValue(1) Debug.Notification ("A Matching Keyword Item Was Added. "+MyGlobal.GetValueInt()+" item(s) in container") Endif Endevent ;----------------------------------------------------------------------------------- Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem.HasKeyword(VendorItemWeapon) MyGlobal.ModValue(-1) Debug.Notification ("A Matching Keyword Item Was Removed. "+MyGlobal.GetValueInt()+" item(s) in container") Endif Endevent Link to comment Share on other sites More sharing options...
antstubell Posted November 25, 2019 Author Share Posted November 25, 2019 Brilliant. I should have thought of that - but didn't. Link to comment Share on other sites More sharing options...
Recommended Posts