ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Fri Aug 17, 2018 12:42 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Feb 17, 2016 8:19 am 
Offline

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


Top
 Profile  
 
PostPosted: Wed Feb 17, 2016 8:48 am 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10228
Location: Angolwen
Resolvers basically are there to let you postpone some stuff in entities.
You *could* write a field like that in an entity:
Code:
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:
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 ;)


Top
 Profile  
 
PostPosted: Wed Feb 17, 2016 8:41 pm 
Offline

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


Top
 Profile  
 
PostPosted: Wed Feb 17, 2016 10:44 pm 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10228
Location: Angolwen
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 ;)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group