diff --git a/sonic-radiance.love/core/modules/world/baseworld.lua b/sonic-radiance.love/core/modules/world/baseworld.lua index f16e67e..9257a31 100644 --- a/sonic-radiance.love/core/modules/world/baseworld.lua +++ b/sonic-radiance.love/core/modules/world/baseworld.lua @@ -102,10 +102,13 @@ function BaseWorld:initActors( ) self.currentCreationID = 0 end -function BaseWorld:newActor(name, x, y, z, properties) +function BaseWorld:newActor(name, x, y, z, properties, mapname) local debugstring = " at (" .. x .. ";" .. y .. ")." core.debug:print("world2D", "adding actor " .. name .. debugstring) local actor = self.obj.index[name](self, x, y) + if (mapname ~= nil) then + actor.mapname = mapname + end if (properties ~= nil) then actor:setProperties(properties) end diff --git a/sonic-radiance.love/core/modules/world/maps/sti.lua b/sonic-radiance.love/core/modules/world/maps/sti.lua index 6554959..5ab0342 100644 --- a/sonic-radiance.love/core/modules/world/maps/sti.lua +++ b/sonic-radiance.love/core/modules/world/maps/sti.lua @@ -9,6 +9,13 @@ function StiMap:new(world, mapfile) self.sti = STI(mapfile) StiMap.super.new(self, world) self:setBackgroundColorFromTable(self.sti.backgroundcolor) + self.mapname = self:getMapName(mapfile) +end + +function StiMap:getMapName(mapfile) + local filepath = utils.string.split(mapfile, "/") + local filenameMap = utils.string.split(filepath[#filepath], ".") + return filepath[#filepath - 1] .. "." .. filenameMap[1] end function StiMap:getDimensions() @@ -104,7 +111,7 @@ function StiMap:newActor(objectlayer, object) y = y + z end - self.world:newActor(objectlayer.name, object.x, y, z, object.properties) + self.world:newActor(objectlayer.name, object.x, y, z, object.properties, self.mapname) end function StiMap:newCollision(objectlayer, object)