mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-27 12:31:47 +00:00
add help in cobject arrays for 0 indexed accesses
in case people try to access the array starting at 0
This commit is contained in:
parent
f4b79bc7a4
commit
d71ef89dbb
1 changed files with 8 additions and 2 deletions
|
|
@ -438,8 +438,9 @@ static int smlua__get_field(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 key = lua_tointeger(L, 2);
|
int isNum;
|
||||||
if (!key) {
|
u32 key = lua_tointegerx(L, 2, &isNum);
|
||||||
|
if (!isNum) {
|
||||||
const char *key = lua_tostring(L, 2);
|
const char *key = lua_tostring(L, 2);
|
||||||
if (key && key[0] == '_') {
|
if (key && key[0] == '_') {
|
||||||
if (strcmp(key, "_lot") == 0) {
|
if (strcmp(key, "_lot") == 0) {
|
||||||
|
|
@ -455,6 +456,11 @@ static int smlua__get_field(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key == 0) {
|
||||||
|
LOG_LUA_LINE("Key is out of bounds for array: key '%u' (help: array starts at 1)", key);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
key--; // Lua is +1 indexed
|
key--; // Lua is +1 indexed
|
||||||
if (key >= data->count) {
|
if (key >= data->count) {
|
||||||
LOG_LUA_LINE("Key is out of bounds for array: key '%u'", key);
|
LOG_LUA_LINE("Key is out of bounds for array: key '%u'", key);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue