Jump to content

[LE] Papyrus Error: RemoveItem does not exist


09jlardinois

Recommended Posts

I've been trying to compile a simple script that removes 1,000 gold from the player. The compiler keeps telling me that Gold001 and RemoveItem do not exist.

I have my script extending Actor (which extends ObjectReference), so there's no reason that the "RemoveItem is not a function or does not exist." should be popping up.
The compiler shows that it is loading both Game.psc and Actor.psc with "unknown user flag hidden". But even though Actor extends gameref, it's not finding the RemoveItem function there. The code is as follows.

Scriptname MyScript Extends Actor

Event OnInit()
	Game.GetPlayer().RemoveItem(Gold001, 1000, true)
EndEvent

So then it also says that Gold001 does not exist. I tried adding a Form Property like so,

Form Property goldItem Auto

But this line of code makes absolutely no sense. There is absolute zero way that the game can determine that goldAuto is supposed to represent the item 000000f or Gold001.

Form Property goldItem = Game.getForm(Gold001)

...
... RemoveItem(goldItem)
...

Tells me that Game.psc does not exist. I can't fathom how you can type in Form Property [somerandomvariablename] and the game determines exactly which item / object you intend to have there. Clearly, this does not work. I have been Googling this problem since 5:00PM CST. It's currently 3:24AM the next day.... I'm going insane, I swear.

The search results amount to,
"Oh, I have this same problem!"
"nvm, figured it out, bye!"
With nobody posting a solution.

Tutorials about

  1. Forms
  2. Properties
  3. Actors
  4. ObjectReference
  5. Extending
  6. Compiling
  7. Eating a Horse

are all miserably incomplete and unhelpful across the entire internet. I came here as a last resort because I hate to bother you guys with such noob questions.

It's a very basic, beginner question, I'm sure, but I'm driven mad by the sheer hours I've put into Googling this and the fact that I am fluent in C++, C#, Lua, Python, Java, JavaScript, VisualBasic, Basic, SQL, HTML, PHP, CSS and anything you throw at me, but then some rinky-drink, slapped-together Bethesda middleware script kiddie garbage pops up and I roll a critical failure apparently and end up breaking the universe trying to write the simplest, most basic, hello-world-level papyrus script. Moral of the story? Papyrus is trash.

Can anyone restore my sanity so that I don't have to go to the Shivering Isles and be a slave to Sheogorath for all eternity?
Thanks, really, truly, I mean it. Any help at all would mean a lot. I'm goin' nuts over here...

Link to comment
Share on other sites

Aside from extracting the scripts.rar folder to have access to the source scripts...

A little explanation on how properties work (please note that the words I use may not match those on the Creation Kit wiki, yet the meaning I give them should be.):

 

<type> <declaration> <variable> <definition> <modifier>

 

type is the object type of the data you want to use. Int for integers, float for floats, string for strings, weapon for weapons, armor for armors, etc

declaration is simply put stating that it is a property rather than a local variable

variable is the name that will be used to reference the data throughout the script. If this variable name is the same as the Editor ID of the desired object Auto-fill can be used.

definition is the defining of how the property will function when used. Typically Auto is used tho in some rare cases a definition may be written fully in order to perform something different.

modifier is usually not used. There are cases, however, where Hidden is used to hide a property from the Creation Kit GUI.

 

Once a property is fully declared and defined on a script, it needs to be 'hooked'. This is done by highlighting the script entry on the object that it is attached to and pressing the properties button. A new window appears. Highlighting a property will populate the empty grey area to the right with various input boxes depending upon the type of property. If any property has the same variable name as the Editor ID of the target object then you can use Auto-fill either individually when highlighted (auto-fill button at the right) or all at once (auto-fill button at the lower left).

 

In your case, your property definition would be:

MiscObject Property Gold001 Auto
Link to comment
Share on other sites

After you learn how to add a properly in your script so the game knows what you are trying to take from the player as IsharaMeradin has shown you. Learn how do make a quest. Adding script directly to an actor is generally not a good idea. Make them a reference alias and do it from there.

 

Keep up the good work! :devil:

Edited by Masterofnet
Link to comment
Share on other sites

Aaaah crap. Thanks, guys. You've helped a lot. I realize I was completely misinterpreting some of the things about Properties... whoops. It is starting to make sense. I'm not used to this "property" idea, because I'm used to just declaring variables as global and having objects directly declared, rather than storing a reference to something else.

 

Yeah, I did extract that Source.zip folder, it did fix a few errors.

 

That idea of "<type> <declaration> <variable> <definition> <modifier>" makes a lot of sense now to me. It's like saying, "Global Float percentageCheck = 00.00" kind of thing. The Definition part I'm still not terribly familiar with, but I think it will start to make sense. I didn't realize that "Auto" made it search for the matching ID. In all my searching, I couldn't find information on the Auto part.

Link to comment
Share on other sites

Just wondering why you would want to do ...

 

Event OnInit()

Game.GetPlayer().RemoveItem(Gold001, 1000, true)

EndEvent

 

So, as soon as the game starts each time you want to take

1000 gold from the player ????

 

Whoops, that's not what I intended. I have this script attached to a perk so that when you buy the perk, it removes 1,000 gold. I thought that OnInit() would only trigger when the script was loaded when the perk was bought. I didn't realize that this triggers every time the game loads.

 

The effect I'm trying to go for is to have multiple levels of the Master Trader perk as part of a bigger personal project, and each increasing stage of Master Trader removes gold from the player as additional "payment" for the perk.

 

The perk is tiered at:

1000

2500

3000

4000

5000

 

So that The total additional gold comes out to 14,500.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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