Difference between revisions of "User:Terra Nova2"
Jump to navigation
Jump to search
Update on my location function.
imported>Terra Nova2 |
imported>Terra Nova2 (Update on my location function.) |
||
Line 1: | Line 1: | ||
Long function that | Long function that I almost have complete. | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Location Function GetParentLocation(ObjectReference akRef) | 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 part of the Tamriel World Space. | |||
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 | |||
iHold | if Hold[iHold].isChild(WSHold[iWSStored]) | ||
debug.trace("::::GETPARENTLOCATION:::::RETURNING HOLD LOCATION INDEX::::" +iHold) | |||
return Hold[iHold] | |||
endif | endif | ||
iHold += 1 | |||
EndWhile | EndWhile | ||
endif | endif | ||
iWSHold += 1 | |||
EndWhile | |||
else | else | ||
debug.notification(" | ; 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 | ||
EndFunction | EndFunction | ||
</source> | </source> |