Difference between revisions of "User:Terra Nova2"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Terra Nova2
imported>Terra Nova2
m
 
(2 intermediate revisions by the same user not shown)
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 not part of the Tamriel World Space.
debug.trace("We're checking holds.")
; Like for example, Riverwood Trader.
if Hold[iHold].isChild(City[iSameLocation])
elseif akRef.isInInterior() == true && akRef.GetWorldSpace() != TamrielWorldSpace
debug.trace("We're returning the hold that is contained in index" + iHold + "and is" +Hold[iHold].Getname())
; If we are inside..we will return the parent of this interior location.
return Hold[iHold]
debug.notification("You are in an interior. Returning hold if possible..")
endif
While iHold < iHoldIndex
debug.trace("Incrementing through the hold locations" + Hold[iHold].GetName() + "hold.")
if Hold[iHold].isChild(akRef.GetCurrentLocation())
iHold += 1
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)
EndWhile
return Hold[iHold]
endif
endif
debug.trace("Incrementing through the cities." + i)
iHold += 1
i += 1
EndWhile
EndWhile
; 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.
elseif akRef.IsInInterior() ; We're inside an interior
elseif !(akRef.isInInterior()) && akRef.GetWorldSpace() != TamrielWorldSpace
debug.trace("We're in an interior")
debug.notification("The cell is an interior, and the cell is not the Tamriel World Space")
While iHold < iHoldIndex
; First we will check if the CURRENT LOCATION matches a city.
if Hold[iHold].isChild(akRef.GetCurrentLocation())
While iWSHold < iWSHoldIndex
debug.trace("Returning_" +Hold[iHold].Getname()+ "hold" + "_for this interior at Index_" +iHold)
if WSHold[iWSHold] == akRef.GetCurrentLocation()
return Hold[iHold]
debug.trace("::::GETPARENTLOCATION:::::STORING CURRENT LOCATION INDEX::::" +iWSHold)
endif
Int iWSStored = iWSHold
debug.trace("Incrementing through the holds" +Hold[iHold].GetName()+ "hold.")
; Now we will check to see if A HOLD is the PARENT of THE CURRENT LOCATION.
iHold += 1
While iHold < iHoldIndex
EndWhile
if Hold[iHold].isChild(WSHold[iWSStored])
elseif akRef.GetWorldSpace() != Tamriel ; We're not in Kansas anymore Dorothy.
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)
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>

Latest revision as of 12:58, 5 August 2016


Long function that I almost have complete.

Location Function GetParentLocation(ObjectReference akRef)
Int iCity
Int iHold
Int iWSHold
Int iCityIndex = City.Length
Int iHoldIndex = Hold.Length
Int iWSHoldIndex = WSHold.Length

if (akRef.GetCurrentLocation() != none)
	; First check if this cell has a location at all before moving..
	debug.notification("This cell has a location. Next check..")
	
else
	debug.notification("This cell has no location. Returning none..")
	; return none if this cell doesn't have a location.
	return none
endif

; 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)

					return Hold[iHold]
				endif
				iHold += 1
			EndWhile
		endif
		iCity += 1
	EndWhile
; Moving to next block.. This block is for when you want to know what Hold is the parent of this interior cell and not part of the Tamriel World Space.
; Like for example, Riverwood Trader.
elseif akRef.isInInterior() == true && akRef.GetWorldSpace() != TamrielWorldSpace
	; If we are inside..we will return the parent of this interior location.
	debug.notification("You are in an interior. Returning hold if possible..")
	While iHold < iHoldIndex
		if Hold[iHold].isChild(akRef.GetCurrentLocation())
			debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)
			return Hold[iHold]
		endif
		iHold += 1
	EndWhile
; 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.
elseif !(akRef.isInInterior()) && akRef.GetWorldSpace() != TamrielWorldSpace
	debug.notification("The cell is an interior, and the cell is not the Tamriel World Space")
	; First we will check if the CURRENT LOCATION matches a city.
	While iWSHold < iWSHoldIndex
		if WSHold[iWSHold] == akRef.GetCurrentLocation()
			debug.trace("::::GETPARENTLOCATION:::::STORING CURRENT LOCATION INDEX::::" +iWSHold)
			Int iWSStored = iWSHold
			; Now we will check to see if A HOLD is the PARENT of THE CURRENT LOCATION.
			While iHold < iHoldIndex
				if Hold[iHold].isChild(WSHold[iWSStored])
					debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold)

					return Hold[iHold]
				endif
				iHold += 1
			EndWhile
		endif
		iWSHold += 1
	EndWhile
else
	; 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
endif

EndFunction