Skip to content

Commit

Permalink
Convert between 0-indexing and 1-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Jan 13, 2024
1 parent 3b1f14e commit 9a55a87
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plutoscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function pluto_push(coro, arg)
for (key in arg)
{
let intkey = parseInt(key);
if (pluto_push(coro, intkey == key ? intkey : key))
if (pluto_push(coro, intkey == key ? intkey + 1 : key))
{
if (pluto_push(coro, arg[key]))
{
Expand Down Expand Up @@ -268,6 +268,10 @@ function pluto_extract(coro, nvals)
while (lib.lua_next(coro, -2))
{
let [key, value] = pluto_extract(coro, 2);
if (typeof(key) == "number")
{
key--;
}
obj[key] = value;
lib.lua_pop(coro, 1);
}
Expand Down

0 comments on commit 9a55a87

Please sign in to comment.