Jump to content

[LE] Whats wrong with my script?


ibengames

Recommended Posts

I watched this TuT from Darkfox127 about "Build Your Own Home" But his Script had more than i wanted so i just took the parts of it i need.

 

 

Scriptname BYOHBuildingiben

ObjectReference Property EnableRef_01 auto
ObjectReference Property EnableRef_02 auto
ObjectReference Property EnableRef_03 auto
ObjectReference Property DisableRef_01 auto

MiscObject Property CraftItem Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

Game.FadeOutGame(false, true, 2.0, 1.0)
EnableAll()
Game.GetPlayer().RemoveItem(CraftItem,1,True)
Return

EndEvent

Function EnableAll()

EnableRef_01.enable()
EnableRef_02.enable()
EnableRef_03.enable()
DisableRef_01.disable()

EndFunction

 

Compiling was no Problem and it partly works ingame.

At first i was able to set the item into the workbench, (the hearthfire and the selfmade) ive build the item and the script managed to delete the item as intended. But the enabling Part did not work.

So i added the "FadeOutGame" but that made it even worse, the game does not fade out and the item does not get deleted, and still no enabling of the references.

From the Script in the TuT i cant see what i did wrong.

I hope someone can tell me my mistake.

 

Link to comment
Share on other sites

For this kinds of issues, there's a diagnostic trick

Step 1: Get Papyrus Util installed

Step 2, Add MiscUtil.PrintConsole("Some Text" + SomeVariableOrProperty)

 

In this case, you first want to know if your script is actually correctly set to that specific ObjectReference, so the line would be MiscUtil.PrintConsole("Enable" + EnableRef_01)

If the console gives you an ID, it means at least it knows it should enable an object reference.

For whatever reason, some times, some stuff makes references go "None" and it could be enabling nothing... or even the wrong Objectreference

Another possibility is the script not doing anything at all, you can know this because when the function gets called, console will print nothing.

Possibilities go far beyond simple variable testing, you can eventually test every level of functionality (Events, Functions etc..) of the script with this trick, and of course, eventually find the part where it went wrong.

Link to comment
Share on other sites

I'm guessing you left the Extends part off of the Scriptname line when posting the code. Cause without that, I'd see no way that it would compile correctly and you stated that it compiled fine.

 

Are you testing on a new game? Did you fill all properties correctly?

 

It'll compile without the extends, but it won't do anything. Every event and function in the script is either declared in it or in objects that are either universally available (Game) or themselves specifically declared (the ObjectReference properties).

 

I am not sure if it will receive OnContainerChanged events unless it does extend ObjectReference though. That's something you'd find out at runtime; I'd make it extend ObjectReference anyway just for clarity.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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