Pellape Posted July 10, 2022 Share Posted July 10, 2022 (edited) Hello everyone. I am an experianced Oblivion and Morrowind modder, but when I try to start scripting in Skyrim, all that knowledge is completely useless honestly, that's what I feel right now and I do not honestly have a slightest clue what I am doing. I am very frustrated honestly :D If you play Oblivion, just look at this what I did publish yesterday. I try slowly to make an Oblivion version of the Legacy of the Dragonbornm called, the Legacy of the Champion and so far I made 2-300 big scripts for it and honestly, I can script Oblivion and OBSE in my sleep. It does not look like the original, the Museun is at the Gold Coast, and i is only the principle that has anything in common with the original as I started to make a player home and went from there, where the original has the Museum in focus. Well lets leave this right now and focus at Skyrim. Okay, Oblivion is so easy as all functions really tell us in plain text what it is they are doing but when I look at many functions in Skyrim, my head just goes blank. How hard can it be? Very hard as it looks like right now. :D I would say that Oblivion is like Ansi C while Skyrim is like C++ and honestly, i have no problems with Ansi C either, but C++ in the other hand... Lets leave that now. :D I have no problems with VB really... Damn Skyrim... I try to make a very very simple mod that will make life easier and so far, it has a chest and a button that are placed in the Bannered Mare in Whiterun. The goal is to make an Auto Seller as I am so bloody tired of poking around in my inventory after a hunt as there is really funnier things to do. I have similar in Oblivion, where I use a dynamic sorter I made. So: I want to place some items in a chest and when I push a button, I want to have the chest inventory compared with the player inventory and sell all stuff per auto that has the same ObjectID as the items in the chest. So the chest works as an array or a formlist but I do not need those really, as I think a simple chest should be enough and I do not want to sell the items from the chest, just the same item from my inventory. In Oblivion we have 4 different Properties in the vamilla game and a couple of more with OBSE but they are simple: Ref (Object References)Short (a short version of float)Long (A long version of Float)Float (Everything is floats in Oblivion as a short is just a truncated float) So a sword object is a Ref in Oblivion and should be a ObjectReference in Skyrim but if it is in the chest, it seems to be a form right? Oki, lets jump to my script I try to Compile inside CK and we also look at the compiling result. Scriptname PekSellAllThisStuff extends ObjectReference {My First Skyrim Scriipt!} Int PekNumberOfItemsinStack Int PekFormIndex Int PekGoldValue Form PekForm Event OnActivate (ObjectReference akActionRef) PekFormIndex = PekDropChestREF.GetNumItems() Debug.Notification("Button Clicked Message") Debug.Trace("Button Clicked Console") While PekFormIndex > 0 PekFormIndex -= 1 PekForm = PekDropChestREF.GetNthForm(PekFormIndex) PekNumberOfItemsinStack = Player.GetItemCount(PekForm) PekGoldValue = PekForm.GetGoldValue() PekGoldValue = PekGoldValue * PekNumberOfItemsinStack Player.RemoveItem(PekForm, PekNumberOfItemsinStack ) Player.Additem(GoldBase, PekGoldValue) EndWhile endEvent So here is the result: :/ Starting 1 compile threads for 1 files... Compiling "PekSellAllThisStuff"... I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(13,16): variable PekDropChestREF is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(13,32): none is not a known user-defined type I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(13,1): type mismatch while assigning to a int (cast missing or types unrelated) I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(22,12): variable PekDropChestREF is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(22,28): none is not a known user-defined type I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(23,28): variable Player is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(23,35): none is not a known user-defined type I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(23,2): type mismatch while assigning to a int (cast missing or types unrelated) I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(28,2): variable Player is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(28,9): none is not a known user-defined type I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(29,2): variable Player is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(29,17): variable GoldBase is undefined I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellAllThisStuff.psc(29,9): none is not a known user-defined type No output generated for PekSellAllThisStuff, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on PekSellAllThisStuff In Oblivion, I would been forced to set the chest to be resitant and there is no checkboxes where I can check this. I saw GoldBase was used in an example but the Gold object is Gold001 if I recall right? I aslo saw that we must also include the Game? Like: Game.PlayerRef.BLABLA() ??? I also saw that a script has properties, do we add the variables there? In Oblivon we just declare variables at the top, add our script between Begin and End and we compile and go and play the game like any happy player would do :D Damn Skyrim... I will learn this, one way or another really. How hard can it be? A lot it seems really.... :wink: Edited July 10, 2022 by Pellape Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 10, 2022 Share Posted July 10, 2022 Yes. You are correct. You need to declare your properties outside of the script body. So, before (or after) the body of script: ObjectReference PROPERTY PekDropChestREF auto for example. Then fill the property on the properties tab on the form. Another example: the player, being an actor, it would be: Actor PROPERTY PlayerRef Auto Etc If you declare a property, as above, that is used in your script body, you must also fill it in the properties tab. Link to comment Share on other sites More sharing options...
Pellape Posted July 10, 2022 Author Share Posted July 10, 2022 (edited) I get the impression it goes hand in hand. But still, there is a couple of things that do not work. I do not get PrintConsole to work. I have installed PapyruUtil and now I test this script. Scriptname PekSellAllThisStuff extends ObjectReference {My first working Script} Actor Property PlayerREF Auto Container Property PekDropChestREF Auto function PrintConsole(string text) global native Event OnActivate (ObjectReference akActionRef) Debug.Notification ("A Message " + PlayerREF as String + akActionRef as String) Debug.Trace ("A Message but where?") If akActionRef == PlayerREF Debug.MessageBox ("A box") PrintConsole ("Message") EndIf Debug.MessageBox ("A box") PrintConsole ("Message") endEventSo the PlayerREF is NONEThe akActionRef is now Actor at leastI do not know if the script are able to find the PekDropChestREF really. I do get a Message Box at least :D When we compare References in Oblivion, we must use if eval (Ref == Ref)Eval was implememeted by OBSE and are able to evaluate anything really but then we must have something and as PlayerREF = None and akActionRef = Actor, no wonder the IF fails... :wink: I will now try a different approach and code at the chest instead, with 2 events. OnActivate and we sall see what the other will be, like OnClose? Edited July 10, 2022 by Pellape Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 10, 2022 Share Posted July 10, 2022 Use ObjectReference instead of container in the property declaration (although Im not seeing the container referenced in your script body anymore) Fill the properties in the property tab under scripts on the form the script is attached to. Use autofill box for PlayerREF Link to comment Share on other sites More sharing options...
Pellape Posted July 10, 2022 Author Share Posted July 10, 2022 Well I ot so far in my chestScript. I want the script to count the number of unique Items in the chest, in the Onlose Event but it does not know what GetNumItems() is. I should reinstall the SKSE64 scripts I guess... :/ But they are there... :sad: Well the script gets this error now: Scriptname PekSellChestSCR extends ObjectReference {The Script at the container} function PrintConsole(string text) global native ObjectReference ChestForm Int Function GetNumItems() Native Event OnActivate (ObjectReference akActionRef) ChestForm = Self Debug.Notification ("This is " + Self as String + ChestForm as String) MiscUtil.PrintConsole ("Chest is open") EndEvent Event Onclose (ObjectReference akActionRef) Int ItemsIndex = ChestForm.GetNumItems() MiscUtil.PrintConsole ("Chest is Closed, ItemCount = " + ItemsIndex as string ) EndEvent Output is: Starting 1 compile threads for 1 files... Compiling "PekSellChestSCR"... I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(20,28): GetNumItems is not a function or does not exist I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(20,5): type mismatch while assigning to a int (cast missing or types unrelated) No output generated for PekSellChestSCR, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on PekSellChestSCR Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 11, 2022 Share Posted July 11, 2022 Make sure you have the SKSE source files copied to the correct directory that the compiler is looking for. If you have not changed your INI setting, the default is "Data > Source > Scripts". This is different from 32 bit Skyrim where it was "Data > Scripts > Source". SKSE along with some other mods use the 32 bit Skyrim folder structure as they saw the change as a "bug" rather than an "improvement" Once you have ensured that the SKSE PSC files are in the correct location, the compiler should get passed the GetNumItems error. The next error should be taken care off automatically as GetNumItems will be able to return an integer. Link to comment Share on other sites More sharing options...
Pellape Posted July 11, 2022 Author Share Posted July 11, 2022 (edited) I do have SKSE64 installed, copied everything so where do I find that ini setting? Is it a SKSE ini or Skyrim ini? You are on the right track here I guess. I got some advices at the Vanilla Skyrim forum and this script should work if everything is setup correct. The changes suggested to me, I copied and pasted it as it was suggested and the Compiler cannot find GetNumItems() nor UnRegisterForMenu and I made sure now again to copy EVERY script from the SKSE64 package, for v1.5.97 which is the game version I am using, so I use SKSE64 2.00.20 and unpacked it, copied every file to my Skyrim Game Folder. I have some real problems here now I guess as something is not working properly. Scriptname PekSellChestSCR extends ObjectReference {The Script at the container} ObjectReference ChestForm Event OnActivate (ObjectReference akActionRef) ChestForm = Self Debug.Notification ("This is " + Self as String + ChestForm as String) MiscUtil.PrintConsole ("Chest is open") RegisterForMenu("ContainerMenu") EndEvent Event OnMenuClose(String menuName) If menuName == "ContainerMenu" UnRegisterForMenu("ContainerMenu") Int ItemsIndex = ChestForm.GetNumItems() MiscUtil.PrintConsole ("Chest is Closed, ItemCount = " + ItemsIndex as string ) Int MyInt = MyCustomIntFunction() Debug.Notification(MyInt) Endif EndEvent Int Function MyCustomIntFunction() return 5 EndFunction I get these errors, and I should not get them really. Starting 1 compile threads for 1 files... Compiling "PekSellChestSCR"... I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(12,4): RegisterForMenu is not a function or does not exist I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(17,8): UnRegisterForMenu is not a function or does not exist I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(18,35): GetNumItems is not a function or does not exist I:\The Elder Scrolls - Skyrim - Special Edition\Data\Source\Scripts\temp\PekSellChestSCR.psc(18,12): type mismatch while assigning to a int (cast missing or types unrelated) No output generated for PekSellChestSCR, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on PekSellChestSCR Lets peek at GetNumItems() - That function is inside the Data\Scripts\ObjectReference.pex and the source is in Data\Scripts\Source\ObjectReference.psc so the problem I have seems to be that something here is really screwed up? I get the impression I must import these functions in some way? Just look at the PrintConsole, as I got that one working after I typed MiscUtil.PrintConsole In C we must include every header file in every Script and for every function we are using, from each specific precompiled source... It must be something here I really missed to do... I have not edited the ini settings. I took the whole Data\Scripts folder and copied it to Data\Source and I still get the same errors. I get the feeling this is CK related really. This script should work. I double checked now and the ObjectReference.Pex is now both in Data\Scripts and in Data\Source\Scrips and so is UI.PEX so what I need now, is really help to sort this problem out. Edited July 11, 2022 by Pellape Link to comment Share on other sites More sharing options...
Pellape Posted July 11, 2022 Author Share Posted July 11, 2022 As this seems to be a technical problem, I sent an email to the SKSE team, as if someone can tell me what is wrong here, they can. This is now more of a technical issue than a modding issue. Link to comment Share on other sites More sharing options...
Pellape Posted July 11, 2022 Author Share Posted July 11, 2022 (edited) IsharaMeradin you and also Dylbill made my day!!!! :DIt was not only the folder I needed to move, as it was the *.pcs files that DylBill pointed out in this thread: https://forums.nexusmods.com/index.php?/topic/11664183-some-scripting-tips-making-a-auto-sell-stuff-mod/&do=findComment&comment=111711903I really needed more detailed help really to solve this. ;) Finally... Now we can back to make a bloody script that will work. Starting 1 compile threads for 1 files... Compiling "PekSellChestSCR"... Starting assembly of PekSellChestSCR 0 error(s), 0 warning(s) Assembly succeeded Compilation succeeded. Edited July 11, 2022 by Pellape Link to comment Share on other sites More sharing options...
Recommended Posts