Jump to content

Papyrus Help : inspect all items carry by player


Recommended Posts

sorry for my bad English

I tried to convert this from Python to papyrus,

I looked for hours but not found,

please help

#get all item in player container
playeritems = player.inv
#check each item/element using "For Loop"
for playeritem in playeritems :
    if playeritem.HasKeyword(ObjectTypeFood) :
        Player.EquipItem playeritem
        #after player consume item food, break the "For Loop"
        break
Link to comment
Share on other sites

Player.inv is not a papyrus function.

You need to look up the Papyrus functions.

Most likely you will need to use GetInventoryItems() which is an F4SE function https://falloutck.uesp.net/wiki/GetInventoryItems_-_ObjectReference

Then you need to look at some base game scripts to understand the Payrus script structure and format.

Link to comment
Share on other sites

35 minutes ago, SKKmods said:

Player.inv is not a papyrus function.

You need to look up the Papyrus functions.

Most likely you will need to use GetInventoryItems() which is an F4SE function https://falloutck.uesp.net/wiki/GetInventoryItems_-_ObjectReference

Then you need to look at some base game scripts to understand the Payrus script structure and format.

thank you for the answer,

and this is the result:

Form[] items = player.GetInventoryItems()
Bool bBreak = False  
int currentItem = 0
While (currentItem < items.Length) && !bBreak
	Form item = items[currentItem]
	If playeritem.HasKeyword(ObjectTypeFood)
		Player.EquipItem playeritem
		bBreak = True    
	Endif
	currentItem += 1
EndWhile

sadly I can't test the code because I use it in the console command, and this "form" must be run in a PSC extension,

and do not have a clue how to trigger it to run

Link to comment
Share on other sites

You will need to read or watch a how to create and compile papyrus scripts tutorial.

There are many on youtube.

The Bethesda Mod School series is good.

Link to comment
Share on other sites

sorry if i rude, after many times  tried, the script is not run even the compile succeed

but the result not appear
 

Scriptname AutoConsume extends Quest
MiscObject Property Caps001 Auto
Actor PlayerRef

Event OnInit()
    RegisterForKey(160); left shift
endEvent

Event OnKeyDown(Int KeyCode)
    If KeyCode == 160
        PlayerRef = Game.GetPlayer()
        Game.GetPlayer().AddItem(Caps001,1000)
    EndIf
EndEvent

but when i press "left shift" the caps do not increase, why?

and second, how to produce warning box like his :40747-1599933015-888326014.thumb.webp.8725023d24bc832daa850433f6b50d5a.webp

Link to comment
Share on other sites

  • Recently Browsing   0 members

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