Difference between revisions of "User:Terra Nova2"

Jump to navigation Jump to search
1,029 bytes removed ,  12:53, 5 August 2016
Update on my location function.
imported>Terra Nova2
imported>Terra Nova2
(Update on my location function.)
Line 1: Line 1:




Long function that doesn't work because missing "pieces".
Long function that I almost have complete.


<source lang="papyrus">
<source lang="papyrus">
Location Function GetParentLocation(ObjectReference akRef)
Location Function GetParentLocation(ObjectReference akRef)
;==============================DOCUMENTATION ON THIS FUNCTION===================================================================
Int iCity
Int iHold
Int iWSHold
Int iCityIndex = City.Length
Int iHoldIndex = Hold.Length
Int iWSHoldIndex = WSHold.Length


; ==============================================================================================================================
if (akRef.GetCurrentLocation() != none)
Int i = 0
; First check if this cell has a location at all before moving..
Int iHold = 0
debug.notification("This cell has a location. Next check..")
Int iWorldSpaceHold = 0
Int iWorldSpaceLoc = 0
else
Int iNoParent = 0
debug.notification("This cell has no location. Returning none..")
Int iGetWorldSpace = 0
; return none if this cell doesn't have a location.
Int iIndex = City.Length
return none
Int iHoldIndex = Hold.Length
endif
Int iWorldSpaceLocIndex = WorldSpaceLoc.Length
Int iWorldSpaceHoldIndex = WorldSpaceHold.Length
Int iNoParentIndex = NoParent.Length
Int iGetWorldSpaceIndex = GetWorldSpaces.Length


;debug.notification("Name of my location." +akRef.GetCurrentLocation().GetName() as string)
; Moving to next block.. This block is for when you want to know what Hold is the parent of this exterior cell and part of the Tamriel World Space.
if !(akRef.isInInterior()) && akRef.GetWorldSpace() == TamrielWorldSpace
; if we are outside..we will return the parent of this location.
debug.notification("The cell is not an interior, and the cell is in the Tamriel World Space")
; First we will check if the CURRENT LOCATION matches a city.
While iCity < iCityIndex
if City[iCity] == akRef.GetCurrentLocation()
debug.trace("::::GETPARENTLOCATION:::::STORING CITY LOCATION INDEX::::" +iCity)
Int iCityStored = iCity
; Now we will check to see if A HOLD is the PARENT of THE CURRENT LOCATION.
While iHold < iHoldIndex
if Hold[iHold].isChild(City[iCityStored])
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)


IF akRef.GetCurrentLocation() != none ; Check if our cell has a locaiton.
return Hold[iHold]
if !akRef.isInInterior() && akRef.GetWorldSpace() == Tamriel ; We're outside and in the Tamriel worldspace.
endif
debug.trace("We're checking for the parent in an exterior.")
iHold += 1
While i < iIndex
EndWhile
if City[i] == akRef.GetCurrentLocation() ; Check if our location matches a city.
endif
debug.trace("Storing the index" + i)
iCity += 1
Int iSameLocation = i
EndWhile
While iHold < iHoldIndex
; Moving to next block.. This block is for when you want to know what Hold is the parent of this interior cell and part of the Tamriel World Space.
debug.trace("We're checking holds.")
elseif akRef.isInInterior() == true && akRef.GetWorldSpace() != TamrielWorldSpace
if Hold[iHold].isChild(City[iSameLocation])
; If we are inside..we will return the parent of this interior location.
debug.trace("We're returning the hold that is contained in index" + iHold + "and is" +Hold[iHold].Getname())
debug.notification("You are in an interior. Returning hold if possible..")
return Hold[iHold]
While iHold < iHoldIndex
endif
if Hold[iHold].isChild(akRef.GetCurrentLocation())
debug.trace("Incrementing through the hold locations" + Hold[iHold].GetName() + "hold.")
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)
iHold += 1
return Hold[iHold]
EndWhile
endif
endif
iHold += 1
debug.trace("Incrementing through the cities." + i)
EndWhile
i += 1
; Moving to next block.. This block if for when you want to know what hold is the parent of this cell behaving like an exterior, but you are not in the Tamriel Worldspace.
EndWhile
elseif !(akRef.isInInterior()) && akRef.GetWorldSpace() != TamrielWorldSpace
elseif akRef.IsInInterior() ; We're inside an interior
debug.notification("The cell is an interior, and the cell is not the Tamriel World Space")
debug.trace("We're in an interior")
; First we will check if the CURRENT LOCATION matches a city.
While iHold < iHoldIndex
While iWSHold < iWSHoldIndex
if Hold[iHold].isChild(akRef.GetCurrentLocation())
if WSHold[iWSHold] == akRef.GetCurrentLocation()
debug.trace("Returning_" +Hold[iHold].Getname()+ "hold" + "_for this interior at Index_" +iHold)
debug.trace("::::GETPARENTLOCATION:::::STORING CURRENT LOCATION INDEX::::" +iWSHold)
return Hold[iHold]
Int iWSStored = iWSHold
endif
; Now we will check to see if A HOLD is the PARENT of THE CURRENT LOCATION.
debug.trace("Incrementing through the holds" +Hold[iHold].GetName()+ "hold.")
While iHold < iHoldIndex
iHold += 1
if Hold[iHold].isChild(WSHold[iWSStored])
EndWhile
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)
elseif akRef.GetWorldSpace() != Tamriel ; We're not in Kansas anymore Dorothy.
debug.trace("We're not in Kansas anymore. Dorothy")


While iGetWorldSpace < iGetWorldSpaceIndex
return Hold[iHold]
if akRef.GetWorldSpace() == GetWorldSpaces[iGetWorldSpace]
Int StoreWorldSpace = iGetWorldSpace
if
While iWorldSpaceLoc < iWorldSpaceLocIndex
if WorldSpaceLoc[iWorldSpaceLoc] == akRef.GetCurrentLocation()
debug.trace("Returning Tamriel")
return TamrielLocation
endif
debug.trace(WorldSpaceLoc[iWorldSpaceLoc].GetName() +"at index_" +iWorldSpaceLoc+ "_is not the parent.")
iWorldSpaceLoc += 1
EndWhile
 
While iWorldSpaceHold < iWorldSpaceHoldIndex
if WorldSpaceHold[iWorldSpaceHold] == akRef.GetCurrentLocation()
debug.trace("Storing the location_"+WorldSpaceHold[iWorldSpaceHold].GetName()+ "_at index_" +iWorldSpaceHold)
Int iWorldSpaceIndex = iWorldSpaceHold
While iHold < iHoldIndex
debug.trace("Checking holds..")
if Hold[iHold].isChild(WorldSpaceHold[iWorldSpaceIndex])
debug.trace("Retuning the_"+Hold[iHold].GetName()+"hold.")
return Hold[iHold]
endif
debug.trace("Incrementing though the holds_"+Hold[iHold].Getname()+ "_of index_" +iHold)
iHold += 1
EndWhile
endif
debug.trace("Incrementing through the worldspace location index_"+iWorldSpaceHold)
iWorldSpaceHold += 1
EndWhile
 
While iNoParentIndex
iNoParentIndex -= 1
if NoParent[iNoParentIndex] == akRef.GetCurrentLocation()
debug.notification("This location has no assigned parent.")
return none
endif
EndWhile
 
if akRef.GetCurrentLocation() == KatariahLocation
While i < iIndex
if City[i].isChild(KatariahLocation)
Int iKatParent
While iHold < iHoldIndex
if Hold[iHold].isChild(City[iKatParent])
return Hold[iHold]
endif
iHold += 1
EndWhile
endif
endif
i += 1
iHold += 1
EndWhile
EndWhile
endif
endif
endif
iWSHold += 1
EndWhile
else
else
debug.notification("This cell has no assigned location.")
; Either you are in an interior but it's behaving like an exterior, or you are not in the Tamriel World Space.
debug.notification("Returning none..")
return none
return none
endif
endif
debug.notification("No parents found for any location.")
 
return none ; return none if no parents are found.
EndFunction
EndFunction
</source>
</source>
Anonymous user

Navigation menu