TyrisBel Posted March 9, 2012 Share Posted March 9, 2012 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 More sharing options...
gsmanners Posted March 9, 2012 Share Posted March 9, 2012 Your code is already better than that garbage in the game. :yucky: Link to comment Share on other sites More sharing options...
GomuGomu64 Posted March 9, 2012 Share Posted March 9, 2012 I'm sure there is a way to shorten it down, but it is rock-solid as it is right now. Good job. Link to comment Share on other sites More sharing options...
porroone Posted March 9, 2012 Share Posted March 9, 2012 Maybe using an array instead of so many variables, I still havent used them tho so I cant help you there. Link to comment Share on other sites More sharing options...
Korodic Posted March 9, 2012 Share Posted March 9, 2012 Looks good, but I would have used an array since you have so many of the same object doing repiticous code ;) Edit: it does not need to be changed tho, both achieve the same goal. Link to comment Share on other sites More sharing options...
TyrisBel Posted March 9, 2012 Author Share Posted March 9, 2012 I Actually have changed to array, will post updated code if anyone wants Link to comment Share on other sites More sharing options...
GomuGomu64 Posted March 9, 2012 Share Posted March 9, 2012 I Actually have changed to array, will post updated code if anyone wants Couldn't hurt. Link to comment Share on other sites More sharing options...
TyrisBel Posted March 9, 2012 Author Share Posted March 9, 2012 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 More sharing options...
porroone Posted March 9, 2012 Share Posted March 9, 2012 Yes that definetly looks more elegant. Link to comment Share on other sites More sharing options...
ScarabMonkey Posted March 9, 2012 Share Posted March 9, 2012 An alternative would be to use a formlist, not sure if it would be any better though! Just possibly eaiser for other mods to amend the list if they add new stones Link to comment Share on other sites More sharing options...
Recommended Posts