mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
refactor Content
This commit is contained in:
parent
f3c5afa1ab
commit
ee9f1639e9
25 changed files with 180 additions and 209 deletions
|
|
@ -8,30 +8,30 @@ using namespace scripting;
|
|||
static int l_item_name(lua::State* L) {
|
||||
auto indices = content->getIndices();
|
||||
auto id = lua::tointeger(L, 1);
|
||||
if (static_cast<size_t>(id) >= indices->countItemDefs()) {
|
||||
if (static_cast<size_t>(id) >= indices->items.count()) {
|
||||
return 0;
|
||||
}
|
||||
auto def = indices->getItemDef(id);
|
||||
auto def = indices->items.get(id);
|
||||
return lua::pushstring(L, def->name);
|
||||
}
|
||||
|
||||
static int l_item_index(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
return lua::pushinteger(L, content->requireItem(name).rt.id);
|
||||
return lua::pushinteger(L, content->items.require(name).rt.id);
|
||||
}
|
||||
|
||||
static int l_item_stack_size(lua::State* L) {
|
||||
auto indices = content->getIndices();
|
||||
auto id = lua::tointeger(L, 1);
|
||||
if (static_cast<size_t>(id) >= indices->countItemDefs()) {
|
||||
if (static_cast<size_t>(id) >= indices->items.count()) {
|
||||
return 0;
|
||||
}
|
||||
auto def = indices->getItemDef(id);
|
||||
auto def = indices->items.get(id);
|
||||
return lua::pushinteger(L, def->stackSize);
|
||||
}
|
||||
|
||||
static int l_item_defs_count(lua::State* L) {
|
||||
return lua::pushinteger(L, indices->countItemDefs());
|
||||
return lua::pushinteger(L, indices->items.count());
|
||||
}
|
||||
|
||||
const luaL_Reg itemlib [] = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue