Entity:loadList / Object Generation Question

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
grayswandir
Uruivellas
Posts: 708
Joined: Wed Apr 30, 2008 5:55 pm

Entity:loadList / Object Generation Question

#1 Post 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?
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)

FACM
Higher
Posts: 65
Joined: Sun Jan 24, 2010 5:54 pm

Re: Entity:loadList / Object Generation Question

#2 Post by FACM »

I recall seeing somewhere that used egos to define materials. Would that work for what you want to do?

grayswandir
Uruivellas
Posts: 708
Joined: Wed Apr 30, 2008 5:55 pm

Re: Entity:loadList / Object Generation Question

#3 Post 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?
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Entity:loadList / Object Generation Question

#4 Post 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
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

grayswandir
Uruivellas
Posts: 708
Joined: Wed Apr 30, 2008 5:55 pm

Re: Entity:loadList / Object Generation Question

#5 Post 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.
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)

Post Reply