Closed inxomnyaa closed 7 years ago
Notice: Undefined index: generation.level4.manager in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142
I see... will fix this this evening.
i have no idea where this comes from ^^
Offtoppic: can you explain me yield/generators? For example, i don't understand why yield is needed here, for me it looks like its not even necessary..
<?php
function fib($n)
{
$cur = 1;
$prev = 0;
for ($i = 0; $i < $n; $i++) {
yield $cur;
$temp = $cur;
$cur = $prev + $cur;
$prev = $temp;
}
}
$fibs = fib(9);
foreach ($fibs as $fib) {
echo " " . $fib;
}
This here is just the same:
<?php
function fib($n)
{
$res = [];
$cur = 1;
$prev = 0;
for ($i = 0; $i < $n; $i++) {
$res[] = $cur;
$temp = $cur;
$cur = $prev + $cur;
$prev = $temp;
}
return $res;
}
$fibs = fib(9);
foreach ($fibs as $fib) {
echo " " . $fib;
}
Oh actually i see now. it simply doesn't save an array to memory
@thebigsmileXD There is an another difference, yield pauses the function execution and execute the code on the foreach (where you can send values back using the $gen->send() function).
Your code should look like this:
<?php
function fib($n) {
$cur = 1;
for ($i = 0; $i < $n; $i++) {
echo " " . $cur;
$cur += yield $cur;
}
}
$prev = 0;
foreach ($gen = fib(9) as $fib) {
echo " Foreach:" . $fib;
$gen->send($fib);
$prev = $fib;
}
This would output:
1 Foreach:1 2 2 Foreach:2 4 4 Foreach:4 8 8 Foreach:8 16 16 Foreach:16
Uhh. What branch are you runing?
Not sure, i guess.. master?
Well on master, BetterNormal::$options is public. Try updating it maybe?
Do anyone still get this bug or I can close it? I cannot reproduce it.
👍
Notice: Undefined index: generation.level4.generator in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142 [20:16:46] [Asynchronous Worker #2 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 [20:16:46] [Asynchronous Worker #1 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #0 /BetterGen/src/Ad5001/BetterGen/generator/BetterNormal(148): Ad5001\BetterGen\biome\BetterDesert->construct(boolean) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #0 /BetterGen/src/Ad5001/BetterGen/generator/BetterNormal(148): Ad5001\BetterGen\biome\BetterDesert->construct(boolean) [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #1 /src/pocketmine/level/generator/GeneratorRegisterTask(53): Ad5001\BetterGen\generator\BetterNormal->init(pocketmine\level\SimpleChunkManager object, pocketmine\utils\Random object) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #1 /src/pocketmine/level/generator/GeneratorRegisterTask(53): Ad5001\BetterGen\generator\BetterNormal->init(pocketmine\level\SimpleChunkManager object, pocketmine\utils\Random object) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #2 /src/pocketmine/scheduler/AsyncTask(80): pocketmine\level\generator\GeneratorRegisterTask->onRun(boolean) [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #2 /src/pocketmine/scheduler/AsyncTask(80): pocketmine\level\generator\GeneratorRegisterTask->onRun(boolean)
Notice: Undefined index: generation.level4.generator in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142 [20:16:46] [Server thread/CRITICAL]: Could not execute asynchronous task GeneratorRegisterTask: Task crashed [20:16:46] [Server thread/CRITICAL]: Could not execute asynchronous task GeneratorRegisterTask: Task crashed zend_mm_heap corrupted [20:16:46] [Asynchronous Worker #2 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 bin\php\php.exe: Exit 1