Role of resolvers.lua in modules?

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
LeToucanHasArrived
Posts: 2
Joined: Wed Feb 17, 2016 6:32 am

Role of resolvers.lua in modules?

#1 Post by LeToucanHasArrived »

Hi all,

I'm trying to dig into T-Engine4 module development by hacking together stuff from various open source modules, but I also want to understand what the API's actually do. I think I'm building up intuition about most of the files but I am totally stumped by the resolvers.lua file and resolvers in general. Can someone help me understand what are resolvers and how they work?

Thanks!

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

Re: Role of resolvers.lua in modules?

#2 Post by darkgod »

Resolvers basically are there to let you postpone some stuff in entities.
You *could* write a field like that in an entity:

Code: Select all

foo = rng.range(1,10)
But the call to rng.range would happen when the entity files is loaded and thus set the value in stone for all entities cloned from it.
If instead you used

Code: Select all

foo = resolvers.rngrange(1, 10)
Then it would take its value only when the entity has been cloned, making sure every clone has its own random value.
[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 ;)

LeToucanHasArrived
Posts: 2
Joined: Wed Feb 17, 2016 6:32 am

Re: Role of resolvers.lua in modules?

#3 Post by LeToucanHasArrived »

Thanks! So a resolver is just a function you call as part of loading an entity right? Does the engine itself have any concept of resolvers?

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

Re: Role of resolvers.lua in modules?

#4 Post by darkgod »

Yes it does, a resolver function must return a table taht has a field "__resolver" set to a unique name (most of the time the same as the name of the resolver).
The engine will look for this name in the resolvers.calc table when it needs to actually resolve the entity.
Just take a look a the existing resolvers it should be self evident now :)
[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 ;)

Post Reply