Minor tweak to hCharacterMovement()
This commit is contained in:
@@ -59,7 +59,7 @@ createTrigger("door 1", overworld, 128, -128, function(entity)
|
||||
end
|
||||
|
||||
local x, y = characterAPI.GetOrigin(entity)
|
||||
characterAPI.SetRoomIndex(entity, uidTwo) --TODO: (0) take exit coordinates as a parameter
|
||||
characterAPI.SetRoomIndex(entity, uidTwo)
|
||||
characterAPI.SetOrigin(entity, 0, 0)
|
||||
networkAPI.PumpCharacterUpdate(entity)
|
||||
end)
|
||||
|
||||
@@ -49,9 +49,10 @@ static int setRoomIndex(lua_State* L) { //TODO: (1) take the room userdata as a
|
||||
|
||||
//error checking
|
||||
if (characterIndex == -1) {
|
||||
throw(std::runtime_error("Failed to find character index by reference"));
|
||||
throw(std::runtime_error("Lua Error: Failed to find character index by reference"));
|
||||
}
|
||||
|
||||
//send the delete & create messages
|
||||
pumpAndChangeRooms(character, lua_tointeger(L, 2), characterIndex);
|
||||
return 0;
|
||||
}
|
||||
@@ -75,8 +76,8 @@ static int getAvatar(lua_State* L) {
|
||||
}
|
||||
|
||||
static const luaL_Reg characterLib[] = {
|
||||
// {"GetOwner", getOwner}, //unusable without account API
|
||||
{"SetRoomIndex", setRoomIndex},
|
||||
// {"GetOwner", getOwner}, //unusable without account API
|
||||
{"GetHandle", getHandle},
|
||||
{"GetAvatar", getAvatar},
|
||||
{nullptr, nullptr}
|
||||
|
||||
@@ -212,6 +212,11 @@ void ServerApplication::hCharacterMovement(CharacterPacket* const argPacket) {
|
||||
|
||||
//check if moving rooms
|
||||
if (characterData->GetRoomIndex() != argPacket->roomIndex) {
|
||||
//set the character's origin and motion
|
||||
characterData->SetOrigin(argPacket->origin);
|
||||
characterData->SetMotion(argPacket->motion);
|
||||
|
||||
//send the delete & create messages
|
||||
pumpAndChangeRooms(characterData, argPacket->roomIndex, argPacket->characterIndex);
|
||||
}
|
||||
//if not moving between rooms
|
||||
|
||||
Reference in New Issue
Block a user