Skip to content

Commit

Permalink
quickjs: add getb
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
cosmo-ray committed Aug 15, 2024
1 parent 4478c28 commit 752b9e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions core/script/quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,21 @@ static JSValue array_geti(JSContext *ctx, JSValueConst this_val,
return JS_NULL;
}

static JSValue array_getb(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
Entity *e = GET_E_(this_val);

if (JS_IsNumber(argv[0])) {
return JS_NewBool(ctx, yeGetIntAt(e, GET_I(ctx, 0)));
} else if (JS_IsString(argv[0])) {
return JS_NewBool(ctx, yeGetIntAt(e, GET_S(ctx, 0)));
} else {
return JS_NewBool(ctx, yeGetIntAt(e, GET_E(ctx, 0)));
}
return JS_NULL;
}

static JSValue array_gets(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
Expand Down Expand Up @@ -1349,6 +1364,7 @@ static const JSCFunctionListEntry js_ent_proto_funcs[] = {
JS_CFUNC_DEF("rm", 0, array_remove),
JS_CFUNC_DEF("get", 1, array_get),
JS_CFUNC_DEF("push", 1, array_push),
JS_CFUNC_DEF("getb", 1, array_getb),
JS_CFUNC_DEF("geti", 1, array_geti),
JS_CFUNC_DEF("gets", 1, array_gets),
JS_CFUNC_DEF("addAt", 0, array_add_at),
Expand Down
2 changes: 1 addition & 1 deletion modules/amap/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function amap_action(wid, events)
return false
let at = yeGet(h, "at")
if (yeGetInt(at) == yeGetIntAt(pc_canel, PC_NB_TURN_IDX)) {
if (h.geti("stop movement") == 1) {
if (h.getb("stop movement")) {
y_move_set_xspeed(pc_minfo, 0)
}
ywidActions(wid, h)
Expand Down

0 comments on commit 752b9e8

Please sign in to comment.