I'd look through some basic papyrus tutorials to get started. With papyrus, everything is controlled through events. So for example, you can do something like this for the activation object/chest script.
Scriptname _test_testscript extends ObjectReferenceObjectReference Property kMarker Auto ;XMarker for spawning new NPCsObjectReference Property kChest Auto ;points to the chest;alternatively you can probably link ObjectReferences together in the CK and use GetLinkedRef()MiscObject Property kObject AutoActorBase Property kEvilActor AutoEvent OnActivate(ObjectReference akActionRef) if kChest.GetItemCount(kObject) kChest.RemoveItem(kObject) kMarker.PlaceActorAtMe(kEvilActor) endIfendEvent
This code needs more work though. If the player mashes on the lever, the OnActivate event will fire each time. States are a good way to prevent this from happening. I would check some other lever scripts, as I believe they do stuff to make sure the animation syncs with script states.
The despawn script is probably simpler. The OnInit() event is the go to event for running code right away. When attached to an actor/object, it will fire when it gets loaded for the first time (and the script is initialized). Something like this may suit your needs, or close to it depending on exactly what you want.
Scriptname _test_testscript extends ActorEvent OnInit() ;play some cool visual and sound effects if you want RegisterForSingleUpdate(60.0) ;triggers the OnUpdate event in 60 secondsendEventEvent OnUpdate() KillMe()endEventEvent OnDeath(Actor akKiller) KillMe()endEventFunction KillMe() GoToState("") ;go to the "DeadState" state to ignore other potential KillMe() ;play some cool visual and sound effects if you want Disable() Delete() ;make sure you clean up with deleteendFunctionState DeadState Function KillMe() ;do nothing endFunctionendState