mmmm maybe it's possible...
doCreateItem in a certain x. y. z.
mmmm maybe i give it a try :ninja:
i think you cant will just return with error
yeh its not possible with normal doCreateItem() function, return error of "Tile not found" in console :thumbup:
maybe you force in source to do this i think..
yeh its not possible with normal doCreateItem() function, return error of "Tile not found" in console :thumbup:
maybe you force in source to do this i think..
then try till you die
what is a empty tile?
he is trolling again :S
int32_t LuaInterface::luaDoCreateItem(lua_State* L)
{
//doCreateItem(itemid[, type/count = 1], pos)
//Returns uid of the created item, only works on tiles.
PositionEx pos;
popPosition(L, pos);
uint32_t count = 1;
if(lua_gettop(L) > 1)
count = popNumber(L);
uint32_t itemId = popNumber(L);
ScriptEnviroment* env = getEnv();
const ItemType& it = Item::items[itemId];
Tile* tile = g_game.getTile(pos);
if(!tile)
{
if(it.group == ITEM_GROUP_GROUND)
{
Item* item = Item::CreateItem(itemId);
tile = IOMap::createTile(item, NULL, pos.x, pos.y, pos.z);
g_game.setTile(tile);
tile->onUpdateTile();
lua_pushnumber(L, env->addThing(item));
return 1;
}
else
{
errorEx(getError(LUA_ERROR_TILE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
}
int32_t itemCount = 1, subType = 1;
if(it.hasSubType())
{
if(it.stackable)
itemCount = (int32_t)std::ceil((float)count / 100);
subType = count;
}
else
itemCount = std::max((uint32_t)1, count);
while(itemCount > 0)
{
int32_t stackCount = std::min(100, subType);
Item* newItem = Item::CreateItem(itemId, stackCount);
if(!newItem)
{
errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
if(it.stackable)
subType -= stackCount;
ReturnValue ret = g_game.internalAddItem(NULL, tile, newItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
if(ret != RET_NOERROR)
{
delete newItem;
lua_pushboolean(L, false);
return 1;
}
--itemCount;
if(itemCount)
continue;
if(newItem->getParent())
lua_pushnumber(L, env->addThing(newItem));
else //stackable item stacked with existing object, newItem will be released
lua_pushnil(L);
return 1;
}
lua_pushnil(L);
return 1;
}
static Tile* createTile(Item*& ground, Item* item, uint16_t px, uint16_t py, uint16_t pz);
void onUpdateTile();
ground = {x = 1245, y = 1078, z = 2, stackpos = STACKPOS_GROUND}
getGround = getThingFromPos(ground)
if check then
doRemoveItem(getGround.uid) -- now there is NOTHING on this tile.
else
doCreateItem(459, 1, ground) -- on the EMPTY tile.
end
this works for me, both for doRemoveItem and doCreateItem
example
Code:ground = {x = 1245, y = 1078, z = 2, stackpos = STACKPOS_GROUND} getGround = getThingFromPos(ground) if check then doRemoveItem(getGround.uid) -- now there is NOTHING on this tile. else doCreateItem(459, 1, ground) -- on the EMPTY tile. end
slawkens, why you want to make blank tiles in mapeditor? ;s
I guess he wanted to say:
"Yay, it works"