ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Mon Nov 30, 2020 7:36 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Apr 30, 2015 11:26 am 
Offline
Higher

Joined: Tue Jan 15, 2013 7:01 am
Posts: 70
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:
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:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group