irswat Posted November 16, 2016 Share Posted November 16, 2016 any idea why the compiler is throwing this error: type mismatch while assigning to a int (cast missing or types unrelated) if MatchingWords==LengthOfCMDItem tempWeap=WeaponFormList.GetAt(CompareArrayCounter1) tempWeapBaseDMG=tempWeap.GetBaseDamage() if PlayerREF.GetItemCount(tempWeap)>=1 debug.trace("Efficiency exception detected.") ;perfect match found FormToReturn=tempWeap break=true endif endif Link to comment Share on other sites More sharing options...
Surilindur Posted November 16, 2016 Share Posted November 16, 2016 (edited) It could maybe be of help to know which line the error was on. There does not seem to be anything totally wrong in that one. Judging by the wiki examples, it might work a bit like this: FormList property WeapFormList auto function DamageTest(int Index) Weapon TempWeap = WeapFormList.GetAt(Index) as Weapon int TempDamage = TempWeap.GetBaseDamage() Debug.MessageBox("WeapList[" + Index + "] = " + TempWeap + " (dmg " + TempDamage +")") endfunctionAt least according to the GetBaseDamage page I think (in a hurry at the moment, so I might have read something wrong, too. :blush: http://www.creationkit.com/index.php?title=GetBaseDamage_-_Weapon Hopefully that helps a bit. Edited November 16, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
FrankFamily Posted November 16, 2016 Share Posted November 16, 2016 If tempweap is of weapon type then i think you have to cast getat as weapon since it returns form. Link to comment Share on other sites More sharing options...
irswat Posted November 16, 2016 Author Share Posted November 16, 2016 Sorry. Error is on int TempDamage = TempWeap.GetBaseDamage(): type mismatch while assigning to a int (cast missing or types unrelated) tempWeap is declared as a form. I wonder if something like this would work:TempDMG=tempWeap as Weapon.GetBaseDamage() I'll try it after work. thanks guys. Link to comment Share on other sites More sharing options...
Surilindur Posted November 16, 2016 Share Posted November 16, 2016 (edited) The issue seems to be with the type of the weapon variable set to Form. I finally got home, and tested it (out of curiosity), and using a "Form TempWeap" instead of "Weapon TempWeap" causes the error when compiling. However I use SublimePapyrus myself so it highlights the missing function GetBaseDamage when I type it in and try to use it on a Form (instead of a Weapon). As in, this causes an error (obviously, Form does not have that function): Form TempWeapon = WeaponList.GetAt(Index) ; <-- GetAt returns a Form int TempDamage = TempWeap.GetBaseDamage() ; <-- Form Script has no "GetBaseDamage" functionThis one also causes an error (missing cast, GetAt returns a Form): Weapon TempWeapon = WeapList.GetAt(Index) ; <-- GetAt returns a FormHowever this works fine: Form TempWeapon = WeaponList.GetAt(Index) ; <-- getAt returns a Form int TempDamage = (TempWeap as Weapon).GetBaseDamage() ; <-- calling GetBaseDamage on Weapon (the cast result)And this one also works fine: Weapon TempWeapon = WeaponList.GetAt(Index) as Weapon ; <-- get the Form as a Weapon straight away int TempDamage = TempWeapon.GetBaseDamage() ; <-- TempWeapon is already a WeaponIf you want to do lots and lots of Papyrus scripting, and use Sublime Text as your text editor (I use Sublime Text 3), SublimePapyrus by mrpwn is a great utility. Definitely recommended. It checks your scripts on the fly, offers all sorts of completions when typing and also offers the ability to import sources from here and there. Definitely invaluable, and actually makes scripting fun, too. Here --> http://www.nexusmods.com/skyrim/mods/60810 Hopefully that helps a bit. :thumbsup: Edit: Still cannot type... :facepalm: Edited November 16, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
irswat Posted November 16, 2016 Author Share Posted November 16, 2016 thanks for your help. blessings Link to comment Share on other sites More sharing options...
Surilindur Posted November 16, 2016 Share Posted November 16, 2016 No problem. Happy modding. Your project sounds ambitious, so I wish you luck with it. :) Link to comment Share on other sites More sharing options...
Recommended Posts