Jump to content

Shotgun shell casings very dark indoors but fine outdoors


Trentosaurus

Recommended Posts

Weird that it told you the error was there, as that simply declares the variable. I did realise an error after looking over it again but not where it said the error was. I pasted it into the GECK and got a different error, which is now fixed when I compile. Hope you can compile it as well.

scn ShellEventHandlerScript

array_var aWeapons
array_var aWeap12Ga
array_var aEntry

ref rWeapon

string_var sShellModel
string_var s12GaModel

Begin MenuMode 4
    If GetGameRestarted
        SetEventHandler "OnCellEnter" ShellUDFScript
;       print "Shell Event Handler Set"
        if aWeap12Ga
        else
            let aWeap12Ga := Ar_Construct "array"
        endif
        let sShellModel := GetWeaponShellCasingModel rWeapon
        let aWeapons := GLTA 40
        ForEach aEntry <- aWeapons
            let rWeapon := aEntry["value"]
            let s12GaModel := "File path to 12Ga shell casing model"
            if sShellModel == s12GaModel
                Ar_Append aWeap12Ga, rWeapon
            endif
        Loop
    EndIf
End

Begin GameMode
    If GetGameLoaded
        If player.IsInInterior
            ForEach aEntry <- aWeap12Ga
                Let rWeapon := aEntry["value"]
                SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
            Loop
        Else
            ForEach aEntry <- aWeap12Ga
                Let rWeapon := aEntry["value"]
                SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
            Loop
        EndIf
    EndIf
End
Edited by EPDGaffney
Link to comment
Share on other sites

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

Yeah, I think the error I was getting before was probably because I forgot to launch Geck with NVSE and instead launched regular Geck powerup.

 

Anyhow the new script compiles just fine. But I'm having trouble updating the other script correctly. This is what I'm getting when I try to save it: https://i.imgur.com/XfVSKPW.png

I know I'm probably doing something horribly wrong.

 

Quick edit: this error pops up after clicking the previous one off, not sure if helpful: https://i.imgur.com/0IYArTl.png

Edited by Trentosaurus
Link to comment
Share on other sites

You need to copy the entire If statement straight into the other script, like so:

scn ShellUDFScript

ref	 rEnteredCell

BEGIN Function {rEnteredCell}
    If player.IsInInterior
        ForEach aEntry <- aWeap12Ga
            Let rWeapon := aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    Else
        ForEach aEntry <- aWeap12Ga
            Let rWeapon := aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    EndIf
END

And then you need to add not the name of your script but your Quest ID (and that's ID, not name) before every single variable. I think that's just aEntry, aWeap12Ga, and rWeapon in this case, becoming:

YourQuestID.aEntry

YourQuestID.aWeap12Ga

YourQuestID.rWeapon

 

Every time they turn up in my script here.

Link to comment
Share on other sites

All sorted. Had a feeling it was this but didn't know how to explain it quickly (and I, as you may have noticed is not uncommon, was in a rush). It couldn't grab the reference variable from the quest in that situation. Some functions are like that, and I see it mostly in Function blocks. Not sure that's because it happens more with them, as it could just be I do a lot of work with them.

 

So, for your future reference, I didn't need to do this here, but declaring a ref variable as part of the UDF script then letting it to the variable you were initially going to use would solve this problem, like so:

scn ShellUDFScript

ref  rEnteredCell
ref  rWeapon

BEGIN Function {rEnteredCell}
    Let rWeapon := ShellQuest.rWeapon
    If player.IsInInterior
        ForEach ShellQuest.aEntry <- ShellQuest.aWeap12Ga
            Let rWeapon := ShellQuest.aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    Else
        ForEach ShellQuest.aEntry <- ShellQuest.aWeap12Ga
            Let rWeapon := ShellQuest.aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    EndIf
END

However, in this case it's completely superfluous, as we change the value in the next line anyway, so here's the way the script should actually look (the first line of code within the Function block is now gone):

scn ShellUDFScript

ref  rEnteredCell
ref  rWeapon

BEGIN Function {rEnteredCell}
    If player.IsInInterior
        ForEach ShellQuest.aEntry <- ShellQuest.aWeap12Ga
            Let rWeapon := ShellQuest.aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    Else
        ForEach ShellQuest.aEntry <- ShellQuest.aWeap12Ga
            Let rWeapon := ShellQuest.aEntry["value"]
            SetWeaponShellCasingModel rWeapon "File Path to Interior Shell Version"
        Loop
    EndIf
END
Edited by EPDGaffney
Link to comment
Share on other sites

Decided to actually move this project to it's own esp plugin, so that everything is a bit neater. Was about to comment back with a slightly different error on line 7 again.

But now with this new script I'm getting an error on line 8, saying unknown variable 'aEntry', even though it's in the other script and compiled. https://i.imgur.com/3KNy28R.png

 

Do we still need to add the quest ID before rWeapon as well? Because if so, it doesn't make a difference with this error.

Link to comment
Share on other sites

The script compiled for me, so something must be mismatched in the interaction. Did you forget to attach the script to the quest perhaps? Is that definitely the right quest ID?

 

Also, I notice you're saving this UDF script as a Quest script. Needs to be Object.

 

Do we still need to add the quest ID before rWeapon as well? Because if so, it doesn't make a difference with this error.

That's the thing I made it so that we no longer need to do, because we're now declaring that variable in the script that's using it. I think the dot confuses the compiler and that it thinks we're trying to use a reference ID rather than a base ID (both base forms and reference forms can be stored in a ref variable, which can get confusing). So, by declaring the variable in this very script, we no longer need to use a dot. And it should process slightly faster.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...