Skip to content

Commit

Permalink
Lua plugin: Include properties from templates (#1901)
Browse files Browse the repository at this point in the history
Properties are copied from the template, then merged with the instances's
properties before being written to the export.
  • Loading branch information
Spice-King authored and bjorn committed Sep 5, 2018
1 parent 7e1a68c commit 6c9aff8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/lua/luaplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "map.h"
#include "mapobject.h"
#include "objectgroup.h"
#include "objecttemplate.h"
#include "properties.h"
#include "savefile.h"
#include "terrain.h"
Expand Down Expand Up @@ -668,7 +669,14 @@ void LuaWriter::writeMapObject(LuaTableWriter &writer,
break;
}

writeProperties(writer, mapObject->properties());
if (const MapObject *base = mapObject->templateObject()) {
// Include template properties
Properties props = base->properties();
props.merge(mapObject->properties());
writeProperties(writer, props);
} else {
writeProperties(writer, mapObject->properties());
}

writer.writeEndTable();
}
Expand Down

0 comments on commit 6c9aff8

Please sign in to comment.