Jump to content

Help with Script.


Recommended Posts

I'm attempting to make a script to auto strip the Player and Npc's when they enter a pool following this article https://www.nexusmods.com/skyrimspecialedition/mods/30265?tab=articles. I copy the text to create a new script for the magic effect, but I get 2 errors and it fails to compile. This is the first script I've tried and have no clue where to begin to fix this. Any help is appreciated.

 

 

Starting 1 compile threads for 1 files...
Compiling "Nul_Strip_Effect_Script_002"...
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(3,0): no viable alternative at character '?'
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(3,1): missing EOF at 'Scriptname'
No output generated for Nul_Strip_Effect_Script_002, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on Nul_Strip_Effect_Script_002
Here is the script that I'm attempting to make.
Scriptname Nul_Strip_Effect_Script_002 extends activemagiceffect
Scriptname Nul_Strip_Effect_Script_002 extends ObjectReference
spell property Nul_Strip_Spell_001 auto
Actor Property PlayerRef Auto
;define variable for camera state
int iCameraState
;define variables for weapons in each hand
Weapon equippedleft
Weapon equippedright
;define varialbe for player shield
Armor player_shield
;define variables for the follwing slots, 30 to 49, 52 to 61
Armor slot32
Armor slot30
Armor slot31
Armor slot33
Armor slot34
Armor slot35
Armor slot36
Armor slot37
Armor slot38
Armor slot39
Armor slot40
Armor slot41
Armor slot42
Armor slot43
Armor slot44
Armor slot45
Armor slot46
Armor slot47
Armor slot48
Armor slot49
Armor slot52
Armor slot53
Armor slot54
Armor slot55
Armor slot56
Armor slot57
Armor slot58
Armor slot59
Armor slot60
Armor slot61
;Armor slot130
;Armor slot131
;Armor slot141
;Armor slot142
;Armor slot143
;Armor slot230
;define variables for possible spells
Spell spell0
Spell spell1
Spell spell2
Spell spell3
Event OnTriggerEnter(ObjectReference triggerRef)
;debug.notification("found something!")
Actor akactionRef = triggerRef as Actor
if (akActionRef != game.getplayer() && !akActionRef.isincombat())
;debug.notification("effect applied")
Nul_Strip_Spell_001.cast(akactionref,akactionref)
else
if (SKSE.GetVersionRelease() > 0)
;find camera state
iCameraState = Game.GetCameraState() ; this is an skse function
endif
;change to third person if not already
If(iCameraState == 0)
Game.ForceThirdPerson()
Endif
;get weapons
equippedleft = PlayerRef.GetEquippedWeapon(true)
equippedright = PlayerRef.GetEquippedWeapon()
;get shield
player_shield = PlayerRef.GetEquippedShield()
;get spells
spell0 = PlayerRef.GetEquippedSpell(0)
spell1 = PlayerRef.GetEquippedSpell(1)
spell2 = PlayerRef.GetEquippedSpell(2)
spell3 = PlayerRef.GetEquippedSpell(3)
;get armor slots
slot32 = PlayerRef.GetEquippedArmorInSlot(32)
slot30 = PlayerRef.GetEquippedArmorInSlot(30)
slot31 = PlayerRef.GetEquippedArmorInSlot(31)
slot33 = PlayerRef.GetEquippedArmorInSlot(33)
slot34 = PlayerRef.GetEquippedArmorInSlot(34)
slot35 = PlayerRef.GetEquippedArmorInSlot(35)
slot36 = PlayerRef.GetEquippedArmorInSlot(36)
slot37 = PlayerRef.GetEquippedArmorInSlot(37)
slot38 = PlayerRef.GetEquippedArmorInSlot(38)
slot39 = PlayerRef.GetEquippedArmorInSlot(39)
slot40 = PlayerRef.GetEquippedArmorInSlot(40)
slot41 = PlayerRef.GetEquippedArmorInSlot(41)
slot42 = PlayerRef.GetEquippedArmorInSlot(42)
slot43 = PlayerRef.GetEquippedArmorInSlot(43)
slot44 = PlayerRef.GetEquippedArmorInSlot(44)
slot45 = PlayerRef.GetEquippedArmorInSlot(45)
slot46 = PlayerRef.GetEquippedArmorInSlot(46)
slot47 = PlayerRef.GetEquippedArmorInSlot(47)
slot48 = PlayerRef.GetEquippedArmorInSlot(48)
slot49 = PlayerRef.GetEquippedArmorInSlot(49)
slot52 = PlayerRef.GetEquippedArmorInSlot(52)
slot53 = PlayerRef.GetEquippedArmorInSlot(53)
slot54 = PlayerRef.GetEquippedArmorInSlot(54)
slot55 = PlayerRef.GetEquippedArmorInSlot(55)
slot56 = PlayerRef.GetEquippedArmorInSlot(56)
slot57 = PlayerRef.GetEquippedArmorInSlot(57)
slot58 = PlayerRef.GetEquippedArmorInSlot(58)
slot59 = PlayerRef.GetEquippedArmorInSlot(59)
slot60 = PlayerRef.GetEquippedArmorInSlot(60)
slot61 = PlayerRef.GetEquippedArmorInSlot(61)
;slot130 = PlayerRef.GetEquippedArmorInSlot(130)
;slot131 = PlayerRef.GetEquippedArmorInSlot(131)
;slot141 = PlayerRef.GetEquippedArmorInSlot(141)
;slot142 = PlayerRef.GetEquippedArmorInSlot(142)
;slot143 = PlayerRef.GetEquippedArmorInSlot(143)
;slot230 = PlayerRef.GetEquippedArmorInSlot(230)
akActionRef.unequipall()
endif
endEvent
Event OnTriggerLeave(ObjectReference triggerRef)
Actor akactionRef = triggerRef as Actor
if (akActionRef != PlayerRef)
;debug.notification("effect removed")
akActionRef.dispelspell(Nul_Strip_Spell_001)
else
if (SKSE.GetVersionRelease() > 0 && iCameraState == 0)
;return to first person if necessary
;if (iCameraState == 0)
Game.ForceFirstPerson()
;Endif
endif
;if the trigger is the player then equip all weapons, spells and armor
;equip weapons
if (SKSE.GetVersionRelease() > 0)
PlayerRef.EquipItemEx(equippedleft,2,true) ;this is an skse function
PlayerRef.EquipItemEx(equippedright,1) ;this is an skse function
else
PlayerRef.EquipItem(equippedleft)
PlayerRef.EquipItem(equippedright)
endif
;equip shield
PlayerRef.EquipItem(player_shield)
;equip spells
PlayerRef.EquipSpell(spell0,0)
PlayerRef.EquipSpell(spell1,1)
PlayerRef.EquipSpell(spell2,2)
PlayerRef.EquipSpell(spell3,3)
;equip armor
PlayerRef.EquipItem(slot32,false,true)
PlayerRef.EquipItem(slot30,false,true)
PlayerRef.EquipItem(slot31,false,true)
PlayerRef.EquipItem(slot33,false,true)
PlayerRef.EquipItem(slot34,false,true)
PlayerRef.EquipItem(slot35,false,true)
PlayerRef.EquipItem(slot36,false,true)
PlayerRef.EquipItem(slot37,false,true)
PlayerRef.EquipItem(slot38,false,true)
PlayerRef.EquipItem(slot39,false,true)
PlayerRef.EquipItem(slot40,false,true)
PlayerRef.EquipItem(slot41,false,true)
PlayerRef.EquipItem(slot42,false,true)
PlayerRef.EquipItem(slot43,false,true)
PlayerRef.EquipItem(slot44,false,true)
PlayerRef.EquipItem(slot45,false,true)
PlayerRef.EquipItem(slot46,false,true)
PlayerRef.EquipItem(slot47,false,true)
PlayerRef.EquipItem(slot48,false,true)
PlayerRef.EquipItem(slot49,false,true)
PlayerRef.EquipItem(slot52,false,true)
PlayerRef.EquipItem(slot53,false,true)
PlayerRef.EquipItem(slot54,false,true)
PlayerRef.EquipItem(slot55,false,true)
PlayerRef.EquipItem(slot56,false,true)
PlayerRef.EquipItem(slot57,false,true)
PlayerRef.EquipItem(slot58,false,true)
PlayerRef.EquipItem(slot59,false,true)
PlayerRef.EquipItem(slot60,false,true)
PlayerRef.EquipItem(slot61,false,true)
;PlayerRef.EquipItem(slot130,false,true)
;PlayerRef.EquipItem(slot131,false,true)
;PlayerRef.EquipItem(slot141,false,true)
;PlayerRef.EquipItem(slot142,false,true)
;PlayerRef.EquipItem(slot143,false,true)
;PlayerRef.EquipItem(slot230,false,true)
;debug.messagebox("Leave Triggered")
endif
endEvent
Link to comment
Share on other sites

I was able to remove 1 error after viewing the post on my phone and saw the characters "" at the beginning of the second line. They didn't show up on the CK editor, but I deleted the line and typed it again.

 

Now I only have the EOF error.

Link to comment
Share on other sites

I took your script as posted and deleted the aforementioned line and also deleted the empty spaces and returns between ActiveMagicEffect at the end of the ScriptName line and the beginning of Spell in the first property declaration then entered fresh returns. The script compiled fine without errors.

 

Always use a plain text editor when writing script code outside of the Creation Kit. The same is true when copy / pasting from a web source, copy into a plain text editor before copying into the Creation Kit editor. Doing so removes any hidden characters that can cause issues with the compiler.

Link to comment
Share on other sites

I'll try again tomorrow after work. I removed the line and deleted the empty spaces and a fresh enter between the 2 lines. Now I get this :

 

D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(3,15): cannot name a variable or property the same as a known type or script
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(67,26): cast is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(67,26): cannot call the member function cast alone or on a type, must call it on a variable
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(69,16): variable SKSE is undefined
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(69,21): none is not a known user-defined type
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(69,41): cannot compare a none to a int (cast missing or types unrelated)
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(69,41): cannot relatively compare variables to None
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(71,32): GetCameraState is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(71,32): cannot call the member function GetCameraState alone or on a type, must call it on a variable
D:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\Nul_Strip_Effect_Script_002.psc(71,12): type mismatch while assigning to a int (cast missing or types unrelated)
No output generated for Nul_Strip_Effect_Script_002, compilation failed.
I'm going to download notepad++ and use that to paste the text into before copying to a new script and see if that solves my problem.
Appreciate the help.
Link to comment
Share on other sites

Make sure you have the SKSE PSC files extracted to the correct directory that the compiler is using. Or after installing Notepad++ set it up to compile PSC scripts and also set it up to use multiple source file locations (see here: https://www.creationkit.com/index.php?title=Notepad%2B%2B_Setup)

 

Basically, the compiler has to have access to the script being extended and on up the extension chain. The compiler also needs access to the scripts containing each function in use and if any of those functions call a function on yet another script it needs access to those too. If any of that is missing, you'll get errors similar to what you have posted.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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