Page 1 of 1

Entity:loadList / Object Generation Question

Posted: Wed Jun 09, 2010 9:44 pm
by grayswandir
I'm trying to auto-generate items based on material and type, such as:

Code: Select all

generate({"IRON", "STEEL", "MYTHRIL"}, {"KNIFE", "SWORD", "AXE"})
as the equivalent of 9 newEntity blocks.

So I've modeled a Material and EquipType classes after the DamageType class. To have the classes be recognized at item generation time, I'm guessing that you'd have to add them here (line 238), in Entity:loadList, similar to the DamageType line:

Code: Select all

	setfenv(f, setmetatable({
		resolvers = resolvers,
		DamageType = require "engine.DamageType",
		newEntity = function(t)
I was thinking of redefining loadList in mod.class.Object. However, the loadList function references the entities_load_functions class local variable, so I can't think of a decent way to actually subclass it. Right now, the only solution I can think of is to copy over the entire Entity class, and every subclass as mod local classes, just to add one or two lines inside of that function. Can anybody else think of a better way?

Re: Entity:loadList / Object Generation Question

Posted: Wed Jun 09, 2010 10:05 pm
by FACM
I recall seeing somewhere that used egos to define materials. Would that work for what you want to do?

Re: Entity:loadList / Object Generation Question

Posted: Wed Jun 09, 2010 10:15 pm
by grayswandir
I haven't even looked at egos yet, so I'm not sure. But I'm trying to create the basic item types, as opposed to special ones. If I used egos, wouldn't that mean every equipable item needs an ego?

Re: Entity:loadList / Object Generation Question

Posted: Wed Jun 09, 2010 10:17 pm
by darkgod
So basicalyl you want a "helper" function to generate some entities ?

just define generate inside the files directly.
You can require your class there too if you need them, like I usualy require ActorTalents for NPCs

Re: Entity:loadList / Object Generation Question

Posted: Wed Jun 09, 2010 10:35 pm
by grayswandir
Yeah, the require does work. I could have sworn that didn't work the first time... :oops:

Ah well, sorry for the trouble.