Script for replacing item

Post » Wed Jun 20, 2012 5:17 am

That's because PlaceAtme only returns a reference to the first one placed. You have to place one at a time, or you lose any reference to the others.
The script doesn't placeatme more than 1 thing at a time, he doesnt even have a second parameter on it

The problem more likely has something to do with the script running twice at the same time or something like that
User avatar
danni Marchant
 
Posts: 3420
Joined: Sat Oct 07, 2006 2:32 am

Post » Wed Jun 20, 2012 2:11 am

I tried doing this:

Scriptname HT_PlayerDropTrap extends ObjectReference {A script that will replace the dummy item with an actual trap when the player drops it.}Activator Property HT_TrapActivator  Autoevent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)ObjectReference[] MakeItems = new ObjectReference[5]int count = 0if (akOldContainer && !akNewContainer)  while count < 5   MakeItems[count] = Self.PlaceAtMe(HT_TrapActivator)   Count += 1   Delete()  endwhileendifendevent

It was rather amusing:
Each time I dropped one trap five spawned. :P
However, dropping more than one at a time still didn't work.

I am too tired to think right now, I will check back in the morning. Thanks for all the help today. =)
User avatar
Ana Torrecilla Cabeza
 
Posts: 3427
Joined: Wed Jun 28, 2006 6:15 pm

Post » Wed Jun 20, 2012 8:16 am

New day, let's see if I can get this to work now.

There are two problems: The script works fine if I drop only one trap from each category (iron, steel). But if I drop a second of either type when there's a trap out the script only works about 33% (<- me guessing) of the time. It seems to work best if I drop a trap, wait for about a minute, then drop the second trap. if I drop a trap wait only a few seconds and then drop the next trap chances are there's gonna be a dummy item on the ground, instead of the activator. Again this does not apply when dropping traps of different types (iron, steel).
The iron and the steel trap script are exactly the same, the only thing that is different is my pre-set properties; which points at different activators. (And, of course, the fact that they are attached to two different dummy items.)
I am guessing it's either the properties or, more likely, the script itself that messes things up.

The second problem, probably a bi-effect of the first problem: if I drop several traps at once it ends up spawning the first trap, then a bunch of dummy items. (As if the script is unable to fire fast enough.) I am guessing that solving the first problem automatically solves the second problem.


EDIT: I tried dropping 7 pieces of coal at the same time. They ended up being one piece of coal with a "(7)" - meaning I can pick them up with a single click, instead of one click per coal.
I knew that gems, such as rubies does not stack this way; so dropping 7 would mean I have to click "E" 7 times to pick them all up again. I thought this might be the problem.
I based my Dummy item on a ruby instead of a piece of coal, but it still doesn't work. Same problems as before. =(


EDIT #2: It seems that whenever I stack up my dummy items in my inventory the script only runs on "the first item". For example: I pick up one dummy and drop it - works perfectly. I pick up three dummies and drop only one. -If it is the "first" item the trigger works perfectly. If I then decide to drop the two others, without picking up the "first", nothing happens - the dummy items are dropped and the script does not run. So I have to pick them all up and "cycle through" them. The easiest way to do this was to drop all three, then pick them up. If I drop all three again the first item dropped will work. The other two will be dropped as dummy items (not working).
-Is there a way to keep traps from stacking in the inventory? (Make them "unique" or something.) I know it will clutter up the inventory and look really ugly, but I would prefer that over forcing the player to only own one trap at a time.


EDIT #3: Would it be possible to count the number of dummy items in the player's inventory before and after the drop?
User avatar
Shae Munro
 
Posts: 3443
Joined: Fri Feb 23, 2007 11:32 am

Post » Wed Jun 20, 2012 4:18 am

Not sure if you can grab the quantity of a stack of items being dropped, but you would need to set the count variable based on the number in the stack (and do it more than once if there were too many to fit in the array.)

My example was just to handle a stack of five...you would need to catch the stack count, set a variable N to how many are in the stack, and make the array big enough that it can catch a lot of them. An array of 128 should be plenty unless the player is completely insane dropping that many traps at once.
User avatar
Stacyia
 
Posts: 3361
Joined: Mon Jul 24, 2006 12:48 am

Previous

Return to V - Skyrim