Jump to content

Tailor Script Problem


gerg357

Recommended Posts

Im running a script that i made/edited that will drop a random item from a leveled list if certain conditions are met.. Im wondering if maybe its the placeatme thats causing the issue here is my code

Scriptname CreateclothesScript extends ObjectReference

LeveledItem Property ClothesFarm Auto
LeveledItem Property LItemClothesFarmAll Auto
LeveledItem Property LItemClothesRegular Auto
LeveledItem Property LItemClothesWork Auto
LeveledItem Property LItemClothesAll Auto
LeveledItem Property LItemFineClothes50 Auto

Message Property lackmaterials Auto
Message Property failure Auto
GlobalVariable Property dlinen Auto
GlobalVariable Property tailorthread Auto
GlobalVariable Property tailorneedles Auto
ObjectReference Property clothesplace Auto

Event OnActivate(ObjectReference akActionRef)

if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this
return
endif
if (tailorthread.GetValue() >= 5 && tailorneedles.GetValue() >= 1 && dlinen.GetValue() >= 5)

dlinen.SetValue(dlinen.GetValue() - 5)
tailorthread.SetValue(tailorthread.GetValue() - 5)
int random = Utility.RandomInt(0, 5)
If random == 0
clothesplace.PlaceAtMe(ClothesFarm,1)
elseif random == 1
clothesplace.PlaceAtMe(LItemClothesFarmAll,1)
elseif random == 2
clothesplace.PlaceAtMe(LItemClothesRegular,1)
elseif random == 3
clothesplace.PlaceAtMe(LItemClothesWork,1)
elseif random == 4
clothesplace.PlaceAtMe(LItemClothesAll,1)
elseif random == 5
clothesplace.PlaceAtMe(LItemFineClothes50,1)

else
failure.Show()
endif

else
lackmaterials.Show()

endif

EndEvent

 

what its doing is its creating stuff fine but then it makes boots. Once i pick them up it just spams stuff at the spawn point.. Im guessing i should maybe use a chest to put this in since picking up the boots is causing the glitch... ??

Link to comment
Share on other sites

I don't see any reason for your script to be spamming items. Its clearly designed to place one item per activation. What is the script attached to? Could it be possible that you over activated the object and thus built up a queue of items to be spawned? The only other thing I could think of is something going wonky with the leveled item selection process and multiple items are chosen instead of just one. You could make sure that your leveled item list is properly spread out among levels instead of a whole bunch at one level.

 

Side note:

Its one thing to use SetValue() when you want to ensure that the global variable is at a specific value, i.e. setting user selected values in an MCM script. But when you are going to be modifying the value by a set amount its better to use Mod(). For example, dlinen.SetValue(dlinen.GetValue() - 5) would become dlinen.Mod(-5).

Link to comment
Share on other sites

what is kicking off the OnActivate

if it's a box then yes it will keep spawning items the way you got it set up.

 

for a box trigger you need something like this

 

Int InTrigger = 0

 

Event OnTriggerEnter(ObjectReference akTriggerRef)
if (InTrigger == 0)
if akTriggerRef == Game.GetPlayer()
InTrigger += 1
;debug.notification("Entered Trigger")
gotoState("done")
endif
endif
EndEvent
Event OnTriggerLeave(ObjectReference akTriggerRef)
if (InTrigger > 0)
if akTriggerRef == Game.GetPlayer()
InTrigger -= 1
;debug.notification("Leaving Trigger")
gotoState("done")
endif
endif

EndEvent

 

State done
;do nothing
endState
Link to comment
Share on other sites

Im using it on a activator.. basically activator is on table i have a x marker beside of that on table.. it works good until it drops a pair of boots then once i pick up the boots then it starts spamming these clothes. i was thinking it had something to do with the fact of the xmarker maybe a glitch what i wanted to do was if they had the materials/ conditions then it rolls a die/get a random number then once it gets a random number lets says 0-5 if its 0 we drop one item from this leveled item list if its another number we drop one from another level item list .. my above code works good until it drops boots about every time it does when i pick up boots its spamming stuff.. so i figure i might want to try putting the item in a chest.. i dont think i have anything like a level item list inside of one i thought maybe it was something to do with that... i havent tried a chest yet i may do that here later..

Link to comment
Share on other sites

Im using it on a activator.. basically activator is on table i have a x marker beside of that on table.. it works good until it drops a pair of boots then once i pick up the boots then it starts spamming these clothes. i was thinking it had something to do with the fact of the xmarker maybe a glitch what i wanted to do was if they had the materials/ conditions then it rolls a die/get a random number then once it gets a random number lets says 0-5 if its 0 we drop one item from this leveled item list if its another number we drop one from another level item list .. my above code works good until it drops boots about every time it does when i pick up boots its spamming stuff.. so i figure i might want to try putting the item in a chest.. i dont think i have anything like a level item list inside of one i thought maybe it was something to do with that... i havent tried a chest yet i may do that here later..

 

Chest is an option. So is just directly adding it to the player inventory instead of dropping it on the floor. Unless there's a reason to not add it to the player inventory.

 

I wanted to clarify something though. If you activate it with whatever method it is, you get an item. If you pick up that item nothing further happens? Unless the item is the boots you're mentioning. If you then pick up those boots, it *then* starts placing more? It is not starting the repeated spam as soon as you activate and it places the first boots?

 

A recursive leveled list shouldn't be able to produce the problem you're describing. Another thing that might be though, is if the record of the boots has some sort of script attached. It might incorrectly be triggering your on activate when you pick it up. Can you easily identify which boots it is to check that?

Link to comment
Share on other sites

  • 4 weeks later...
  • Recently Browsing   0 members

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