virginharvester Posted October 31, 2018 Author Share Posted October 31, 2018 Just some cosmetic changes for the alias script. SmeltPlayerAliasScript Scriptname SmeltPlayerAliasScript extends ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/7112681-if-player-added-spesific-item-event-in-papyrus/ MiscObject PROPERTY OreGold auto ; fill by CK MiscObject PROPERTY IngotGold auto ; fill by CK ; -- EVENTs -- 2 EVENT OnInit() ; we want to set up a filter, so we do not waste time and resources of running script when not needed self.AddInventoryEventFilter(OreGold as Form) ENDEVENT EVENT OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) IF (akBaseItem == OreGold as Form) ; should always be TRUE due to the filter above, but is always good practice ELSE RETURN ; - STOP - for some unknown reason safety net is working ENDIF ;--------------------- myF_Action(akBaseItem) ; added the item what we want ENDEVENT ; -- FUNCTION -- FUNCTION myF_Action(Form akBaseItem) ;----------------------------------- actor Player = Game.GetPlayer() ; obtain the player data only once, and store it as local variable int i = Player.GetItemCount(akBaseItem) ; hold the count of "OreGold" also as local variable IF (i < 2) RETURN ; - STOP - player has only one item of "OreGold" ENDIF ;--------------------- and now figure out how many ingots can be transformed i = i - (i % 2) ; use modulo to get the result (0 or 1) Player.RemoveItem(akBaseITem, i, TRUE) ; remove the ores Player.AddItem(IngotGold as Form, i/2, TRUE) ; and add the half count of ingots instead ENDFUNCTION You also asked: "how to adding empty formlist?" use a script variable like this FormList emptyListbut it does not make sense by using the following self.AddInventoryFilter(emptyList)because adding an InventoryFilter of None (no valid formId inside the list) is doing nothing, it does not remove any filter you added beforethanks, for reply, i test this too, the compile is succeed,for the formlist i though it will fix the "AddInventoryEventFilter" turn out it not Link to comment Share on other sites More sharing options...
foamyesque Posted October 31, 2018 Share Posted October 31, 2018 You are extending quest this is the reason for compilation errors. For both AddInventoryEventFilter and OnItemAdded to work (in this instance) the script needs to be attached to a quest alias that points to the player. As such the script would extend ReferenceAlias. Once the script extends ReferenceAlias, it will compile without issue. For consistency, I would remove the space between AddInventoryEventFilter and (OreGold). It compiled without error with the space present, but without testing, I do not know if the space will cause an issue with execution in-game. Papyrus ignores whitespace, so that's not an issue. for the formlist i though it will fix the "AddInventoryEventFilter" turn out it not Can you provide details on your current code, on what you're expecting it to do, and what's actually happening? Link to comment Share on other sites More sharing options...
virginharvester Posted October 31, 2018 Author Share Posted October 31, 2018 You are extending quest this is the reason for compilation errors. For both AddInventoryEventFilter and OnItemAdded to work (in this instance) the script needs to be attached to a quest alias that points to the player. As such the script would extend ReferenceAlias. Once the script extends ReferenceAlias, it will compile without issue. For consistency, I would remove the space between AddInventoryEventFilter and (OreGold). It compiled without error with the space present, but without testing, I do not know if the space will cause an issue with execution in-game. Papyrus ignores whitespace, so that's not an issue. for the formlist i though it will fix the "AddInventoryEventFilter" turn out it not Can you provide details on your current code, on what you're expecting it to do, and what's actually happening? this is my first i try to do : Event IfThisCharGetSpesificItemEvent(player,OreGold) ;or IfPlayerGetSpesificItemEvent(OreGold) if (Game.GetPlayer().getItemCount(OreGold) >=2) Count = (Math.Floor( Game.GetPlayer().getItemCount(OreGold) / 2)) Game.GetPlayer().removeItem(OreGold,2 * Count , TRUE) Game.GetPlayer().addItem(IngotGold,1 * Count , TRUE) endif endEvent i do not now what my expext to do, but i like that script work, and maybe the script not work because i put it on quest script,anyway , where i must create script if i like to do "extends ReferenceAlias" Link to comment Share on other sites More sharing options...
foamyesque Posted October 31, 2018 Share Posted October 31, 2018 Okay, I think this may need some illustrations. I'll see if I can put something together to walk you through this later today. Link to comment Share on other sites More sharing options...
Recommended Posts