Help creating stores with makeEntity

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
EatThisShoe
Higher
Posts: 72
Joined: Tue Jan 15, 2013 7:01 am

Help creating stores with makeEntity

#1 Post by EatThisShoe »

I'm trying to make an addon that randomly generates stores. I can make traps, and I can make stores using makeEntityByName, but I cannot seem to figure out how to make stores with makeEntity.

The generator code is pretty simple just to test, half copied from the random trap generator:

Code: Select all

require "engine.class"
local Map = require "engine.Map"
require "engine.Generator"
module(..., package.seeall, class.inherit(engine.Generator))

function _M:init(zone, map, level)
	engine.Generator.init(self, zone, map, level)
	local data = level.data.generator.trap

	self.filters = data.filters
	self.nb_trap = data.nb_trap or {10, 20}
	self.level_range = data.level_range or {level, level}
end

function _M:generate()
	self:regenFrom(1)
end

function _M:generate()
	local o = self.zone:makeEntity(self.level, "trap", nil, nil, true)
--	local o = self.zone:makeEntityByName(self.level, "trap", "HEAVY_ARMOR_STORE", true)
	self.zone:addEntity(self.level, o, "trap", 1, 1)
end
and traps.lua for the zone:

Code: Select all

load("/data/general/traps/store.lua")

newEntity{ base = "BASE_STORE", define_as = "HEAVY_ARMOR_STORE",
	name="Hormond & Son Plates",
	display='2', color=colors.UMBER,
	resolvers.store("HEAVY_ARMOR", "allied-kingdoms", "store/shop_door.png", "store/shop_sign_hormond_sons.png"),
}
I pretty much just copied a store from Last Hope.

When I add other traps to the traps.lua file then it always generates those traps. When the store is the only trap available I get a lua error because makeEntity is returning nil. My best guess is that makeEntity is not loading the store onto its' list of possible traps, but I'm not sure why.

Post Reply