Jump to content

Items as None, can't be added through script?


CharmicsMods

Recommended Posts

Hello, I'm over 200 lines of code into a script I'm working on, and it's been smooth sailing, but I'm getting an issue that I can't add an item to the player's inventory.

Scriptname _CheeBurdenInventoryScript extends ObjectReference

Weapon property _ChumBurdenItem auto
MiscObject property Gold001 Auto

...

function burden()
	
	if {stuff}
	
		Game.GetPlayer().AddItem(_ChumBurdenItem)
		Debug.Notification("I am overweight!")
	
	endif
	
	Game.GetPlayer().additem(Gold001, 1) ;for debugging
	
endfunction

...

I want to temporarily burden the player if certain criteria are met. Changing the player's CarryWeight seems like a bad idea, even if through an activeeffect or something like that. So I'm using a weapon I made. It doesn't have to be a weapon but that plays nice with the rest of the script. If there's a better (safe) way of making the player encumbered, I'd be happy to use that. But for the issue at hand...

 

The issue is that while I get the notification, I do not receive the item. I added Gold for testing, and that also doesn't work. Here's my logs:

[03/23/2018 - 06:32:59PM] Error: Cannot add None to a container
stack:
	[ (00000014)].Actor.AddItem() - "<native>" Line ?
	[ (00000014)]._CheeBurdenInventoryScript.burden() - "_CheeBurdenInventoryScript.psc" Line 283
	[ (00000014)]._CheeBurdenInventoryScript.OnPlayerLoadGame() - "_CheeBurdenInventoryScript.psc" Line 68
[03/23/2018 - 06:32:59PM] Error: Cannot add None to a container
stack:
	[ (00000014)].Actor.AddItem() - "<native>" Line ?
	[ (00000014)]._CheeBurdenInventoryScript.burden() - "_CheeBurdenInventoryScript.psc" Line 288
	[ (00000014)]._CheeBurdenInventoryScript.OnPlayerLoadGame() - "_CheeBurdenInventoryScript.psc" Line 68

Two errors, the first is from my custom item and the second is from the gold. No idea why it thinks they're "None". However, you can see that it is attempting to add the items to the player correctly at least.

 

Any thoughts what's going on?

 

(Note: _CheeBurdenItem is both the item's ID and Name in CK, double-checked and copy-pasted just to be sure.)

Link to comment
Share on other sites

O I never found out you had to fill properties in CK. I think that might be it. Give me 3 minutes.

 

---------------------------------------------------------------------------------------------------------------------------------------------

 

Edit: Yeah that was -.- ppl gloss over these things. Here's how to do it in case someone else has the same issue:

 

After compiling your script, you have to update the .esp so it can communicate with the script about the items whose properties you had set to Auto.

Simply select the script in CK and hit "auto-fill all". Make sure the items are correct. Save the esp and go back to coding where it's safe and everything makes sense.

Edited by ColdHarmonics
Link to comment
Share on other sites

After compiling your script, you have to update the .esp so it can communicate with the script about the items whose properties you had set to Auto.

Simply select the script in CK and hit "auto-fill all". Make sure the items are correct. Save the esp and go back to coding where it's safe and everything makes sense.

 

To be fair 'auto-fill all' only works if the properties have the same name as the editor name of the desired object to be used. Some scripts purposefully use a generic property name so that the script can be reused in different situations with different objects. But yes, making sure the properties have the correct data assigned is a must step.

 

It is covered on the CK wiki within their series of tutorials:

https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions#Hooking_up_the_message_boxes_to_the_properties_in_the_script

https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Papyrus_Events_and_Properties#Attaching_the_Script

Link to comment
Share on other sites

  • Recently Browsing   0 members

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