Jump to content

Quick question about a simple script


Legotrash

Recommended Posts

I made this script but I couldn't figure out how to make it work with an if statement in one block so I made it with a second block starting with begin.Everything works as intended but I'd really appreciate if someone with more experience in scripting than me (and I have none experience really) can tell me if everything's fine with it.

 

ScriptName aaStaticAlchemyScript

short doOnce

 

Begin OnActivate Player

Player.AddItem RetortMaster 1

Player.AddItem MortarPestleMaster 1

Player.AddItem CalcinatorMaster 1

Player.AddItem AlembicMaster 1

Player.EquipItem CalcinatorMaster

Set doOnce to 1

End

 

Begin GameMode

If doOnce == 1

Player.RemoveItem RetortMaster 1

Player.RemoveItem MortarPestleMaster 1

Player.RemoveItem CalcinatorMaster 1

Player.RemoveItem AlembicMaster 1

Set doOnce to 0

EndIf

End

 

Making a second block makes me feel a bit uneasy about it that's why I thought I should ask about it.

Link to comment
Share on other sites

To prevent adding all items and then removing them, why not go for a script that checks your player's inventory, and uses an appropriate item? If none, then the standard M&P is used. Here is my static alchemy script from the Highwood mod:

 

 

  Reveal hidden contents

 

Link to comment
Share on other sites

Thanks for the reply!

 

I did it while having in mind "Listener Overhaul",it's supposed to equip the player with master leveled equipment.I saw that there are others bothered by the mod's alchemy script (very nice mod though) so I thought to upload a fix for it.Other than that,this is my first time scripting so I wanted to keep it simple. :biggrin:

 

Your script is only set to equip the player with what he has in his inventory or the equip command can also add the specific item?

 

 

By the way,should I consider my script ok? I was wondering about my second block,it wont keep on running if "doOnce == 0",right?

Link to comment
Share on other sites

  On 10/11/2012 at 9:15 PM, Legotrash said:

Thanks for the reply!

 

I did it while having in mind "Listener Overhaul",it's supposed to equip the player with master leveled equipment.I saw that there are others bothered by the mod's alchemy script (very nice mod though) so I thought to upload a fix for it.Other than that,this is my first time scripting so I wanted to keep it simple. :biggrin:

 

Your script is only set to equip the player with what he has in his inventory or the equip command can also add the specific item?

 

 

By the way,should I consider my script ok? I was wondering about my second block,it wont keep on running if "doOnce == 0",right?

 

Your script is ok, (sort of). The set doOnce should be at the beginning, or at least not at the end of the first block, because when you equip the item the OnActivate block stops running.

 

You should also get into the habit of using 'Return' in GameMode blocks where possible, to negate processing the whole of the script every frame. It's good optimisation practice. I would do it like this:

 

  Reveal hidden contents

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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