kuhaaku98

Newbie
Jan 12, 2019
60
10
Anyone else had the error in the current save?
"Cannot read properties of undefined (reading 'id')." This error appeared in my save that I have been using since the beginning of the game
 
  • Like
Reactions: ttyrke

guest1492

Member
Apr 28, 2018
366
307
I ran into an issue when playing v0.26c on mopoga. Sometimes when I go back to the cabin, the game freezes and I have to kill the page. This is how it looks like when it happens:

1701014535239.png

At first I assumed that this is a problem from getting redirected to 'Event: Common capital' which I had never seen before, but I was able to get that event to show properly after numerous refreshes. I'm not sure what exactly is the problem.

I have tried using SugarCube.Engine.play('Event: Common capital') in the browser console and that does cause the game to freeze. Also I looked at the code of the event and there seems to be an issue with this:
Code:
<<set _randomPersons = setup.getRandomPersons(_persons, 2)>>
<<set 
    _randomPerson1Id = _randomPersons[0],
    _randomPerson2Id = _randomPersons[1]
>>
...
$guests[_randomPerson1Id].name
setup.getRandomPersons returns an array of objects, which means _randomPerson1Id is an object, so $guests[_randomPerson1Id].name shouldn't really work, but the problem is that I can sometimes get the event to fire and it works properly.

I'm confused o_O. I've attached my save but I don't think that it'll be any help at all.
 
  • Like
Reactions: ttyrke

ttyrke

Well-Known Member
Game Developer
Jun 10, 2017
1,534
1,828
Anyone else had the error in the current save?
"Cannot read properties of undefined (reading 'id')." This error appeared in my save that I have been using since the beginning of the game
Add your save file
 

ttyrke

Well-Known Member
Game Developer
Jun 10, 2017
1,534
1,828
I ran into an issue when playing v0.26c on mopoga. Sometimes when I go back to the cabin, the game freezes and I have to kill the page. This is how it looks like when it happens:

View attachment 3119719

At first I assumed that this is a problem from getting redirected to 'Event: Common capital' which I had never seen before, but I was able to get that event to show properly after numerous refreshes. I'm not sure what exactly is the problem.

I have tried using SugarCube.Engine.play('Event: Common capital') in the browser console and that does cause the game to freeze. Also I looked at the code of the event and there seems to be an issue with this:
Code:
<<set _randomPersons = setup.getRandomPersons(_persons, 2)>>
<<set
    _randomPerson1Id = _randomPersons[0],
    _randomPerson2Id = _randomPersons[1]
>>
...
$guests[_randomPerson1Id].name
setup.getRandomPersons returns an array of objects, which means _randomPerson1Id is an object, s $guests[_randomPerson1Id].name shouldn't really work, but the problem is that I can sometimes get the event to fire and it works properly.

I'm confused o_O. I've attached my save but I don't think that it'll be any help at all.
Thx. Sounds like an infinity loop. Will check it out
 
  • Like
Reactions: guest1492

guest1492

Member
Apr 28, 2018
366
307
Thx. Sounds like an infinity loop. Will check it out
I realized that _persons in the code I quoted is actually an array of integers and not objects, so my point about your code is invalid and that's not the reason for the game freezing.

EDIT 1
After yet another look, I believe that the problem is with this part of the code:
JavaScript:
setup.getRandomPersonIds = function(persons, limit = 2) {
    var randomIds = [];
    var randomPersonList = clone(persons);
    while (randomIds.length < limit && randomPersonList.length) {
        var randomIndex = Math.floor(Math.random() * randomPersonList.length);
        if (!randomIds.includes(randomIndex)) {
            randomIds.push(randomIndex);
            randomPersonList.splice(randomIndex, 1);
        }
    }

    return randomIds;
};
Using something like SugarCube.setup.getRandomPersonIds([3, 5], 2) can cause an infinite loop. In the code, randomIndex is an integer that's either 0 or 1 (since persons is a 2 element array here). So randomIds is going to be filled with either 0 or 1 (which is not what you want, since you actually want it to be 3 or 5 in this example, but that's a separate issue).

The infinite loop happens if the first time through the loop, randomIndex is 0. Now randomPersonList has a length of 1 and so afterwards, randomIndex will always be 0 and thus doesn't get pushed into randomIds. So randomIds stays with length 1 and the loop repeats.

Side note, but SugarCube's creator added many custom methods to the Array class, so that whole function could be written like so:
JavaScript:
setup.getRandomPersonIds = function(persons, limit = 2) {
    return [].concatUnique(persons).randomMany(limit);
}

EDIT 2
Changing that function seems to have fixed the problem for me.
 
Last edited:
  • Like
Reactions: red1n

decker666

Member
Sep 29, 2017
228
551
Hello,
Here is my mega action pack for v0.27 (2.8 GB).



It includes new pictures :
- for the new 'workout' location for fuck scenes.
- new 'handjob', 'handjob cum' and 'anal fingering' actions.
- tons of lesbian actions (0.5 GB) for the lesbian event.

Help to get the lesbian repeatable event :
- have minimum 2 women guests that like women (lesbian, bisexual, pansexual).
- go in the guest house when they are not working

If that is met, the event has a 30% chance to start, I will change that one day to base it on the guest horny stat.
Note that the event has 6 different steps, and 5 levels of intensity, based in the lowest corruption stat between the girls participating.

CU
 
Last edited:

ttyrke

Well-Known Member
Game Developer
Jun 10, 2017
1,534
1,828
Anyone else had the error in the current save?
"Cannot read properties of undefined (reading 'id')." This error appeared in my save that I have been using since the beginning of the game
Check . There's 0.27a-beta patch out. Should be fixed there. As for official patch - will be probably out after 2-3 hours.
 
3.70 star(s) 52 Votes