Jump to content

Scripting Noob in Need of Help from The Pros


Recommended Posts

OK so I have been writing script all day. Linked chests and activators and making book shelves. EVERYTHING works great. EXCEPT this script lol. What am I doing wrong?

 

The activator is set to Player Activated in the primitive tab, its not stuck in a collision box, the script compiles perfectly, the object reference property is set and the trigger is canted slightly so it isn't all zeros. I can see the activator in game but when I tap E, nothing happens. The container below is full of ingredients but nothing is removed from the container to the player inventory.

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

What is the final script code?

Are you testing on a save or new game that has not seen the activator loaded yet?

Does the container in question actually have items in it?

Do the items transfer if you open and close the container first?

Disregard. I coc'd in to my mod (i just learned how) and it works. Bad in game save I presume. Thanks so much! It is a little slow which I assume is a stack dump. You mentioned another way that wouldn't?

Link to comment
Share on other sites

Slow doesn't necessarily mean a stack dump. A stack dump would be evident in the papyrus log, otherwise you'd have no idea that one ever took place. The routes that would avoid causing stack dumps would probably take longer as they must go through and transfer the items one at a time rather than the whole lot at once.

Link to comment
Share on other sites

OK. :Deep breath: weirdest thing. it just stopped working. When I responded to you last, I had just finished screen recording myself going to the activator and trying it. It worked. But now it doesn't work at all. I am so confused. So I am going back to answering your questions.

 

Script below.

I tried both game save and console teleport.

Yes there is 1 of each ingredient for testing purposes.

I am going to try that now. ---edit--- You called it. I have to open the wardrobe 1st and then it will work properly. How did you know that?

Scriptname JLRemoveAlcIngredients extends ObjectReference
 
ObjectReference Property JL_Alchemy_Wardrobe Auto
 
Event OnActivate(objectReference akActivator)
If akActivator == Game.GetPlayer()
JL_Alchemy_Wardrobe.RemoveAllItems(akActivator)
debug.notification("All Ingredients Equipped")
EndIf
EndEvent
Edited by Chris20201986
Link to comment
Share on other sites

I am nearing completion of my player home. I appreciate the help given. I am working on the last script needed for a trophy room. I have been searching for a tutorial on the trophy bases but the only one I can find is Darkfox127. Although his is cool because you can actually remove the trophy and replace if you get tired of that trophy unlike the vanilla version where you are stuck with what you put. But I spent half an hour following his tut as best as possible. There are A LOT of steps to make that work for EVERY trophy piece. After completing ONE trophy, I tested and it didn't work. I did so much for that I have no idea where to start to find my mistake so I was just reaching to see if there was a much easier way to go about the trophy bases. So, is there? Even a vanilla version.

 

My trophy bases are going to be initially able. Player will not have to build this house. They can walk into the trophy room and just put trophies on as they choose with required materials of course.

Link to comment
Share on other sites

Place your trophy base, set this to be enabled.

Place the object for the trophy, set this to be disabled.

Wrap an activator around the trophy base.

Apply a script to the activator. This script will if the player has the correct items, enable the trophy object and remove the items from the player inventory.

 

An example script allowing any number of items with differing quantities of each (needs tested for compilation and function):

 

 

Scriptname SomeTrophyBaseScript Extends ObjectReference
 
FormList Property ListOfRequiredItems Auto ;list of required items
Int[] Property RequiredItemQuantityArray Auto ;fill in CK property window - index match with form list
ObjectReference Property TrophyDisplay Auto
Bool doOnce = false
String Property DisplayMessage Auto ; optional message to show after trophy has been built
 
Event OnActivate(ObjectReference akActivator)
  If akActivator == Game.GetPlayer() && doOnce == false
    If HasRequiredItemsInList(akActivator as Actor,ListOfRequiredItems) == true
      TrophyDisplay.Enable()
      doOnce = true
      Int ix = ListOfRequiredItems.GetSize() - 1
      While ix >= 0
        Form Entry = ListOfRequiredItems.GetAt(ix)
        Int Quantity = RequiredItemQuantityArray[ix]
        akActivator.RemoveItem(Entry,Quantity)
        ix -= 1
      EndWhile
      ;Self.Disable()  ;optional disable the activator so that it no longer appears.
    EndIf
  ;optional elseif block
  ElseIf akActivator == Game.GetPlayer() && doOnce == true
    Debug.MessageBox(DisplayMessage)
  EndIf
EndEvent
 
Bool Function HasRequiredItemsInList(Actor Dude, FormList TheList)
  Bool Result = false
  int ix = TheList.GetSize() - 1
  While ix >= 0
    Form Entry = TheList.GetAt(ix)
    If Dude.GetItemCount(Entry) >= RequiredItemQuantityArray[ix]
      ;if item is present set to true and check the next
      Result = true
      ix -= 1
    Else
      ;if item is not present set to false and exit loop
      Result = false
      ix = -1
    EndIf
  EndWhile
  Return Result
EndFunction

 

 

There are other possible routes to achieve what you want.

Link to comment
Share on other sites

Now this script would be for ONE particular trophy correct? Not giving the player the choice to pick other trophies? Not that it bothers me, I am just asking to be sure.

 

ListOfRequiredItems-I must make a form list of the items I would require the player to have in order to make a particular trophy and replace this with my form list name?

Integer property-the quantity of each item in the form list and must match that list sequentially?

ObjectReference Property TrophyDisplay-the actual item on the trophy base that I initially disabled?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...