Jump to content

Papyrus Script - GetWornForm and GetWeightClass not working


DarkWolfModding

Recommended Posts

Im testing out a theory of a mod I have been thinking of making for a long time. It will convert heavy armor to light armor class and vice versa. But I have a problem with the conversion Script it gives me the errors

"GetWornForm is not a function or does not exist"

"GetWeightClass is not a function or does not exist"

 

 

Heres the script.

Scriptname ArmorConverterSCRIPT Extends Quest
import game
import debug
import utility
ArmorConverter_MCM_SCRIPT Property MCM_Menu Auto
Actor Property PlayerREF Auto
Event OnInit()
if (MCM_Menu.akModEnabled == true)
RegisterForUpdate(1.0)
ElseIf (MCM_Menu.akModEnabled == False)
UnRegisterForUpdate()
EndIf
EndEvent
Event OnUpdate()
Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001)
Armor ArmorTorso = PlayerREF.GetWornForm(0x00000004)
Armor ArmorBoots = PlayerREF.GetWornForm(0x00000080)
Armor ArmorGloves = PlayerREF.GetWornForm(0x00000008)
Int HelmetWeightClass = ArmorHelmet.GetWeightClass()
Int TorsoWeightClass = ArmorTorso.GetWeightClass()
Int BootsWeightClass = ArmorBoots.GetWeightClass()
Int GlovesWeightClass = ArmorGloves.GetWeightClass()
if (MCM_Menu.akHeavyAsLight == true)
ElseIf (MCM_Menu.akLightAsHeavy == true)
EndIf
EndEvent
I have tried to change the Extends to ObjectReference, Actor, Quest.
All of them give me the same error.
Please Help.
Link to comment
Share on other sites

GetWornForm returns the FORM. You are trying to put it into an ARMOR variable. Cast it from Form into Armor.

Example:

Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001) as Armor

 

Fix the GetWornForm entries and GetWeightClass should work. Its syntax should already be correct.

Link to comment
Share on other sites

GetWornForm returns the FORM. You are trying to put it into an ARMOR variable. Cast it from Form into Armor.

Example:

Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001) as Armor

 

Fix the GetWornForm entries and GetWeightClass should work. Its syntax should already be correct.

I tried that before I posted here and same errors.

It adds this error

"cannot cast a none to a armor, types are incompatible"

Link to comment
Share on other sites

Edit you code with the following lines and try again. I ran them through the compiler and got no error.

    Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001) as Armor
    Armor ArmorTorso = PlayerREF.GetWornForm(0x00000004) as Armor
    Armor ArmorBoots = PlayerREF.GetWornForm(0x00000080) as Armor
    Armor ArmorGloves = PlayerREF.GetWornForm(0x00000008) as Armor


Edited by Terra Nova
Link to comment
Share on other sites

 

Edit you code with the following lines and try again. I ran them through the compiler and got no error.

    Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001) as Armor
    Armor ArmorTorso = PlayerREF.GetWornForm(0x00000004) as Armor
    Armor ArmorBoots = PlayerREF.GetWornForm(0x00000080) as Armor
    Armor ArmorGloves = PlayerREF.GetWornForm(0x00000008) as Armor


I have that on my script I still get Errors. :(

Heres the current Script:

Scriptname ArmorConverterSCRIPT Extends Quest
import game
import debug
import utility
ArmorConverter_MCM_SCRIPT Property MCM_Menu Auto
Actor Property PlayerREF Auto
Event OnInit()
if (MCM_Menu.akModEnabled == true)
RegisterForUpdate(1.0)
ElseIf (MCM_Menu.akModEnabled == false)
UnRegisterForUpdate()
EndIf
EndEvent
Event OnUpdate()
Armor ArmorHelmet = PlayerREF.GetWornForm(0x00000001) as Armor
Armor ArmorTorso = PlayerREF.GetWornForm(0x00000004) as Armor
Armor ArmorBoots = PlayerREF.GetWornForm(0x00000080) as Armor
Armor ArmorGloves = PlayerREF.GetWornForm(0x00000008) as Armor
Int HelmetWeightClass = ArmorHelmet.GetWeightClass()
Int TorsoWeightClass = ArmorTorso.GetWeightClass()
Int BootsWeightClass = ArmorBoots.GetWeightClass()
Int GlovesWeightClass = ArmorGloves.GetWeightClass()
if (MCM_Menu.akHeavyAsLight == true)
if (HelmetWeightClass == 1) ;isHeavy
ArmorHelmet.SetWeightClass(0)
EndIf
If (TorsoWeightClass == 1)
ArmorTorso.SetWeightClass(0)
EndIf
If (BootsWeightClass == 1)
ArmorBoots.SetWeightClass(0)
EndIf
If (GlovesWeightClass == 1)
ArmorGloves.SetWeightClass(0)
EndIf
ElseIf (MCM_Menu.akLightAsHeavy == true)
EndIf
EndEvent
When I compile that exact script the output is this:
Starting 1 compile threads for 1 files...
Compiling "ArmorConverterSCRIPT"...
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(18,33): GetWornForm is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(18,57): cannot cast a none to a armor, types are incompatible
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(19,33): GetWornForm is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(19,57): cannot cast a none to a armor, types are incompatible
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(20,33): GetWornForm is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(20,57): cannot cast a none to a armor, types are incompatible
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(21,34): GetWornForm is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(21,58): cannot cast a none to a armor, types are incompatible
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(23,37): GetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(23,5): type mismatch while assigning to a int (cast missing or types unrelated)
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(24,35): GetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(24,5): type mismatch while assigning to a int (cast missing or types unrelated)
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(25,35): GetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(25,5): type mismatch while assigning to a int (cast missing or types unrelated)
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(26,37): GetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(26,5): type mismatch while assigning to a int (cast missing or types unrelated)
No output generated for ArmorConverterSCRIPT.psc, compilation failed.
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(30,16): SetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(33,15): SetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(36,15): SetWeightClass is not a function or does not exist
D:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\ArmorConverterSCRIPT.psc(39,16): SetWeightClass is not a function or does not exist
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on ArmorConverterSCRIPT.psc
[Finished in 1.1s]

 

 

If it helps I use SublimeText 2 to do all my scripting and compiling.

Link to comment
Share on other sites

Since the syntax is now correct, the next step is to ensure that SKSE is properly installed. Please make sure that you have the PEX files from SKSE in Data > Scripts and the PSC files from SKSE in Data > Scripts > Source (or wherever you've directed papyrus to look for source files)

Link to comment
Share on other sites

Since the syntax is now correct, the next step is to ensure that SKSE is properly installed. Please make sure that you have the PEX files from SKSE in Data > Scripts and the PSC files from SKSE in Data > Scripts > Source (or wherever you've directed papyrus to look for source files)

Hmm I copied everything in the SKSE archive and replaced everything and now it compiles.

 

I just wanted to say thank you to all the fellow modders for helping me out on small things like this.

If anyone else who sees this please go here to this topic. here and see if you can help me on that topic.

Link to comment
Share on other sites

Also put some if-else conditions around the functions you're calling off from the returned armor forms (namely, the GetWeightClass() functions). GetWornForm() could return a none value if nothing is being worn at that armor slot. If you then call GetWeightClass() or SetWeightClass() on that none form, the papyrus log will spit out an error. A player walking around naked in Skyrim for a few minutes could result in thousands of lines of errors clogging up the papyrus log.

i.e. 4 forms with values of 'none' x 4 errors from GetWeightClass() * 60 seconds if script is run once per second * 10 minutes = 9,600 lines in the papyrus log all complaining about the same thing.

 

Or maybe that won't happen in practice, but have a look at your papyrus log anyway and resolve any issues that come up related to your mod :smile:

Edited by RealAntithesis
Link to comment
Share on other sites

  • Recently Browsing   0 members

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