Jump to content

Script not working any idea why?


Recommended Posts

I am trying to make a mod where the the player can pick up a special lockpick and lockpicks do not break and if they drop it lock picks break again this is one of the scripts i have tried any idea why it wont compile. I am very new to scripting.

 

Script[

Scriptname UnbreakablePickTest extends ObjectReference  

Perk Properties Unbreakable auto

Event OnItemAdded()
      Game.GetPlayer().AddPerk(MUBUnbreakLock)
      Debug.Notification("Perk Should Be Added")
EndEvent]

 

 

gkhg.PNG

Link to comment

Apart from properties->property, make sure that your event signature on line 5 reads

Event(OnItemAdded(FormakBaseItem,intaiItemCount,ObjectReferenceakItemReference,ObjectReferenceakSourceContainer)

as this matches the signature the engine is going to expect the event to have when it tries to receive it. (the parameter names aren't important, e.g. akBaseItem can be pickedUpItem or whatever you want, but the types need to match)

 

Also, OnItemAdded will only be called when the ObjectReference it's attached to receives an item. I can't tell what your script is attached to, but if it is supposed to be invoked when the player receives the item, you'll want it to be attached to the player. You can't modify the player's OnItemAdded directly, so what you'll probably want to do is:

1. Make a quest

2. Make an alias in that quest, and point it to the player

3. Create a new script on that alias, and paste <everything but the Scriptname line> into that file

 

so that the player gets your OnItemAdded attached to them via the alias

 

Edited by Visio Diaboli
Link to comment


Its property not properties (Usually looking at the first error gives a good hint at which line to start. Following errors often make less sense as the compiler is already off on the wrong path...)

 

Assuming this script is placed on the item you likely want something like :
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  if akNewContainer == Game.getPlayer()
    ; ensure perk active
  else
    ; ensure perk inactive
  endif
EndEvent

rather than OnItemAdded

 

Edit: Oops too late ;)  well the last part might be useful yet as it's easier than VD's valid solution.

Edited by MTB
Link to comment
1 hour ago, krestor said:

So i have tried add ing the unbreakable perk then i tried adding a perk i made that is supose to make make picks unbreakable then i tried adding the skeliton key perk and the lockpick still breaks

 

 

1 hour ago, krestor said:

@MTB So what is ;ensure perk active and i don't see how to add the perk. sorry if the answer is obvious

 

 

; this is a comment. So ; ensure perk active  would be what you already had:

Game.GetPlayer().AddPerk( Unbreakable )

Debug.Notification( ""Perk Should Be Added" )

 

Do you see the notification when you pick up the item ?

 

If so the script is running.

Make sure you filled the property on the script.   (Try it with the unbreakable perk that is already in the lockpick tree before trying to make your own perk.  Is that the one you mean when you say `skeliton key perk' ?)

 

If not: the script is not running.  Did you place it on the objectbase of the item that is supposed to supply this power / or the actual object reference ?

(Try placing the object somewhere out in the world. Or just dropping it and picking it up again; Inventory objects don't always exist as object references.)

 

Edited by MTB
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use