Jump to content

Shader applied to player instead of item


bwins95

Recommended Posts

I'm working on a mod and the script length is almost at the character limit. I've tried using setstage and moving part of the script to a quest, but I've ran into a problem. the script should be applying a shader to an item, but instead it's being applied to the player.

The script is on a pair of glasses, so when they are put on the shader is applied.

 

This is the main script.

scn aaaaGlowingItems
ref rCurrentRef
ref Bscan
Begin OnEquip player
	set Bscan to 1
End
Begin OnUnequip player
	set Bscan to 0
End
Begin GameMode
	if bscan == 0
		stopMagicShaderVisuals aaaaGlowingItemsShaderGreen
		stopMagicShaderVisuals aaaaGlowingItemsShaderRed
		stopMagicShaderVisuals aaaaGlowingItemsShaderBlue
		stopMagicShaderVisuals aaaaGlowingItemsShaderWhite
		stopMagicShaderVisuals aaaaGlowingItemsShaderYellow
		stopMagicShaderVisuals aaaaGlowingItemsShaderPink
		stopMagicShaderVisuals aaaaGlowingItemsShaderPurple
	endif
	if bscan == 1
		set rCurrentRef to GetFirstRef 24 1 0
		Label 1
		if rCurrentRef
			if aaaaGlowingItemsArmor == 1
				SetStage aaaaglowingitemsa 0
				set rCurrentRef to Pencil01
				set rCurrentRef to GetNextRef
				Goto 1
			endif
		endif
	endif
End

This is the script in quest stage 0

ref rCurrentRef
if aaaaGlowingItemsArmorGreen == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderGreen 1
elseif aaaaGlowingItemsArmorRed == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderRed 1
elseif aaaaGlowingItemsArmorBlue == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderBlue 1
elseif aaaaGlowingItemsArmorWhite == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderWhite 1
elseif aaaaGlowingItemsArmorYellow == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderYellow 1
elseif aaaaGlowingItemsArmorPink == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderPink 1
elseif aaaaGlowingItemsArmorPurple == 1
    rCurrentRef.PlayMagicShaderVisuals aaaaGlowingItemsShaderPurple 1
elseif aaaaGlowingItemsArmor == 0
endif

The quest is set to start game enabled and allow repeated stages.

 

Link to comment
Share on other sites

Your valid rCurrentRef is located inside Item of the player.

 

rCurrentRef in quest stage 0 is empthy ref.

 

So you have to declare rCurrentRef inside quest script and then inside Object script change line

                set MyQuest.rCurrentRef to GetNextRef

And then access MyQuest.rCurrentRef from quest stage the same way

ref rCurrentRef
set  rCurrentRef to MyQuest.rCurrentRef
if aaaaGlowingItemsArmorGreen == 1

I'd recomment using UDF functions instead of quest stages since you use NVSE anyway.

Link to comment
Share on other sites

Your valid rCurrentRef is located inside Item of the player.

 

rCurrentRef in quest stage 0 is empthy ref.

 

So you have to declare rCurrentRef inside quest script and then inside Object script change line

                set MyQuest.rCurrentRef to GetNextRef

And then access MyQuest.rCurrentRef from quest stage the same way

ref rCurrentRef
set  rCurrentRef to MyQuest.rCurrentRef
if aaaaGlowingItemsArmorGreen == 1

I'd recomment using UDF functions instead of quest stages since you use NVSE anyway.

Thank you.

Using the UDF's I was able to reduce the character number from 28,000 to 800.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...