Jump to content

Scripting a container and an activator


Angelbroke

Recommended Posts

I'm currently making a mod and unfortunately for the time I'm required to be fairly cagey about details, but I have idea.

I'd like a container and an activator, where when you place item A in the container and then press the activator, item A is removed and item B is put in it's place (to make it look like a trade). However it needs to be specifically item A and if it's any other item, it get's destroyed or nothing happens (I'm not bothered which). I have almost no understanding of the Papyrus language and so any assistance here would be enormously appreciated.

Link to comment
Share on other sites

I can get you started on the right track, but I don't have your exact setup so I can't make something that will just work.

 

Try something like this.


  •  
  • Open your activator,
  • add a new script,
  • then edit the source code on the new script
  • copy paste the below spoiler wrapped code
  • Try to compile it
  • If it compiles
  • save the script
  • then assign the correct items & containers to the properties
  • save plugin
  • test it out in the game
     

Import Game

ObjectReference Property ItemA auto
ObjectReference Property ItemB auto
ObjectReference Property ContainerA auto

Event OnActivate (ObjectReference akActor)
Actor Player = GetPlayer()
       If akActor == Player ;if the activator is the player
                  If ContainerA.GetItemCount(ItemA) >= 1  ;ContainerA has 1 or more of ItemA go on
              ContainerA.RemoveItem(ItemA,1,True,None) ;remove 1 of ItemA from ContainerA, be silent about it and do not put it anywhere
              ContainerA.AddItem(ItemB,1,True)  ; add 1 of ItemB to ContainerA, be silent about it
           ElseIf ContainerA.GetItemCount(ItemA) < 1  ;ContainerA has less than 1 of ItemA do nothing
           EndIf
EndIf
EndEvent

 

Edited by IsharaMeradin
Link to comment
Share on other sites

It won't compile. This is the script I'm trying to compile:

 

Scriptname JCDehydroScript extends ObjectReference  
Import Game

ObjectReference Property deathBell auto
ObjectReference Property JCPowderDeathbell auto
ObjectReference JCDweDehydroChamber auto

Event OnActivate (ObjectReference akActor)
       Actor Player = GetPlayer()
       If akActor == Player ;if the activator is the player
                  If JCDweDehydroChamber.GetItemCount(deathBell) == 1  ;JCDweDehydroChamber has 1 or more of deathBell go on
                     JCDweDehydroChamber.RemoveItem(deathBell,1,True,None) ;remove 1 of deathBell from JCDweDehydroChamber, be silent about it and do not put it anywhere
                     JCDweDehydroChamber.AddItem(JCPowderDeathbell,1,True)  ; add 1 of JCPowderDeathbell to JCDweDehydroChamber, be silent about it
                  ElseIf JCDweDehydroChamber.GetItemCount(deathBell) < 1  ;JCDweDehydroChamber has less than 1 of ItemA do nothing
                  EndIf
       EndIf
EndEvent

 

And this is what it gives as the issue:

 

Starting 1 compile threads for 1 files...
Compiling "JCDehydroScript"...
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\JCDehydroScript.psc(6,36): required (...)+ loop did not match anything at input 'auto'
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\JCDehydroScript.psc(6,40): mismatched input '\\r\\n' expecting STATE
No output generated for JCDehydroScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on JCDehydroScript

Link to comment
Share on other sites

  • Recently Browsing   0 members

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