Jump to content

Optimise my clunky code


TyrisBel

Recommended Posts

Hi guys, i'm teaching myself papyrus (very gradually) I haven't coded since high school and that was in turbo pascal (yes that long ago) so it's slow going. I've written a script for my player house: When the player enters a trigger zone (directly in front of the entrance) the script checks to see if any of the fast travel markers to the standing stones (ie guardian stones mage, thief and warrior) are enabled, if they are it enables clones of the standing stones within the house. (this way you don't have to fast travel everywhere when you want to change star signs. But the code is very basic and as I look at it, I wonder if theres not a more elegant way to do this. If you're good at this sort of thing, please take a look and advise on any improvements:

 

 

 

 

Scriptname FFM_Doomstone_Enable extends ObjectReference
;Check to see if player has discovered doomstones and if so enables them for use in the house
ObjectReference Property DStoneMarker01  Auto
ObjectReference Property DStoneMarker02  Auto
ObjectReference Property DStoneMarker03  Auto
ObjectReference Property DStoneMarker04  Auto
ObjectReference Property DStoneMarker05  Auto
ObjectReference Property DStoneMarker06  Auto
ObjectReference Property DStoneMarker07  Auto
ObjectReference Property DStoneMarker08  Auto
ObjectReference Property DStoneMarker09  Auto
ObjectReference Property DStoneMarker10  Auto
ObjectReference Property DStoneMarker11  Auto
ObjectReference Property FTMarker01 Auto
ObjectReference Property FTMarker02 Auto
ObjectReference Property FTMarker03 Auto
ObjectReference Property FTMarker04 Auto
ObjectReference Property FTMarker05 Auto
ObjectReference Property FTMarker06 Auto
ObjectReference Property FTMarker07 Auto
ObjectReference Property FTMarker08 Auto
ObjectReference Property FTMarker09 Auto
ObjectReference Property FTMarker10 Auto
ObjectReference Property FTMarker11 Auto
Event OnTriggerEnter(ObjectReference akActionRef)
;When player enters trigger zone, checks to see if any of the stones are disabled and if they are and the player can fast travel to them, it enables in-house stones.
   
bool canFastTravel = FTMarker01.CanFastTravelToMarker()
bool canFastTravel01 = FTMarker01.CanFastTravelToMarker()
bool canFastTravel02 = FTMarker02.CanFastTravelToMarker()
bool canFastTravel03 = FTMarker03.CanFastTravelToMarker()
bool canFastTravel04 = FTMarker04.CanFastTravelToMarker()
bool canFastTravel05 = FTMarker05.CanFastTravelToMarker()
bool canFastTravel06 = FTMarker06.CanFastTravelToMarker()
bool canFastTravel07 = FTMarker07.CanFastTravelToMarker()
bool canFastTravel08 = FTMarker08.CanFastTravelToMarker()
bool canFastTravel09 = FTMarker09.CanFastTravelToMarker()
bool canFastTravel10 = FTMarker10.CanFastTravelToMarker()
bool canFastTravel11 = FTMarker11.CanFastTravelToMarker()
           If (DStoneMarker01.IsDisabled())
  if canFastTravel01 == true
   DStoneMarker01.Enable()
  endif
           endif

           If (DStoneMarker02.IsDisabled())
  if canFastTravel02 == true
   DStoneMarker02.Enable()
  endif
           endif

           If (DStoneMarker03.IsDisabled())
  if canFastTravel03 == true
   DStoneMarker03.Enable()
  endif
           endif

          If (DStoneMarker04.IsDisabled())
  if canFastTravel04 == true
   DStoneMarker04.Enable()
  endif
           endif

           If (DStoneMarker05.IsDisabled())
  if canFastTravel05 == true
   DStoneMarker05.Enable()
  endif
           endif
 If (DStoneMarker06.IsDisabled())
  if canFastTravel06 == true
   DStoneMarker06.Enable()
  endif
           endif

            If (DStoneMarker07.IsDisabled())
  if canFastTravel07 == true
   DStoneMarker07.Enable()
  endif
           endif

           If (DStoneMarker08.IsDisabled())
  if canFastTravel08 == true
   DStoneMarker08.Enable()
  endif
           endif

            If (DStoneMarker09.IsDisabled())
  if canFastTravel09 == true
   DStoneMarker09.Enable()
  endif
           endif

           If (DStoneMarker10.IsDisabled())
  if canFastTravel10 == true
   DStoneMarker10.Enable()
  endif
           endif
            If (DStoneMarker11.IsDisabled())
  if canFastTravel11 == true
   DStoneMarker11.Enable()
  endif
           endif
EndEvent

 

 

 

Link to comment
Share on other sites

Scriptname FFM_QuestLvl_Enable extends ObjectReference  

ObjectReference[] property DStoneMarkers auto

Event OnTriggerEnter(ObjectReference akActionRef)

       int index = 0
       while (index < DStoneMarkers.length)
               if (DStoneMarkers[index].IsDisabled())
                       if (DStoneMarkers[index].GetLinkedRef().CanFastTravelToMarker())
                               DStoneMarkers[index].Enable()
                       endif
               endif
               index += 1
       endwhile

EndEvent


Link to comment
Share on other sites

  • Recently Browsing   0 members

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