decker666

Member
Sep 29, 2017
213
495
Thank for real life but is this include in game?
In fact I was a little bit too quick to answer (I had proposed the change a while back).

v0.26 : X=55
v0.27 : X=49

0% : chance over or equal to X
100% : chance under X, with breeder trait
50% : chance under X, if mc takes fertility potion
10% : chance under X

This may change in the future :D
 
Last edited:
  • Like
Reactions: GamerDaddy

lp456

Newbie
May 24, 2018
93
17
In fact I was a little bit too quick to answer (I had proposed the change a while back).

v0.26 : X=55
v0.27 : X=49

0% : chance over or equal to X
100% : chance under X, with breeder trait
50% : chance under X, if mc takes fertility potion
10% : chance under X

This may change in the future :D
Okay wish it increase to 60 instead in mature
 

kuhaaku98

Newbie
Jan 12, 2019
57
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
353
292
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,472
1,717
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,472
1,717
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
353
292
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
3.60 star(s) 42 Votes