• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Create floor

GSMaster

Why? for money
Joined
Oct 26, 2008
Messages
169
Solutions
1
Reaction score
10
Location
HKS <3
if you can create floor in a place where there is nothing (in the map there is no floor), for example the floor above. (lua script)?
 
hmm, i had same problem, and i make it by placing first blank tiles and then creating on it a tiles by script.. Anyway my 3660 is kinda bugged so i need to update to newer tfs to check.
 
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..

not a fource as quas just said.. create empty tile then create a tile on it... no erros and will work im scripting it :ninja:
 
sorry double post by error rather than editing..
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..

not a force... as quas just said, create empty tile then create a tile on it... no erros and will work im scripting it :ninja:

and

then try till you die

i won't die that easy :ninja:
 
This is possible since latest update in 0.4_DEV repository.

Here is a quick solution:

luascript.cpp
Replace this function:
Code:
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;
}

iomap.h
Move this line under "public:"
Code:
static Tile* createTile(Item*& ground, Item* item, uint16_t px, uint16_t py, uint16_t pz);

tile.h
Move this line above "private:"
Code:
void onUpdateTile();
 
this works for me, both for doRemoveItem and doCreateItem

example :p
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
 
Last edited:
this works for me, both for doRemoveItem and doCreateItem

example :p
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

ok, but first you have to create those blank tiles in map editor, am I right? :) With patch posted above you don't have to, so you're allowed to create whole map from scratch just with simple lua script.
 
Back
Top