Jump to content

Papyrus Help: Script Won't Compile


Recommended Posts

Me again, your local modding noob hoping someone can help.

 

I'm still getting the hang of papyrus scripting, and tried to mimic a script I found elsewhere to create a lantern that changes colours. The original script swaps out the model of a light and adds/deletes a light source, allowing you to turn a light on or off. I followed the syntax of the original script throughout, but changed it so that it checks which lantern is active and cycles between them, deleting the old light and adding a new one.

Here's what it does / should do:

  • Checks which lantern is active by looking at the "ActiveLantern" property (defined on the object)
  • Enables the next lantern
  • Waits 0.5 seconds (the only float that's working.)
  • Disables the original lantern
  • Finds the closest light source based on a formlist ("LightList") and deletes it.
  • Creates a new light that matches the latern colour.

The error I'm getting when compiling is that it can't create two of the three initial floats I'm using:

 

D:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\_SHSCRLanternPuzzle.psc(3,15): cannot initialize a float to 1

D:\Games\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\_SHSCRLanternPuzzle.psc(5,15): cannot initialize a float to 64

 

I've attached my .psc file as text I've edited this post to add a spoiler window so you can see my full code. I'm a little baffled because I initialize three floats the exact same way, but only two of them fail.

Scriptname _SHSCRLanternPuzzle extends ObjectReference

Float Property ActiveLantern = 1 Auto
Float Property WaitTimer = 0.5 Auto
Float Property SearchRadius = 64 Auto

ObjectReference Property Light1 Auto
ObjectReference Property Light2 Auto
ObjectReference Property Light3 Auto
ObjectReference Property Light4 Auto
ObjectReference Property Light5 Auto
ObjectReference Property Light6 Auto
ObjectReference Property LightLocation Auto
ObjectReference Property PlayerREF Auto

FormList Property LightList Auto

Light Property LightType Auto

Sound Property LightChange Auto


Event OnInit()

GoToState("InActive")

EndEvent

State InActive

Event OnActivate(ObjectReference akActionRef)

GoToState("Active")

If ActiveLantern == 1

LightChange.Play(PlayerREF)
Light2.enable()
Utility.Wait(WaitTimer)
Light1.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

ElseIf ActiveLantern == 2

LightChange.Play(PlayerREF)
Light3.enable()
Utility.Wait(WaitTimer)
Light2.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

ElseIf ActiveLantern == 3

LightChange.Play(PlayerREF)
Light4.enable()
Utility.Wait(WaitTimer)
Light3.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

ElseIf ActiveLantern == 4

LightChange.Play(PlayerREF)
Light5.enable()
Utility.Wait(WaitTimer)
Light4.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

ElseIf ActiveLantern == 5

LightChange.Play(PlayerREF)
Light6.enable()
Utility.Wait(WaitTimer)
Light5.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

Else

LightChange.Play(PlayerREF)
Light1.enable()
Utility.Wait(WaitTimer)
Light6.disable()
Game.FindClosestReferenceOfAnyTypeInListFromRef(LightList, LightLocation, SearchRadius).delete()
LightLocation.PlaceAtMe(LightType)

EndIf

GoToState("InActive")

EndEvent

EndState



In terms of what I've tried:

  • I've searched the forums here, as well as Google, for instances of "cannot initialize a float to" - did find one reference on LoversLab, but no solution listed.
  • I've confirmed that Float can use both of those numbers on the Creation Kit wiki.
  • Tried swapping the failing "Float" to "Int", but that fails as well.
  • Added decimals to the numbers, but that doesn't seem to make a difference.
  • Downloaded SSEScript, and ran "Tools > Check for Errors" which tells me there are no errors, but also fails to compile the script.

Any advice would be appreciated. I'm probably lacking some basic understanding, but so far no dice on determining what that might be.

 

Thanks!

Link to comment
Share on other sites

For the floats, you have to put a period to initialize. So change to 1.0 and 64.0

 

Edit: and this is because 1 or 64 is viewed by papyrus as an int, so you're trying to initialize float properties to ints and papyrus doesn't like that.

Link to comment
Share on other sites

Update: It was the decimals in spite of the fact that, as mentioned above, I had already tried adding them to no effect.
This appears to have been because Creation Kit was caching a separate version of the script. It kept trying to compile that version instead of the one I was editing (/source/scripts instead of /scripts/source, both of which exist for... some reason.)

Thanks Dylbill

Link to comment
Share on other sites

The Creation Kit for SSE use "Data > Source > Scripts" by default instead of "Data > Scripts > Source" as LE did. Whether this is a bug or intentional is up for debate. However, it is what it is. If you wish to use "Data > Scripts > Source" you'll need to make sure all your source scripts are located there and modify the correct INI file to point to that folder location.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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