Jump to content
ℹ️ Intermittent Download History issues ×

How to get reference?


Recommended Posts

I am trying to scan for in world objects with a keyword so a script will run when an animation is detected.

 

I was thinking of using "Event OnActivate(ObjectReference akActionRef)" and then scanning for keywords but I dont know how to get the reference of the item selected.

Link to comment
Share on other sites

Well, written a script and the compiler complaints are endless :)

Scriptname ATaAH_Terminal extends Quest

Event OnActivate(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		ObjectReference TerminalRef = game.GetReference()
		If TerminalRef.GetBaseObject() is Terminal
			If Game.GetPlayer(GetScale()) == PlayerScale
				TerminalRef.Disable
				Game.GetPlayer.SetScale(1.0)
				TerminalRef.Enable
				TerminalRef.Activate(Game.GetPlayer())
			Else 
				ObjectReference PlayerScale = Game.GetPlayer(GetScale())
				TerminalRef.Disable
				TerminalRef.Enable
				TerminalRef.Activate(Game.GetPlayer())
			EndIf
		EndIf
	EndIf
EndEvent

Event OnExitFurniture(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		Game.GetPlayer.SetScale(PlayerScale)
	EndIf
EndEvent

Link to comment
Share on other sites

Yep, not that it works at all.

 

Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "ATaAH_Terminal.psc"...
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(5,37): GetReference is not a function or does not exist
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(5,37): cannot call the member function GetReference alone or on a type, must call it on a variable
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(5,18): type mismatch while assigning to a objectreference (cast missing or types unrelated)
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(7,21): GetScale is not a function or does not exist
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(7,11): too many arguments passed to function
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(7,36): variable PlayerScale is undefined
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(7,33): cannot compare a void to a none (cast missing or types unrelated)
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(8,16): Disable is not a property on script objectreference or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(9,9): a property cannot be used directly on a type, it must be used on a variable
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(9,9): GetPlayer is not a property on script game or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(9,19): none is not a known user-defined script type
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(10,16): Enable is not a property on script objectreference or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(13,49): GetScale is not a function or does not exist
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(13,39): too many arguments passed to function
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(13,20): type mismatch while assigning to a objectreference (cast missing or types unrelated)
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(14,16): Disable is not a property on script objectreference or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(15,16): Enable is not a property on script objectreference or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(3,0): new event onactivate cannot be defined because the script is not flagged as native
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(24,7): a property cannot be used directly on a type, it must be used on a variable
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(24,7): GetPlayer is not a property on script game or one of its parents
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(24,26): variable PlayerScale is undefined
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(24,17): none is not a known user-defined script type
H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\ATaAH_Terminal.psc(22,0): new event onexitfurniture cannot be defined because the script is not flagged as native
No output generated for ATaAH_Terminal.psc, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on ATaAH_Terminal.psc
Link to comment
Share on other sites

Its designed for people who resize the player to be anything other than size 1. Unlike the old games where it didnt matter, in fallout 4 the terminal screen becomes misaligned when you try to use it while not the correct size.

 

redone script for spotted logic issues:

Scriptname ATaAH_Terminal extends Quest

Event OnActivate(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		ObjectReference TerminalRef = game.GetReference()
		If TerminalRef.GetBaseObject() is Terminal
			If Game.GetPlayer(GetScale()) == 1
			Else 
				ObjectReference PlayerScale = Game.GetPlayer(GetScale())
                                Game.GetPlayer.SetScale(1.0)
				TerminalRef.Disable
				TerminalRef.Enable
				TerminalRef.Activate(Game.GetPlayer())
			EndIf
		EndIf
	EndIf
EndEvent

Event OnExitFurniture(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		Game.GetPlayer.SetScale(PlayerScale)
	EndIf
EndEvent

This script was supposed to on activate check that its the player doing it and that the item is a terminal.

Then if player is not size 1, record player size, set player scale to 1 interrupt and then activate the terminal again.

Then on exit of terminal the player is returned to original size.

Link to comment
Share on other sites

1)First of all create new global variable. We will need that below.
2) Then create new perk. We will need that as well.

2)You cannot use OnActivate and OnExitFurniture in Quest type scripts they are events of ObjectReference script. (well you can use with remote event registration but it's bad option for this case, just believe me). We will still use one remote event though. remove everything from that quest script. paste this script:

GlobalVariable Property myglobvar Auto
Perk Property myperk Auto


Event OnInit()
	RegisterForRemoteEvent(Game.getplayer(),"OnGetUp")
        Game.getplayer().addperk(myperk)
endevent


Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)
	if (akFurniture is Terminal)
		Game.GetPlayer.SetScale(myglobvar.getvalue())
	endif
endEvent

Fill properties with perk and global variable you created earlier.

Then open your perk, add new entry everything should be like on this image:
http://i.imgur.com/yLXHvxh.png

 

Use this script for copy:

If !(Game.GetPlayer().GetScale() == 1)
	myglobvar.setvalue( Game.GetPlayer().GetScale())
       Game.GetPlayer().SetScale(1.0)
	akTargetRef.Disable()
	akTargetRef.Enable()
	akTargetRef.Activate(Game.GetPlayer())
EndIf

Btw you had problems in script. GetScale() cannot used as parameter. It is method which can be called on reference of player which is game.getplayer(). Also return value of getscale() is float not objectreference.

Link to comment
Share on other sites

Well.

looks like this is suffering the same problem unfortunately:

Scriptname ATaAH_Quest_Script extends Quest
 
GlobalVariable Property ATaAH_GlobalVariable Auto
Perk Property ATaAH_Perk Auto
 
Event OnInit()
  RegisterForRemoteEvent(Game.getplayer(),"OnGetUp")
  Game.getplayer().addperk(ATaAH_Perk)
endevent
 
Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)
  if (akFurniture is Terminal)
    Game.GetPlayer().SetScale(ATaAH_GlobalVariable.GetValue())
  endif
endEvent
Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "ATaAH_Quest_Script"...
C:\Users\stonf\AppData\Local\Temp\PapyrusTemp\ATaAH_Quest_Script.psc(12,17): cannot cast a objectreference to a terminal, types are incompatible
No output generated for ATaAH_Quest_Script, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on ATaAH_Quest_Script
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Perks:PRKF_ATaAH_Perk_01000F9A Extends Perk Hidden Const
 
;BEGIN FRAGMENT Fragment_Entry_00
Function Fragment_Entry_00(ObjectReference akTargetRef, Actor akActor)
;BEGIN CODE
If !(Game.GetPlayer().GetScale() == 1)
ATaAH_GlobalVariable.setvalue( Game.GetPlayer().GetScale())
       Game.GetPlayer().SetScale(1.0)
akTargetRef.Disable()
akTargetRef.Enable()
akTargetRef.Activate(Game.GetPlayer())
EndIf
;END CODE
EndFunction
;END FRAGMENT
 
;END FRAGMENT CODE - Do not edit anything between this and the begin comment
 
GlobalVariable Property PATaAH_GlobalVariable Auto Const Mandatory 

Papyrus Compiler Version 2.8.0.4 for Fallout 4

Copyright © ZeniMax Media. All rights reserved.

Starting 1 compile threads for 1 files...
Compiling "Fragments:Perks:PRKF_ATaAH_Perk_01000F9A"...
C:\Users\stonf\AppData\Local\Temp\PapyrusTemp\Fragments\Perks\PRKF_ATaAH_Perk_01000F9A.psc(8,1): variable ATaAH_GlobalVariable is undefined
C:\Users\stonf\AppData\Local\Temp\PapyrusTemp\Fragments\Perks\PRKF_ATaAH_Perk_01000F9A.psc(8,22): none is not a known user-defined script type
No output generated for Fragments:Perks:PRKF_ATaAH_Perk_01000F9A, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on Fragments:Perks:PRKF_ATaAH_Perk_01000F9A
Edited by stonefisher
Link to comment
Share on other sites

For first script error try. If (akFurniture.getbaseobject() is Terminal)

 

For second you have given different global variable property name and the one you use has different name than property.

 

P.s very often if you read errors they directly tell you what's a problem

Link to comment
Share on other sites

  • Recently Browsing   0 members

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