SetWorldModelPath - Form

From the CreationKit Wiki
(Redirected from SetWorldModelPath- Form)
Jump to navigation Jump to search

SKSE Member of: Form Script

Sets the world model of the form. (This function requires SKSE)

Syntax[edit | edit source]

Function SetWorldModelPath(String Path) native

Parameters[edit | edit source]

  • Path: the new world model for this form.

Return Value[edit | edit source]

  • none

Examples[edit | edit source]

Setting up correct world model path properly

; Set 1st person iron sword static to use 1st person elven sword static world model, emerging from Data/Meshes
1stPersonIronSword.SetWorldModelPath("Weapons/Elven/1stPersonElvenSword.nif")
; Iron sword's now using the Elven sword world model!


How to execute maintenance code to apply changes on already placed instances of base object

; example on how to set up maintenance code in order to replace world model on loading a game, with the one applied before saving the game
; this example uses SkyUI menu option to replace world models via MCM menu
; as long as you did not place any objects in the game world while executing SetWorldModelPath in any of your scripts, you don't necessarily need maintenance code
Function MaintenanceSection()
	
        SetMenuOptionValue(MarkerModel, MarkerList[MarkerModelIndex])
	If MarkerModelIndex == 0
               ; do stuff 
	ElseIf MarkerModelIndex == 1

		Int iIndex = MTW_WayStoneFormList.GetSize(); get all ObjectReferences of base object via array
		While iIndex
			iIndex -= 1
			ObjectReference WaystoneRef = MTW_WayStoneFormList.GetAt(iIndex) as ObjectReference
			Utility.Wait(0.25); script latency troubleshoot
			WaystoneRef.disable(); needs to be disabled and reenabled in order to properly work on already plaaced instances in the game world
			MTW_Sign01.SetWorldModelPath("PointOfInterest/NorHitchPost01.nif")	
			WaystoneRef.enable(); don't forget to reenable
		EndWhile
			
	ElseIf MarkerModelIndex == 2
               ; do stuff
	EndIf
		
EndFunction

Notes[edit | edit source]

  • This function can only be applied to items that actually have a 'physical/visual' world model.
  • This will affect all instances of the passed form.
  • World Model changes will not be saved and must be maintained via a maintenance setup or something similar.
  • In order to make it work, you'll need to use / (slash) instead of \ (backslash)

See Also[edit | edit source]