Jump to content

[LE] Script Help - Fast Travel


Plarux

Recommended Posts

Hello everyone,

 

I'm currently trying to create a script that teleports the player (only if they have the location discovered) via activator.

Not sure what I'm doing wrong, but I think that I've got the right idea.

 

Here's what I have (attached to an activator):

Scriptname Plarux_FastTravelMenu02 extends ObjectReference  

Message Property PL_FastTravelMenu02  Auto
Message Property PL_LND_Message_Solstheim Auto
ObjectReference Property SolstheimMapMarker Auto
ObjectReference Property SolstheimMarker Auto


Event OnActivate(ObjectReference akActionRef)
	IsLocationDiscovered()

EndEvent

Bool Function IsLocationDiscovered(ObjectReference SolstheimMapMarker)

if (SolstheimMapMarker.GetMapMarkerVisible() == 2)
    Menu()
elseif
    PL_LND_Message_Solstheim.show()
endif
EndFunction

Function Menu(int aButton = 0)
	aButton = PL_FastTravelMenu02.show()
	If aButton == 0
		Game.FadeOutGame(False, True, 2.0, 1.0)
		Game.GetPlayer().MoveTo(SolstheimMarker)
		Game.EnableFastTravel()
		Game.FastTravel(SolstheimMarker)
	ElseIf aButton == 1
		
	EndIf
EndFunction

Compile Output:

Starting 1 compile threads for 1 files...
Compiling "Plarux_FastTravelMenu02"...
E:\Program Files\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Plarux_FastTravelMenu02.psc(18,6): no viable alternative at input '\\r\\n'
No output generated for Plarux_FastTravelMenu02, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on Plarux_FastTravelMenu02

I'm not sure what the third line of the Compile Output means, and require assistance figuring out what to do next.

 

Thank You,

Plarux

Edited by Plarux
Link to comment
Share on other sites

Your problem is here:

if (SolstheimMapMarker.GetMapMarkerVisible() == 2)
    Menu()
elseif
    PL_LND_Message_Solstheim.show()
endif

Given what your script is doing, the 'elseif' needs to be 'else' instead.

 

 

IsharaMeradin,

 

Thank you for replying! I was able to resolve the error in the previous post, but now have another one :/

 

Here's the updated script:

Scriptname Plarux_FastTravelMenu02 extends ObjectReference  

Message Property PL_FastTravelMenu02  Auto
Message Property PL_LND_Message_Solstheim Auto
ObjectReference Property SolstheimMarker Auto
ObjectReference Property RavenRockMapMarker Auto


Event OnActivate(ObjectReference akActionRef)
	IsLocationDiscovered()
EndEvent

Bool Function IsLocationDiscovered(ObjectReference RavenRockMapMarker)

if (RavenRockMapMarker.IsMapMarkerVisible() == TRUE && RavenRockMapMarker.CanFastTravelToMarker() == TRUE)
    Menu()
else
    PL_LND_Message_Solstheim.show()
endif
EndFunction
Function Menu(int aButton = 0)
	aButton = PL_FastTravelMenu02.show()
	If aButton == 0
		Game.FadeOutGame(False, True, 2.0, 1.0)
		Game.GetPlayer().MoveTo(SolstheimMarker)
		Game.EnableFastTravel()
		Game.FastTravel(SolstheimMarker)
	ElseIf aButton == 1
		
	EndIf
EndFunction

Compile Output:

Starting 1 compile threads for 1 files...
Compiling "Plarux_FastTravelMenu02"...
E:\Program Files\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\Plarux_FastTravelMenu02.psc(10,1): argument ravenrockmapmarker is not specified and has no default value
No output generated for Plarux_FastTravelMenu02, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on Plarux_FastTravelMenu02

The error it is giving is directly related to the line with the Bool Function. When I changed RavenRockMapMarker to something else, it will say argument "something else" is not specified.

Link to comment
Share on other sites

I was able to compile the script successfully.

Thank you both for the help!

Scriptname Plarux_FastTravelMenu02 extends ObjectReference  


Message Property PL_FastTravelMenu02  Auto
Message Property PL_LND_Message_Solstheim Auto
ObjectReference Property SolstheimMarker Auto
ObjectReference Property RavenRockMapMarker Auto




Event OnActivate(ObjectReference akActionRef)


if (RavenRockMapMarker.IsMapMarkerVisible() == TRUE && RavenRockMapMarker.CanFastTravelToMarker() == TRUE)
     Menu()
else
     PL_LND_Message_Solstheim.show()
endif
EndEvent


Function Menu(int aButton = 0)
aButton = PL_FastTravelMenu02.show()
If aButton == 0
Game.FadeOutGame(False, True, 2.0, 1.0)
Game.GetPlayer().MoveTo(SolstheimMarker)
Game.EnableFastTravel()
Game.FastTravel(SolstheimMarker)
ElseIf aButton == 1


EndIf
EndFunction
Edited by Plarux
Link to comment
Share on other sites

Whenever you want to use a function in papyrus scripting there are some things you should understand right now.

(1) Parameter

FUNCTION Test1(Int param1, Float param2, ObjectReference param3)
    ; some code here
ENDFUNCTION

(2) Return value (functions may have this, events never have any return value)

Bool FUNCTION Test1(Int param1, Float param2, ObjectReference param3)
   IF (param1 == 0)
      Return TRUE
   ENDIF

   IF (param2 == 1.0)
      Return TRUE
   ENDIF

   IF (param3 == Game.GetPlayer() as ObjectReference)
      Return TRUE
   ENDIF

  Return False         ; this is the return value in case that every condition before do not match
ENDFUNCTION

You wrote: "trying to create a script that teleports the player (only if they have the location discovered) via activator."

Plarux_FastTravelMenu02

 

Scriptname Plarux_FastTravelMenu02 extends ObjectReference  
; https://forums.nexusmods.com/index.php?/topic/8402498-script-help-fast-travel/

  Message PROPERTY PL_FastTravelMenu02      auto        ; success message for travelling
  Message PROPERTY PL_LND_Message_Solstheim auto        ; error message

  ObjectReference PROPERTY SolstheimMarker    auto      ; a marker placed to Solstheim world
  ObjectReference PROPERTY RavenRockMapMarker auto      ; a map marker


; -- EVENT --

EVENT OnActivate(ObjectReference akActionRef)
    IF IsLocationDiscoveredBy(akActionRef)
        Menu()
    ENDIF
EndEvent


; -- FUNCTIONs -- 2

;----------------------------------------------------------------
Bool FUNCTION IsLocationDiscoveredBy(ObjectReference akActionRef)  ; internal helper
;----------------------------------------------------------------
; https://www.creationkit.com/index.php?title=IsMapMarkerVisible_-_ObjectReference
; https://www.creationkit.com/index.php?title=CanFastTravelToMarker_-_ObjectReference

IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
    Return False    ; not player activated for whatever reason
ENDIF
;---------
IF RavenRockMapMarker.IsMapMarkerVisible() && RavenRockMapMarker.CanFastTravelToMarker()  ; as Ghaunadaur wrote
    Return TRUE        ; map marker is visible and player can fast travel to the marker
ENDIF
;---------
    PL_LND_Message_Solstheim.show()
    Return False    ; map marker is invisible or player cannot fast travel to the markers location
ENDFUNCTION


;--------------
FUNCTION Menu()
;--------------
; https://www.creationkit.com/index.php?title=FadeOutGame_-_Game
; https://www.creationkit.com/index.php?title=EnableFastTravel_-_Game

    int i = PL_FastTravelMenu02.show()            ; get the return value from two choices message
    IF (i == 0)
        Game.EnableFastTravel(False)                ; disable player fast travel immediately
        Game.FadeOutGame(False, TRUE, 2.0, 1.0)     ; "spend 2 sec on a black screen before fading in to the game over 1 sec"
        Game.GetPlayer().MoveTo(SolstheimMarker)    ; move player to Solstheim marker
;;;        Utility.Wait(0.25)                       ; just wait a bit
;;;        Game.EnableFastTravel(TRUE)              ; "Fast travel is reenabled automatically when the player is moved via MoveTo()"
;;;        Game.FastTravel(SolstheimMarker)         ; player is already near the solstheim marker
    ENDIF
ENDFUNCTION

 

 

 

And this is the Skyrim forum, not the Skyrim SE forum !!!

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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