ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Sun Sep 24, 2017 1:33 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Jan 07, 2011 11:31 pm 
Offline
Perspiring Physicist

Joined: Tue Jul 13, 2010 2:53 pm
Posts: 1332
Working on the Moon/Star knife pairing has highlighted how it would be useful to add temporary values to objects as well as actors. The addTemporaryValue, removeTemporaryValue functions and the compute_vals table could be moved from engine.Actor to engine.Entity quite easily, allowing for more flexible options. Thoughts?

_________________
Quote:
<DarkGod> lets say it's intended


Top
 Profile  
 
PostPosted: Sat Jan 08, 2011 8:55 am 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10126
Location: Angolwen
I pondered it in the past but never needed it :)
It's done, along with :attr()

_________________
[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: Sat Jan 08, 2011 6:02 pm 
Offline
Perspiring Physicist

Joined: Tue Jul 13, 2010 2:53 pm
Posts: 1332
I have two further extension proposals for the temporary value adding/removing. Currently you can only set a first-level property (something in the self table) with either a number or a single-level table. I have a use case where I would like to update a third-level property (so self.combat.melee_project[DamageType.BLINDPHYSICAL]) and these extensions would allow that.

The first and easiest on the code-eyes is to allow prop to be either a string or a table. If it is a table iterate over it to find the table you want to update the properties of and then execute the code as is (replacing self[prop] with the newly found table).

The second option is to allow the value to be updated be a nested table and write a closure that can be recursively called. We can also combine both and have a truly flexible/general function.

_________________
Quote:
<DarkGod> lets say it's intended


Top
 Profile  
 
PostPosted: Sat Jan 08, 2011 9:41 pm 
Offline
Perspiring Physicist

Joined: Tue Jul 13, 2010 2:53 pm
Posts: 1332
Here is my current refactor: http://pastebin.com/FjEx09sw

I think the stdout could be improved a bit to help with debugging, but I tested this with Moon/Star pairing and both extensions work.

EDIT: A slightly updated refactor: http://pastebin.com/hYbjxKYz

_________________
Quote:
<DarkGod> lets say it's intended


Top
 Profile  
 
PostPosted: Sun Mar 24, 2013 6:44 pm 
Offline
Wyrmic

Joined: Fri Jan 18, 2013 8:35 am
Posts: 261
I think a general addTemporaryValue is a nice idea. I recently tried using it with a talent, something like talentId:addTemporaryValue("cooldown", n), and of course it didn't work.

Still, not hard to work around; any function that can remember a temporary value id can remember a field and a value and can handle stuff manually. (In fact, I'm still not sure why addTemporaryValue is necessary, but I try to use it for consistency's sake.)

_________________
Proud father of Fx4fx and Chronometer add-ons; proud mother of Fated add-on


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

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