Jump to content

[LE] Some scripting Tips? Making a auto sell stuff mod...


Recommended Posts

If the debug calls are just for debugging, how do I get text from a script into the console? The examples given to popup messageboxes, messages starts with Degug.Notification as one example and you use them as well right? You did have

Debug.Notification("Items were sold for " + Counter as String + " pennies")

in your script, which = Message in TES 3 and 4 but I want to see messages in the console, not spam the top left of the screen with text :wink:, not more than necessary at least. So in Oblivion we have

PrintToConsole "This line will be printed into the console" + ThisVariable + "%.0f", AShortIntegerASVariable2

and we have 2 different ways of adding the variables as well, as OBSE use the way you do it and vanilla CS can only have the variables outside the "" as that AShortInteger in the example above. So how do I do this in CK?

Edited by Pellape
Link to comment
Share on other sites

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

I also just noticed that this is the Vanilla Skyrim forum and I use Skyrim SE. I did add my failures at the SE forum and if you wanna give me an helping hand, to sort this out, feel free to read this link: https://forums.nexusmods.com/index.php?/topic/11684223-help-scripting/&do=findComment&comment=111656898

 

I could make a copy here, but lets just keep my frustrations in one single thread. I think I at least now know what a property really is. :D

 

We can do this. YES WE CAN!!! Well it does not feel like it right now honestly. Someone must know what I did wrong. So why do I just not look at other modders scripts? Yes, why not? I could start by looking at Legacy of the Dragonborn that has a sell chest inside the Hideout or rather SafeRoom. All I need is to get that button to work as I guess it is a quest that triggers the chest in the SafeHouse.

 

Thanks IsharaMeradin. Well Neither do Oblivion as it is an OBSE function when I think about it. We also have a very cool mod called ConScribe that writes the Console down to a log file, which is extremely useful. All error messages pops up in the console, which makes debugging so much easier, specially when I fail to use an array as they are so bloody sensitive. If a Object Starts with a number, the array refuse to accept it as one stupid example and the arrays is nothing but a pointer to any damn property we put into it in OBSE, so why does it even bother? I could ask idle, the xOBSE author that tries to fix OBSE right now. :D I bug that poor fellow a lot :wink: When he solve one bug, he always manage to make a new one :D

 

By the way, if you do play Oblivion, look up my latest project that I released 2 days ago: The Legacy of the Champion.

Edited by Pellape
Link to comment
Share on other sites

Oki... I decided to start even more simple, to get a working script. You did mention Properties, and I start to understand slowly what a Property really is as it seems we have to tell Skyrim every tiny detail for it to understand Papyrus at all it seems. I am so bloody spoiled in Oblivion where we do not need to do this.

 

So the player has the Property Actor right? So what property has a container? If I want to declare the container in my button or use it at all, I must make it Persistent right? It seems even if I give a Reference a name, I cannot check it as Persistent. Actors gets the persistent ref per auto if I am correct but other objects do not if I am onboard this train correctly :D

 

I did peek at the StoneActivators and they have loads of stuff declared as Properties... I should start there really... I really want to script in a similar structure that I am used to, to feel I have control over what I am doing at all, as I do not for sure. I do not wanna cheat to get around the proper way of coding, so if declarations of Properties is needed, so be it. I want my scripts to be crystal clear. The best scripte in Oblivion, does not script clear, as he is a master of optimating stuff. I did ask him if he tried to script Skyrim.

Link to comment
Share on other sites

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")


endEvent

So the PlayerREF is NONE

The akActionRef is now Actor at least

I 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... ;)

Edited by Pellape
Link to comment
Share on other sites

You're trying to define the function printConsole as a property, you don't need to do that. Instead, do this:

 

Actor Property PlayerREF Auto
Container Property PekDropChestREF  Auto  

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")
        MiscUtil.PrintConsole ("Message")
    EndIf
    
    Debug.MessageBox ("A box")
    MiscUtil.PrintConsole ("Message")

endEvent
Link to comment
Share on other sites

If playerRef is none, it means you didn't fill properties in the creation kit. After attaching your script, click on the properties tab in the CK, then hit Auto Fill All button. If your property in the script is named the same as the thing you're trying to reference in the CK, it will be auto linked.

 

Declaring a property in papyrus tells papyrus that something of that type exists in the script, but it doesn't know what it references. You have to tell it what it is, either by filling (linking) the property in the creation kit, or by setting it with another script function or event. You can also do:

 

Event OnInit()
    PlayerREF = Game.GetPlayer()
EndEvent

A note, when you say Actor Property, what it's doing is actually referencing the Actor.psc script. This means you can also make your own property types.

 

So for example, if you had your script like so:

 

Scriptname PekSellAllThisStuff  extends ObjectReference  

{My first working Script}

Int Property MyInt = 5 Auto 

In another script you can do this:

Scriptname AnotherScript Extends ObjectReference

PekSellAllThisStuff Property PekSellAllThisStuffREF Auto 

Event OnInit 
    Debug.Notification("MyInt = " + PekSellAllThisStuffREF.MyInt)
EndEvent
Link to comment
Share on other sites

Thanks Dybill for making this so clear. I sure get mpore vice now (I hope) but I will now try another approach, coding at the chest instead at a button. I need the button to work anyway, one day, I guess. Lets see what I can get up with really...

Link to comment
Share on other sites

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... :/ Nut 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

Edited by Pellape
Link to comment
Share on other sites

Again, you shouldn't define functions in your script if they are already defined somewhere else. You can however make custom functions in your own script. Also, OnClose won't work as you expect, that's for when the an actor closes a door for instance. It fires when the object is done animating. Instead you can use OnMenuClose.

 

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

For valid menus check out UI.psc

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...