Jump to content

Noob Script Problem


Linky1

Recommended Posts

Hey all!

 

Just need a little help with my second script.

 

I have made a chest with some powerful items in it, and have written this script for the chest when you open it:

 

scn LincolnsAllomancyChestScript

 

Begin OnActivate

 

Messagebox "You open the chest and feel a Strong surge of Power flow through you." "Ok"

 

End

 

 

You have probably spotted the problem already, but for the people who haven't, I click the chest and it comes up with the message. When I click ok it doesn't open, and if I click the chest again it repeats.

 

Any help is appreciated,

Thanks

 

Linky1

Edited by Linky1
Link to comment
Share on other sites

If an object has an OnActivate block, then it will not activate normally. For a chest, this means it will not open.

 

This is to allow scripters to specifically avoid the object being activated under certain circumstances. Whenever you do want the object to be activated, use the command:

Activate

 

It's worth noting that "Activate" should be used as late as possible. It seems that sometimes it halts a script prematurely; although no-one is sure where, when, how or why this is.

Link to comment
Share on other sites

Try this:

scn LincolnsAllomancyChestScript
ref mySelf   ;reference that stores the name of the chest

Begin OnActivate

set mySelf to GetSelf    ;stores the name of the chest so it can activate itself

Messagebox "You open the chest and feel a Strong surge of Power flow through you." "Ok"
mySelf.Activate Player   ;the chest opens itself

End

 

Or assuming you only want the message to appear once,

 

scn LincolnsAllomancyChestScript
ref mySelf   ;reference that stores the name of the chest
short doonce

Begin OnActivate

set mySelf to GetSelf    ;stores the name of the chest so it can activate itself

if ( doonce == 0 )
Messagebox "You open the chest and feel a Strong surge of Power flow through you." "Ok"
mySelf.Activate Player   ;the chest opens itself
set doonce to 1

endif
End

 

Container activation method shamelessly ripped from here, since I've never actually had to do it before :whistling:

 

Edit: Derp. In the doonce version, mySelf.Activate Player should be AFTER endif, since you want it to always open but not always display the message. Yup, dumb mistake on my part.

Edited by Septfox
Link to comment
Share on other sites

I have tried both of your solutions but there is now another problem that pops up with both of your solutions.

 

It opens the chest, and displayes the message behind it. I have to click ok on the message but the inventory blocks it.

This makes the chest open, but thn you cant loot anything and you can see a bit of the message in the background.

 

fix?

 

Thanks BTW :)

 

Linky1

Link to comment
Share on other sites

And now you've been witness to Septy's Dumb Mistake #2: assuming that the messagebox is always forced to the top layer.

 

Anyway, fixing is easy, just switch the order of the commands so the chest activates first:

scn LincolnsAllomancyChestScript
ref mySelf   ;reference that stores the name of the chest
short doonce

Begin OnActivate

set mySelf to GetSelf    ;stores the name of the chest so it can activate itself
mySelf.Activate Player   ;the chest opens itself

if ( doonce == 0 )
Messagebox "You open the chest and feel a Strong surge of Power flow through you." "Ok"
set doonce to 1

endif
End

 

I just tested this, appears to work perfectly.

Link to comment
Share on other sites

And now you've been witness to Septy's Dumb Mistake #2: assuming that the messagebox is always forced to the top layer.

 

Anyway, fixing is easy, just switch the order of the commands so the chest activates first:

scn LincolnsAllomancyChestScript
ref mySelf   ;reference that stores the name of the chest
short doonce

Begin OnActivate

set mySelf to GetSelf    ;stores the name of the chest so it can activate itself
mySelf.Activate Player   ;the chest opens itself

if ( doonce == 0 )
Messagebox "You open the chest and feel a Strong surge of Power flow through you." "Ok"
set doonce to 1

endif
End

 

I just tested this, appears to work perfectly.

 

 

Thanks, Kudos :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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