fix double input bug
This commit is contained in:
parent
af79dba48a
commit
67fe729d8c
|
@ -29,9 +29,6 @@ globalThis.class_use = function(script, config, base, callback)
|
||||||
|
|
||||||
if (callback) callback(padawan);
|
if (callback) callback(padawan);
|
||||||
|
|
||||||
if (typeof config === 'object')
|
|
||||||
Object.merge(padawan,config);
|
|
||||||
|
|
||||||
var script = Resources.replstrs(file);
|
var script = Resources.replstrs(file);
|
||||||
script = `(function() {
|
script = `(function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -42,6 +39,9 @@ globalThis.class_use = function(script, config, base, callback)
|
||||||
var fn = os.eval(file,script);
|
var fn = os.eval(file,script);
|
||||||
fn.call(padawan);
|
fn.call(padawan);
|
||||||
|
|
||||||
|
if (typeof config === 'object')
|
||||||
|
Object.merge(padawan,config);
|
||||||
|
|
||||||
return padawan;
|
return padawan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ var mod = {
|
||||||
released
|
released
|
||||||
rep
|
rep
|
||||||
pressed
|
pressed
|
||||||
pressrep
|
|
||||||
down
|
down
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -83,7 +82,6 @@ prosperon.keydown = function(key, repeat)
|
||||||
mod.shift = 1;
|
mod.shift = 1;
|
||||||
else {
|
else {
|
||||||
var emacs = modstr() + keyname_extd(key);
|
var emacs = modstr() + keyname_extd(key);
|
||||||
player[0].raw_input(emacs, "pressrep");
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
player[0].raw_input(emacs, "rep");
|
player[0].raw_input(emacs, "rep");
|
||||||
else
|
else
|
||||||
|
@ -289,6 +287,11 @@ input.tabcomplete = function(val, list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* May be a human player; may be an AI player */
|
/* May be a human player; may be an AI player */
|
||||||
|
|
||||||
|
/*
|
||||||
|
'block' on a pawn's input blocks any input from reaching below for the
|
||||||
|
*/
|
||||||
|
|
||||||
var Player = {
|
var Player = {
|
||||||
players: [],
|
players: [],
|
||||||
input(fn, ...args) {
|
input(fn, ...args) {
|
||||||
|
@ -335,18 +338,14 @@ var Player = {
|
||||||
},
|
},
|
||||||
|
|
||||||
raw_input(cmd, state, ...args) {
|
raw_input(cmd, state, ...args) {
|
||||||
|
console.info(cmd + state);
|
||||||
for (var pawn of this.pawns.reversed()) {
|
for (var pawn of this.pawns.reversed()) {
|
||||||
if (!pawn.inputs) {
|
if (!pawn.inputs) {
|
||||||
console.error(`pawn no longer has inputs object.`);
|
console.error(`pawn no longer has inputs object.`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof pawn.inputs.any === 'function') {
|
var block = pawn.inputs.block;
|
||||||
pawn.inputs.any(cmd);
|
|
||||||
|
|
||||||
if (!pawn.inputs.fallthru)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pawn.inputs[cmd]) {
|
if (!pawn.inputs[cmd]) {
|
||||||
if (pawn.inputs.block) return;
|
if (pawn.inputs.block) return;
|
||||||
|
@ -372,17 +371,15 @@ var Player = {
|
||||||
fn = pawn.inputs[cmd];
|
fn = pawn.inputs[cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof fn === 'function') {
|
if (typeof fn === 'function')
|
||||||
fn.call(pawn, ... args);
|
fn.call(pawn, ... args);
|
||||||
if (!pawn.inputs) continue; // TODO: OK? Checking if the call uncontrolled the pawn
|
|
||||||
pawn.inputs.post?.call(pawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (state) {
|
if (!pawn.inputs)
|
||||||
case 'released':
|
if (block) return;
|
||||||
|
else continue;
|
||||||
|
|
||||||
|
if (state === 'released')
|
||||||
pawn.inputs.release_post?.call(pawn);
|
pawn.inputs.release_post?.call(pawn);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pawn.inputs.fallthru) return;
|
if (!pawn.inputs.fallthru) return;
|
||||||
if (pawn.inputs.block) return;
|
if (pawn.inputs.block) return;
|
||||||
|
|
Loading…
Reference in a new issue