Jump to content

Can't get scripts to run in-game (yes, I'm a noob...)


Recommended Posts

Hi there. Total beginner to modding and scripting, here. As a first step I just wanted to make the "Hello World" tutorial and see how it goes... it didn't go anywhere...
I've created a new quest, set it to 'start game enabled' and 'run once' and added the script:â
scriptname samplescript extends quest


event onquestinit()

   debug.messagebox("Hello World")

endevent

As I understand it, a confirmation box with and "OK" button should pop up when I loaded the game, but it didn't.

 

I added an object to see if the mod was loading properly, and the object appeared in-game.

 

I added a quest stage with the papyrus fragment "setobjectivedisplayed(10)" (10 being the index of the stage) and nothing happened. I added a book with the script:

scriptname overhaul_scriptbook extends objectreference const
â
event onread()
   debug.messagebox("This player's life is now enriched!")
endevent

The book is there (on the floor outside of Vault 111's exit, next to the ramp of the blue room thing with the button to the Vault's entrance) and I can read it. But the message box does not appear.

 

I am probably missing something really really stupid here. Something so basic you wouldn't even consider I would be doing wrong. But I might.

 

Please if anybody can shed some light here that would be greatly appreciated. I can't move forward with learning scripting if I can't even get the scripts running in the game.

 

Thanks in advance.

 

 

 

Link to comment
Share on other sites

So, I added

bInvalidateOlderFiles=1

to Fallout4.ini and the book script is running. So I guess that solves it. I can't get the quest script to run yet but I reckon that is a problem with loading the quest rather than the script itself. So I'll work on that now. Thanks.

Link to comment
Share on other sites

From my experience so far, OnQuestInit() will not show a debug.messagebox() without some help. You could try adding

event onquestinit()
  Actor PlayerREF = Game.GetPlayer()
  if PlayerREF.WaitFor3DLoad()
    Debug.MessageBox("The players 3d has loaded")
  endif
endevent

and then it should show up for you. I just tried it and it worked for me, though, my PlayerRef is pulled from a ref alias. Otherwise I think the init section happens so early in load that your screen isn't even loaded yet for the messagebox to fire properly.

Edited by kwong96
Link to comment
Share on other sites

I placed your code instead of the onquestini() event and got this on compile:

C:\Users\faint\AppData\Local\Temp\PapyrusTemp\SampleScript.psc(3,18): no viable alternative at input 'Game'
C:\Users\faint\AppData\Local\Temp\PapyrusTemp\SampleScript.psc(3,22): required (...)+ loop did not match anything at input '.'
C:\Users\faint\AppData\Local\Temp\PapyrusTemp\SampleScript.psc(3,6): Unknown user flag game

Also, if I want a script to be always running, is attaching it to a quest the best way to do it?

Edited by Haruochan1
Link to comment
Share on other sites

I can't say if it is the "best" way to do it, maybe someone more experienced with CK can answer that, but it is how I would do it as well.

 

As to the code, that's weird it can't find "Game". Try adding a property for the PlayerRef instead then. Compile and open the properties panel and the PlayerRef should be able to autofill, otherwise select "any" for the cell and PlayerRef('Player') for the reference.

Actor Property PlayerRef Auto Const
Event OnQuestInit()
  if PlayerRef.WaitFor3DLoad()
    Debug.MessageBox("The player has loaded his 3d")
  endif
EndEvent
Link to comment
Share on other sites

It compiled and auto-filled. But nothing happened in-game.

 

What's the easiest way to check if the quest is loading at all?

 

 

+++++++

 

Used OnInit() instead of OnQuestInit() and it worked!!

 

Yay

 

Any idea why? And any idea on why game.getplayer() wasn't working?

Edited by Haruochan1
Link to comment
Share on other sites

At least OnInit works for you. I don't know why OnQuestInit didn't show anything with that since I did try it myself and it worked. Unless your quest isn't loading properly. You should be able to double check in-game by doing "sqs questname" from the console. If it isn't showing as running then that might be why. I just double checked and mine is extended from "Quest Conditional", possible that has something to do with it as well since Actor PlayerRefTwo = Game.GetPlayer() inside of OnQuestInit() compiles fine for me, but again mine extended with "Conditional" at the end.

 

Just to make sure... I just made a blank script...

 

Scriptname TrashScript extends Quest


Event OnQuestInit()
  Actor PlayerRef = Game.GetPlayer()
    if PlayerRef.WaitFor3DLoad()
      Debug.MessageBox("The player has loaded his 3d")
    endif
endEvent

and this compiled with no errors for me. So I'm at a loss as to why.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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