Author Topic: Scripts  (Read 5066 times)

  • Administrator
  • Sr. Member
  • *****
  • Posts: 407
    • View Profile
Re: Scripts
« Reply #45 on: October 16, 2021, 08:58:04 am »
I guess that the code you have pasted is in the loader file in main timeline frame script. That is the only way it landed at _root level and the only way to make it right.

Then NEVER reference the data by creating new SharedObject in Northernfalls or any other file by caling
var so = SharedObject.getLocal("HighTailHall2");
That way you have you have multiple objects conflicting over one save file data. It's like opening one file with multiple editors at the same time. Except these editors always writes file on editor close, each holding different data sets overwriting each other.
The only way to reference these data in level files is by calling the loader function by _root.saveData(); after modifying a root variable you want to save.

BTW, that line  so.data.voyeurlevel = Number(so.data.hall1) + Number(so.data.hall2) + Number(so.data.vlnf); will end up by NaN (Not a Number) stored in so.data.voyeurlevel because so.data.vlnf is not created yet. It's likely just a variable name typo.

Also so.data.voyeurlevel is not assigned in your _root.saveData() function. The game scripts should use _root.voyeurlevel variable instead and there should be something like following included in saveData() function.
so.data.voyeurlevel = 0;
if (_root.voyeurlevel != NaN)
{
so.data.voyeurlevel = _root.voyeurlevel;
}