Ejemplo n.º 1
0
int ActionScript::luaActionGetThingfromPos(lua_State *L)
{
	//getThingfromPos(pos)
	//Note:
	//	stackpos = 255. Get the top thing(item moveable or creature).
	//	stackpos = 254. Get MagicFieldtItem
	//	stackpos = 253. Get Creature

	PositionEx pos;
	internalGetPositionEx(L,pos);

	ActionScript *action = getActionScript(L);

	//Tile *tile = action->game->getTile(pos.x, pos.y, pos.z);
	Tile *tile = action->game->map->getTile(pos);

	Thing *thing = NULL;

	if(tile){
		if(pos.stackpos == 255){
			thing = tile->getTopMoveableThing();
		}
		else if(pos.stackpos == 254){
			thing = tile->getFieldItem();
		}
		else if(pos.stackpos == 253){
			thing = tile->getTopCreature();
		}
		else{
			thing = tile->getThingByStackPos(pos.stackpos);
		}

		if(thing){
			if(pos.stackpos > 250){
				pos.stackpos = tile->getThingStackPos(thing);
			}
			unsigned int thingid = action->AddThingToMap(thing,pos);
			internalAddThing(L,thing,thingid);
		}
		else{
			internalAddThing(L,NULL,0);
		}
		return 1;

	}//if(tile)
	else{
		std::cout << "luagetItemfromPos: Tile not found" << std::endl;
		internalAddThing(L,NULL,0);
		return 1;
	}
}
Ejemplo n.º 2
0
void Container::internalAddThing(Thing* thing)
{
	internalAddThing(0, thing);
}
Ejemplo n.º 3
0
void Tile::internalAddThing(Thing* thing)
{
	internalAddThing(0, thing);
}