Jump to content

Can someone exsplain why this script won't compile?


Recommended Posts

Posted

I have been trying to make a script where when a player places 1000 gold into a strongbox it opens a door and locks the strongbox. This is what i have so far that won't compile.

strongscript.JPG

Posted

I'm no expert here, but I do see some problems:

  • Container is not defined. Perhaps this should be LastStrong?
  • Gold001 is defined as a property, but you are using Gold instead.
  • Gold001 is not an ObjectReference, it is a Miscellaneous Object (I forget the abbreviation).

 

Posted

add "MiscObject Property Gold001 auto"

delete "int gold001"

 

also you don't need the ( in front of container or the ) after 1000 for this script

Posted (edited)

your top "if container.getitemcount" line should be "if laststrong.getitemcount"

Edited by MadMansGun
Posted

...maybe try replaceing

if LastStrong.GetItemCount(Gold001) == 1000

with
 

Int chestgold = GetItemCount(gold001)
if chestgold == 1000

 

Posted
12 minutes ago, krestor said:

.

long shot but maybe
 

Form GetGold = Game.GetFormFromFile(0x0000000F, "Skyrim.ESM")
Int StoreGold = LastStrong.GetItemCount(GetGold)
if StoreGold >= 1000

 

Posted

@MadMansGun When i put in

Event OnClose(ObjectReference akActionRef)

if LastStrong.GetItemCount(Gold001) == 1000)
LastDoor.Activate()
LastStrong.Lock()
endIf
EndEvent
ObjectReference Property LastDoor Auto
Container Property LastStrong Auto
MiscObject Property Gold001 Auto

 

The only error i get is. I wonder if i formatted it wrong. I have tried ) and)) and then i tried ()) after the 1000 and nothing works

strong 4.JPG

Posted (edited)

Form cast problem I guess

 

2 hours ago, krestor said:

LastStrong.GetItemCount(Gold001) == 1000)
LastDoor.Activate()

The function returns an int

It's not defined under properties

and no formcast

 

Int iLastStrong = LastStrong.GetItemCount(Gold001 as form) 

 

If iLastStrong == 1000

 

 

or direct check

If  ( LastStrong.GetItemCount(Gold001 as Form ) == 1000

 

 

PS:

recommend not use check for the exact Nr., better > or so.

Otherwise it can happen, the condition will never met.

E.g. put or withdraw 2 coins ?

 

 

Edited by Tlam99
Posted

GetItemCount() must be called on ObjectReference, not on Container. It should look like this:

 

Event OnClose(ObjectReference akActionRef)
if LastStrong.GetItemCount(Gold001) == 1000
	LastDoor.Activate(LastDoor)
	LastStrong.Lock()
endIf
EndEvent

ObjectReference Property LastDoor Auto
ObjectReference Property LastStrong Auto
MiscObject Property Gold001 Auto

 

You will need to set LastStrong Property to the strongbox you placed in the world. Also, I'm not sure that Door can be activated to open. If it does not work you can try replacing 

 

LastDoor.Activate(LastDoor)

 

with

LastDoor.PlayGamebryoAnimation("Open", 5.0)

 

This will force the door to play "Open" animation.

Posted (edited)

ah yes, the stupid easy to miss bullshit that fucks me up the ass at every turn.

but since this is a object script wouldn't "self.GetItemCount(Gold001) == 1000" also work?

Edited by MadMansGun
Posted
1 hour ago, MadMansGun said:

ah yes, the stupid easy to miss bullshit that fucks me up the ass at every turn.

but since this is a object script wouldn't "self.GetItemCount(Gold001) == 1000" also work?

 

Yep, it should. :) 

Posted

Another point to consider is that Lock() will by default set the lowest level of lock, and the highest is “requires a key”. If you want the container not to be openable by the player, then consider using BlockActivation instead, as this stops the container from being used at all. The down side is that there is no failure message to indicate that you can not open it. It just has no activation prompt.

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...