JSFiddle - React, Tailwind, and code Playground
HTML
<script type="application/javascript">
var browser = "Chrome";
</script>
<script type="application/javascript;version=1.8">
// Only Firefox will interpret this block because th javascript version was included
browser = "Firefox";
</script
JavaScript
var ent = {};
ent.last_scan_result = function(){ return { type: 0, location: {x: 10, y:10}}};
ent.scanForward = function(){ return; /* dummy */ };
ent.facing = function(){ return 0; /* dummy */ };
ent.getX = function(){ return 20; };
ent.getY = function(){ return 20; };
/*
ent.CustGenGet_distance_to_wall_in_front = function() { // Firefox
/*/
ent.CustGenGet_distance_to_wall_in_front = function*() { // Chrome
//*/
while(true){
ent.scanForward(); yield 3; // This is the value being returned. WRONG
while ((ent.last_scan_result().type) != (1)) {
ent.scanForward(); yield 3;
}
if ((ent.facing() == 0) || (ent.facing() == 2)) {
if (true) {
yield Math.abs((ent.getY()) - (ent.last_scan_result().location.y));
yield -1;
}
distance = Math.abs((ent.getY()) - (ent.last_scan_result().location.y));
}
if ((ent.facing() == 1) || (ent.facing() == 3)) {
distance = Math.abs((ent.getX()) - (ent.last_scan_result().location.y));
}
yield distance; // This is what I want in userVar! Somehow
yield -1;
} };
ent.CustIterGet_distance_to_wall_in_front = ent.CustGenGet_distance_to_wall_in_front();
/*
ent.CustGen2Get_distance_to_wall_in_front = function(){ // Firefox
/*/
ent.CustGen2Get_distance_to_wall_in_front = function*(){ // Chrome
//*/
while(true){
ent.CustIterGet_distance_to_wall_in_front = ent.CustGenGet_distance_to_wall_in_front();
ent.CustIterVarLastGet_distance_to_wall_in_front = ent.CustIterVarGet_distance_to_wall_in_front;
ent.CustIterVarGet_distance_to_wall_in_front = ent.CustIterGet_distance_to_wall_in_front.next();
if(ent.CustIterVarGet_distance_to_wall_in_front == -1){
// Value is ready to return
yield {return: ent.CustIterVarLastGet_distance_to_wall_in_front};
}else{
...