Compiler errors.

Post » Tue Jun 19, 2012 11:28 am

I'm trying to set up a script so that when a specific item is sold to the player, it gets removed from the player's inventory and replaced with a different one. This is what I have so far:

Event onSell            game.getPlayer().removeItem(SnowberryImport, 1, 1)     game.getPlayer().addItem(Snowberry, 1, 1)EndEvent

It is throwing these errors on compile:

c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\aaTKSnowberryImportScript.psc(5,12): mismatched input '\\r\\n' expecting LPAREN
c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\aaTKSnowberryImportScript.psc(0,0): error while attempting to read script aaTKSnowberryImportScript: Object reference not set to an instance of an object.

And I cannot decipher them.

Could anyone correct me on where I'm going wrong?
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Tue Jun 19, 2012 5:38 am

Events are functions, and like other functions they require a set of parentheses after their identifier in their definition. http://www.creationkit.com/OnSell_-_ObjectReference has a single parameter, so you need to use this:
Event OnSell(Actor akSeller)

Cipscis
User avatar
Ross Thomas
 
Posts: 3371
Joined: Sat Jul 21, 2007 12:06 am

Post » Tue Jun 19, 2012 6:23 am

Then that brings up my next question: would it be possible to pull that parameter from a form list or alias (because multiple actors would qualify)? If so, how would I go about setting that up?
User avatar
Tiffany Holmes
 
Posts: 3351
Joined: Sun Sep 10, 2006 2:28 am

Post » Tue Jun 19, 2012 10:50 am

Sorry, I'm not really sure what you're asking for.

The parameter is passed to the event when the game calls it, which happens because it is a native event. You can use the parameter inside the event to refer to the actor doing the selling. You can compare the value of this parameter to another actor or set of actors, if you only want it to fire when a certain actor or set of actors do the selling, but the game specifies its value, not you.

Cipscis
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Tue Jun 19, 2012 7:51 am

Sorry, I'm not really sure what you're asking for.

The parameter is passed to the event when the game calls it, which happens because it is a native event. You can use the parameter inside the event to refer to the actor doing the selling. You can compare the value of this parameter to another actor or set of actors, if you only want it to fire when a certain actor or set of actors do the selling, but the game specifies its value, not you.

Cipscis

Oh, so the game fills in that parameter automatically? I was thinking I had to set that parameter myself.

Thanks for that, though. All I had to do after that was define SnowberryImport and Snowberry (Ingredient properties) and the script compiled.
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Tue Jun 19, 2012 2:51 pm

Yeah, it does. You'd only need to set it yourself if you were calling the event (like I said before, events are functions, so you can call them). When you start a line with "Event" in a script, you're writing a definition for the event, and that definition is used every time it's called, so the parameter represents an arbitrary value of a certain type.

For objects of the right type, the game itself will call native events like this one at the right time, and the values that it passes as the event's parameters will always represent the same thing (like the Actor doing the selling, as in this case).

Cipscis
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Tue Jun 19, 2012 4:38 am

Okay, I've changed the script up a bit to something I feel might work a bit better in my context:

scriptname aaTKSnowberryImportScript extends ActorIngredient property SnowberryImport autoIngredient property Snowberry autoInt property ItemCountInt autoEvent onItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    ItemCountInt = (game.getPlayer().getItemCount(SnowberryImport))    if akSourceContainer == game.getPlayer()        game.getPlayer().removeItem(SnowberryImport, ItemCountInt, true)        game.getPlayer().addItem(Snowberry, ItemCountInt, true)    endifEndEvent

But not the trouble is actually getting it to run. Its currently being attached to a quest container, but it isn't really doing anything. Nor did it function when it was attached directly to the item I wanted to remove (which I decided against in case that might interfere with the script execution). All the properties are defined in the Creation Kit for the script, too.
User avatar
brian adkins
 
Posts: 3452
Joined: Mon Oct 01, 2007 8:51 am

Post » Tue Jun 19, 2012 10:13 am

Did you say it's attached to a container? I'm surprised you even managed to get a script that extends http://www.creationkit.com/Actor_Script attached to a container.

Cipscis
User avatar
Rodney C
 
Posts: 3520
Joined: Sat Aug 18, 2007 12:54 am

Post » Tue Jun 19, 2012 9:34 am

No, it's attached to a quest right now.

So, if I'm reading you correctly, that means the script extension I must use needs to match the object you attach it to (in this case extends Quest)? It would certain support what I'm noticing in the Wiki.
User avatar
Laura Simmonds
 
Posts: 3435
Joined: Wed Aug 16, 2006 10:27 pm

Post » Tue Jun 19, 2012 2:12 pm

That's right - in order to attach a script to an object the script must extend a type that the object possesses. Each new script is the definition of a new type, and when you attach a script to an object you're adding that type to the object's list of types. The game engine automatically attaches native scripts, like http://www.creationkit.com/Quest_Script, to the right objects, so a quest with no scripts attached will only have the type "Quest", so the first script attached to any quest must extend this type.

Cipscis
User avatar
Kat Ives
 
Posts: 3408
Joined: Tue Aug 28, 2007 2:11 pm

Post » Tue Jun 19, 2012 3:03 pm

Well, that resolves the script not running, so now it is down to the game simply not liking the way the remove-add portion is coded.
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Tue Jun 19, 2012 10:55 am

Why not attach the script to the item itself and run an OnSell event? Like so...
Spoiler

scriptname aaTKSnowberryImportScript extends ObjectReference Ingredient property SnowberryImport auto Ingredient property Snowberry auto Int property ItemCountInt auto Event OnSell(Actor akSeller) 	If (akSeller != game.getPlayer()) 		ItemCountInt = (game.getPlayer().GetItemCount(SnowberryImport)) 		game.getPlayer().removeitem (SnowberryImport, ItemCountInt, true) 		game.getPlayer().additem (Snowberry, ItemCountInt, true) 	endif EndEvent
User avatar
Andrew
 
Posts: 3521
Joined: Tue May 08, 2007 1:44 am

Post » Tue Jun 19, 2012 2:54 pm

Why not attach the script to the item itself and run an OnSell event? Like so...
Spoiler

scriptname aaTKSnowberryImportScript extends ObjectReferenceIngredient property SnowberryImport autoIngredient property Snowberry autoInt property ItemCountInt autoEvent OnSell(Actor akSeller)	If (akSeller != game.getPlayer())		ItemCountInt = (game.getPlayer().GetItemCount(SnowberryImport))		game.getPlayer().removeitem (SnowberryImport, ItemCountInt, true)		game.getPlayer().additem (Snowberry, ItemCountInt, true)	endifEndEvent

Because of an issue with CTDs when attaching scripts to ingredients. I have to do it this way in order to avoid that.
User avatar
Jack
 
Posts: 3483
Joined: Sat Oct 20, 2007 8:08 am


Return to V - Skyrim