die hard script error - advice needed

Post » Thu May 19, 2016 11:31 pm

WHY does this...



Function ResetSuiteUsers ()
While Busy
Wait ( 0.1 )
endWhile

Busy = true
Counter = SuiteUsersLocal.Length
CounterAux = -1

Actor SuiteUserTemp = None

While ( Counter > 0 )
Counter -= 1

SuiteUserTemp = SuiteUsersLocal [ Counter ]

if ( SuiteUserTemp && ( ( SuiteUserTemp as Actor ) && !SuiteUserTemp.IsDead () ) )
ResetSuiteUser ( SuiteUserTemp )


...give me this...


[05/17/2016 - 03:38:16AM] error: Mismatched types assigning to variable named "::SuiteUsersLocal_var"

stack:

[ (1D0C4444)].s7osos01actisuitemasterscript.ResetSuiteUsers() - "s7oSOS01actiSuiteMasterSCRIPT.psc" Line 453

[ (1D0C4444)].s7osos01actisuitemasterscript.InitSelf() - "s7oSOS01actiSuiteMasterSCRIPT.psc" Line 176

[ (1D0C4444)].s7osos01actisuitemasterscript.OnCellLoad() - "s7oSOS01actiSuiteMasterSCRIPT.psc" Line 73



(where 453 is the ResetSuiteUser line in this case)


i just don't get it.


SuiteUsersLocal [] is an actor array, and reliably holds either an actor or a none


(where my assumption is that hopefully ANY of the stuff in my if... line will prevent that part from running if it's none)



the ResetSuiteFunction does require an actor of course, but it totally doesn't matter whatever i do to SuiteUserTemp, adding them to factions, giving them items etc, it all gives the same error.


where oddly, when i run more functions in a row on SuiteUserTemp (like add to 2 factions, give 1 item), always only ONE of them will spawn an error


i also tried a hidden property for SuiteUserTemp, no difference



and even more odd, i have no indication that what the ResetSuiteUser function is supposed to do hasn't been properly done, everything appears to be in order.



hope anybody can give me a hint, i just don't know what to try anymore with the thing

User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Thu May 19, 2016 7:33 pm

Post the code for your ResetSuiteUser function, please. (You've posted ResetSuiteUsers.)
User avatar
Kate Murrell
 
Posts: 3537
Joined: Mon Oct 16, 2006 4:02 am

Post » Thu May 19, 2016 2:44 pm

no problem, there you go:


Function ResetSuiteUser ( Actor ResetMe )
ResetMe. SetFactionRank ( SuiteFactionLocal, 1 )
ResetMe. SetFactionRank ( SuiteGuests, 1 )

Int SuiteKeyCount = ResetMe.GetItemCount ( SuiteKeyLocal )

if ( SuiteKeyCount <= 0 )
ResetMe. AddItem ( SuiteKeyLocal, 1 )

else
ResetMe. RemoveItem ( SuiteKeyLocal, ( SuiteKeyCount - 1 ) )
endif
endFunction


before i put that stuff into an own function (had hoped for the function fairy to perform a miracle, but she refused :-),


where it bugged out was either the second setfaction line (never the 1st one though, for some reason) or the key adding (but never the getting the item count)


and it wasn't necessarily the first one of them to bug out, at times, the first one passed and the second one spawned an error.

User avatar
Niisha
 
Posts: 3393
Joined: Fri Sep 15, 2006 2:54 am

Post » Thu May 19, 2016 5:14 pm

The variable that the error refers to isn't even used in that function, and now that I'm paying closer attention, I see the call stack doesn't list it either.



Could you post the full code for ResetSuiteUsers? The whole function?

User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Thu May 19, 2016 9:15 pm

it is. like in this.


the part that i just don't see is what i'm "assigning", i'm not assigning anything, i copied the value into another variable xx lines earlier and didn't touch the original array since then (at the point the error occurs). that part might be kind of a semantic misunderstanding though :-)



SuiteUserTemp = SuiteUsersLocal [ Counter ]


sure. there just isn't much more after that :-)



Function ResetSuiteUsers ()
While Busy
Wait ( 0.1 )
endWhile

Busy = true
Counter = SuiteUsersLocal.Length
CounterAux = -1

Actor SuiteUserTemp = None

While ( Counter > 0 )
Counter -= 1

SuiteUserTemp = SuiteUsersLocal [ Counter ]

if ( SuiteUserTemp && ( ( SuiteUserTemp as Actor ) && !SuiteUserTemp.IsDead () ) )
ResetSuiteUser ( SuiteUserTemp )

if ( Innkeeper && ( SuiteUserTemp == Innkeeper ) )
CounterAux = Counter
endif

elseif ( CounterAux == -1 )
CounterAux = Counter
endif

SuiteUserTemp = None
endWhile

if ( Innkeeper && ( ( CounterAux > -1 ) && ( CounterAux < SuiteUsersLocal.Length ) ) )
SuiteUsersLocal [ CounterAux ] = Innkeeper
endif

Busy = false
endFunction

edit: for a little explanation what that does maybe: check through an array (different size arrays on different refs) of actors, see if they're all existing, alive and set up, or otherwise clean them out and replace them with (preferredly) the "innkeeper" actor, if he/she's not in that array already (it also had an option to pass a new actor with it in an earlier version, took that out for now to reduce potential error sources)

User avatar
Milagros Osorio
 
Posts: 3426
Joined: Fri Aug 25, 2006 4:33 pm

Post » Thu May 19, 2016 1:58 pm

I was expecting to see a typo like forgetting the array subscript when assigning, but I don't -- the syntax looks correct there.


Can I see the variable declarations for SuiteUsersLocal and Innkeeper? I want to make sure they're exactly the same type; even if one can be cast to the other, you'll still get errors if you don't actually do that cast.
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Thu May 19, 2016 2:39 pm

yeah, compiles fine and all, too.




sure. here's the whole script, to put an end to the function-by-function delivery :-)


(xcuse my lack of documentation, most of it will be unintelligible gibberish to anybody, but usually, nobody ever reads my scripts :-)



Spoiler
Scriptname s7oSOS01actiSuiteMasterSCRIPT extends ObjectReference      Conditional



import Debug
import Utility



; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - P R O P E R T I E S - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Actor [] Property SuiteUsersLocal Auto

Actor Property PlayerRef Auto
Actor Property Innkeeper Auto
Faction Property SuiteFactionLocal Auto
Faction Property SuiteGuests Auto

Key Property SuiteKeyLocal Auto
MiscObject Property Gold Auto

Quest Property AUXinnkeeperFinder Auto
Keyword Property WIRentRoomWalkToStart Auto

s7oSOS01questSuitesMasterSCRIPT Property SOS01masterSCRIPT Auto
QF_s7oSOS01questAux00innkeeperFinder Property AuxInnkeeperFinderSCRIPT Auto

ObjectReference Property SelfRef Auto Hidden
ObjectReference Property SuiteService Auto Hidden
ObjectReference Property DoorMaster Auto Hidden ;;;;; linked from suite master
ObjectReference Property SuiteSpot Auto Hidden ;;;;; linked from door master

Location Property SuiteLocation Auto Hidden

Bool Property Rented Auto Hidden Conditional
Bool Property RentOverdueLocked Auto Hidden Conditional

Bool Property BusyFinder = false Auto Hidden
Bool Property Busy = false Auto Hidden

Bool Property RentDue = false Auto Hidden
Bool Property RentOverdue = false Auto Hidden
Bool Property RentWarning = false Auto Hidden

Bool Property Update20 Auto Hidden

Float Property RentTime Auto Hidden

Int Property SuiteRentDue Auto Hidden

Int Property SuiteRentLocal = 300 Auto

Bool Property NoRentRoom = false Auto

Int Counter = 0
Int CounterAux = 0

Bool SelfInit



; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - E V E N T S - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Event OnCellLoad ()
if ( InitSelf () && InitInnkeeper ( None ) )
WelcomeHome ()
endif
endEvent



Event OnCellDetach ()
if BusyFinder
if AuxInnkeeperFinder.IsRunning ()
AuxInnkeeperFinder. Stop ()
AuxInnkeeperFinder. Reset ()
endif

BusyFinder = false
endif
endEvent



Event OnUpdateGameTime () ;;;;; check if rent due, if not repeat next day
UnregisterForUpdateGameTime ()

if ProcessSuiteRentDue ()
if !RentDue
RegisterForSingleUpdateGameTime ( 24 )
endif
endif
endEvent



; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - F U N C T I O N S - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Function WelcomeHome () ;;;;; will also be called by suite scout (if present)
While Busy
Wait ( 0.1 )
endWhile

if CheckDue ()
Busy = true

if RentDue
SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentDue )

if RentWarning
if Rented
if RentOverdueLocked
Notification ( "Rent overdue - Suite locked." )

elseif RentOverdue
Notification ( "Your rent is overdue." )

elseif RentDue
Notification ( "Your rent is due." )
endif

else
Notification ( "You owe the Innkeeper " + SuiteRentDue + " gold." )
endif

RentWarning = false
endif

else
if Rented
SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentDue )

else
SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentLocal )
endif
endif

SOS01masterSCRIPT. UpdateSuiteDataLocal ( SelfRef, Innkeeper, true, Rented, RentDue, RentOverdue, RentOverdueLocked )
CheckInnkeeperNoRentRoom ()

Busy = false
endif
endFunction



Bool Function InitSelf ()
if !SelfInit
SelfInit = true

CheckUpdate20 ()

SelfRef = ( Self as ObjectReference )
SetFactionOwner ( SuiteFactionLocal )

SuiteLocation = ( GetCurrentLocation () as Location )
DoorMaster = ( GetNthLinkedRef ( 1 ) as ObjectReference )
SuiteSpot = ( GetNthLinkedRef ( 2 ) as ObjectReference )

if ( !Innkeeper || Innkeeper.IsDead () )
InitInnkeeper ( None )

else
ResetSuiteUsers ()
endif
endif

Return SelfInit
endFunction



Bool Function InitInnkeeper ( Actor ThisInnkeeper = None )
While BusyFinder
Wait ( 0.1 )
endWhile

if ( !ThisInnkeeper && ( Innkeeper && !Innkeeper.IsDead () ) )
CheckInnkeeperNoRentRoom ()

Return true

else
if ThisInnkeeper
Innkeeper = ThisInnkeeper
ThisInnkeeper = None

else
BusyFinder = true
Innkeeper = None

AuxInnkeeperFinder. Stop ()
AuxInnkeeperFinder. Reset ()
AuxInnkeeperFinder. Start ()

AuxInnkeeperFinderSCRIPT. SuiteMasterLocal = SelfRef

While BusyFinder ;;;;; waits for finder quest to finish
Wait ( 0.1 )
endWhile
endif

if Innkeeper
Innkeeper. SetFactionRank ( SuiteFactionLocal, 1 )
Innkeeper. SetFactionRank ( SuiteGuests, 1 )

if ( SuiteKeyLocal && ( Innkeeper.GetItemCount ( SuiteKeyLocal ) <= 0 ) )
Innkeeper. AddItem ( SuiteKeyLocal, 1 )
endif

CheckInnkeeperNoRentRoom ()
ResetSuiteUsers ()

Return true

else
Return false
endif
endif
endFunction



Function CheckInnkeeperNoRentRoom ()
if ( ( NoRentRoom && Innkeeper ) && ( Innkeeper.GetActorValue ( "Variable09" ) == 0 ) )
Innkeeper.SetActorValue ( "Variable09", -1 ) ;;;;; "variable 09" -1 prevents "rent room" dialogue for non-vanilla innkeepers
endif
endFunction



Function RentSuite ()
While Busy
Wait ( 0.1 )
endWhile

Busy = true

if ( RentTime == 0 )
WIRentRoomWalkToStart. SendStoryEvent ( SuiteLocation, Innkeeper, SuiteSpot )
endif

RentTime = GetCurrentGameTime ()
Rented = true
RegisterForSingleUpdateGameTime ( 8736 )

if ( PlayerRef.GetItemCount ( SuiteKeyLocal ) <= 0 )
PlayerRef. AddItem ( SuiteKeyLocal, 1, false )
endif

PlayerRef. AddToFaction ( SuiteFactionLocal )
PlayerRef. SetFactionRank ( SuiteFactionLocal, 2 )
PlayerRef. RemoveItem ( Gold, SuiteRentLocal, false, Innkeeper )

SOS01masterSCRIPT. FlashObjective ( 10 )
SOS01masterSCRIPT. UpdateSuiteDataLocal ( SelfRef, Innkeeper, true, Rented, RentDue, RentOverdue, RentOverdueLocked )
SOS01masterSCRIPT. UpdateRentGlobal ( 0 )

Doormaster. EnableNoWait ( false )
SuiteService. BlockActivation ( false )
Innkeeper. SetActorValue ( "Variable09", 2.0 )

Busy = false
endFunction



Function UnrentSuite ()
While Busy
Wait ( 0.1 )
endWhile

Busy = true

Rented = false

if ProcessSuiteRentDue ()
SuiteRentDue -= SuiteRentLocal

if ( SuiteRentDue <= 0 )
if ( SuiteRentDue < 0 )
PlayerRef. AddItem ( Gold, -SuiteRentDue, false )
SuiteRentDue = 0
endif

SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentLocal )
UnlockSuite ()

else
SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentDue )
endif
endif

PlayerRef. RemoveItem ( SuiteKeyLocal, PlayerRef.GetItemCount ( SuiteKeyLocal ), false )

SOS01masterSCRIPT. FlashObjective ( 9 )
SOS01masterSCRIPT. UpdateSuiteDataLocal ( SelfRef, Innkeeper, true, Rented, RentDue, RentOverdue, RentOverdueLocked )
ResetSuite ()

Busy = false
endFunction



Function PayRent ()
if Rented
UnregisterForUpdateGameTime ()

if ProcessSuiteRentDue ()
RentTime = GetCurrentGameTime ()
SOS01masterSCRIPT. UpdateRentGlobal ( 0 )
RegisterForSingleUpdateGameTime ( 8736 )
endif

else
SOS01masterSCRIPT. UpdateRentGlobal ( SuiteRentLocal )
endif

UnlockSuite ()
SOS01masterSCRIPT. UpdateSuiteDataLocal ( SelfRef, Innkeeper, true, Rented, RentDue, RentOverdue, RentOverdueLocked )
PlayerRef. RemoveItem ( Gold, SuiteRentDue, false, Innkeeper )
endFunction



Bool Function ProcessSuiteRentDue ()
if ( RentTime > 0 )
SuiteRentDue = ( ( ( SuiteRentLocal / 364 ) * ( GetCurrentGameTime () - RentTime ) as Int ) )

if ( SuiteRentDue >= SuiteRentLocal )
RentDue = true
endif
endif

Return true
endFunction



Bool Function CheckDue ()
if Rented
ProcessSuiteRentDue ()
endif

if ( !RentDue && ( SuiteRentDue > SuiteRentLocal ) )
RentDue = true
RentWarning = true

elseif RentDue
if ( !RentOverdue && ( SuiteRentDue > ( SuiteRentLocal * 1.5 ) ) )
RentOverdue = true
RentWarning = true

elseif RentOverdue
if ( !RentOverdueLocked && ( SuiteRentDue > ( SuiteRentLocal * 2 ) ) )
RentoverdueLocked = true
RentWarning = true
LockSuite ()

elseif RentOverdueLocked
RentWarning = true
endif
endif
endif

Return true
endFunction



Function CheckStuffOut ()
if RentOverdueLocked
DoorMaster. DisableNoWait ()
PlayerRef. SetFactionRank ( SuiteFactionLocal, -1 )
endif
endFunction



Function StuffOut ()
PlayerRef. SetFactionRank ( SuiteFactionLocal, 2 )
DoorMaster. EnableNoWait ()
endFunction



Function UnlockSuite ()
if Rented
PlayerRef. SetFactionRank ( SuiteFactionLocal, 2 )

else
PlayerRef. RemoveFromFaction ( SuiteFactionLocal )
ResetSuite ()
endif

SuiteService. BlockActivation ( false )
DoorMaster. EnableNoWait ()

RentDue = false
RentOverdue = false
RentOverdueLocked = false
RentWarning = false
SuiteRentDue = 0
endFunction



Function LockSuite ()
PlayerRef. SetFactionRank ( SuiteFactionLocal, -1 )
SuiteService. BlockActivation ( true )
DoorMaster. DisableNoWait ()
endFunction



Function ResetSuite ()
Innkeeper. SetActorValue ( "Variable09", ( 0 - ( NoRentRoom as Float ) ) ) ;;;;; "variable 09" -1 prevents "rent room" dialogue for non-vanilla innkeepers
RentTime = 0.0
ResetSuiteUsers ()
endFunction



Function ResetSuiteUsers ()
While Busy
Wait ( 0.1 )
endWhile

Busy = true
Counter = SuiteUsersLocal.Length
CounterAux = -1

Actor SuiteUserTemp = None

While ( Counter > 0 )
Counter -= 1

SuiteUserTemp = SuiteUsersLocal [ Counter ]

if ( SuiteUserTemp && ( ( SuiteUserTemp as Actor ) && !SuiteUserTemp.IsDead () ) )
ResetSuiteUser ( SuiteUserTemp )

if ( Innkeeper && ( SuiteUserTemp == Innkeeper ) )
CounterAux = Counter
endif

elseif ( CounterAux == -1 )
CounterAux = Counter
endif

SuiteUserTemp = None
endWhile

if ( Innkeeper && ( ( CounterAux > -1 ) && ( CounterAux < SuiteUsersLocal.Length ) ) )
SuiteUsersLocal [ CounterAux ] = Innkeeper
endif

Busy = false
endFunction



Function ResetSuiteUser ( Actor ResetMe )
ResetMe. SetFactionRank ( SuiteFactionLocal, 1 )
ResetMe. SetFactionRank ( SuiteGuests, 1 )

Int SuiteKeyCount = ResetMe.GetItemCount ( SuiteKeyLocal )

if ( SuiteKeyCount <= 0 )
ResetMe. AddItem ( SuiteKeyLocal, 1 )

else
ResetMe. RemoveItem ( SuiteKeyLocal, ( SuiteKeyCount - 1 ) )
endif
endFunction



Function CheckUpdate20 ()
if !Update20
While Busy
Wait ( 0.1 )
endWhile

Busy = true

if PlayerRef.IsInFaction ( SuiteFactionLocal )
Rented = true
endif

if ( Innkeeper && ( Innkeeper.GetActorValue ( "Variable09" ) > 2 ) )
Innkeeper. SetActorValue ( "Variable09", ( 2 * ( Rented as Float ) ) )
endif

Update20 = true
Busy = false
endif
endFunction

User avatar
Antonio Gigliotta
 
Posts: 3439
Joined: Fri Jul 06, 2007 1:39 pm

Post » Thu May 19, 2016 12:25 pm

Well, I don't see any syntax errors that could explain the error you're seeing, so this is the part where I resort to blind guessing:



Your indentation and spacing is bizarre. Maybe it's tripping up the compiler somehow? You declare SuiteUsersLocal on line 16 and assign to it on line 467; please strip all unnecessary spaces out of those lines, recompile, and see if you still get errors.

User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am


Return to V - Skyrim