--- Log opened Mon Oct 10 00:00:57 2016 20161010 00:02:33-!- prophile [~alynn@oftn/oswg-member/prophile] has quit [Quit: The Game] 20161010 00:23:31-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20161010 00:23:38-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth 20161010 00:37:02-!- edaq [~edaq3@h184-60-58-252.cytnin.broadband.dynamic.tds.net] has joined #wesnoth 20161010 00:38:09-!- jemadux [~jemadux@unaffiliated/jemadux] has quit [Quit: Leaving] 20161010 00:39:25-!- Vadatajs [~Vadatajs@63-152-66-240.cdrr.qwest.net] has quit [Read error: Connection reset by peer] 20161010 01:04:59-!- Smedles [~quassel@CPE-58-160-77-34.ssqn1.lon.bigpond.net.au] has quit [Ping timeout: 256 seconds] 20161010 01:18:37-!- ancestral [~ancestral@75-168-189-115.mpls.qwest.net] has joined #wesnoth 20161010 01:29:41-!- Rh0nda [~rhonda@anguilla.debian.or.at] has quit [Ping timeout: 248 seconds] 20161010 01:30:29-!- Jetrel_bot [~Jetrel@ec2.happyspork.com] has quit [Ping timeout: 260 seconds] 20161010 01:31:13-!- Rhonda [~rhonda@anguilla.debian.or.at] has joined #wesnoth 20161010 01:34:39-!- Jetrel_bot [~Jetrel@ec2.happyspork.com] has joined #wesnoth 20161010 01:34:46-!- Grickit is now known as Gambit 20161010 02:41:00-!- ArneBab_ [~quassel@55d46ee0.access.ecotel.net] has joined #wesnoth 20161010 02:45:25-!- ArneBab [~quassel@55d47f97.access.ecotel.net] has quit [Ping timeout: 248 seconds] 20161010 03:10:30-!- mystic_x [~X@unaffiliated/mysticx] has quit [Quit: Leaving.] 20161010 03:53:53-!- Kwandulin [~Miranda@p200300760F2C71D3D56812C2C9812869.dip0.t-ipconnect.de] has joined #wesnoth 20161010 04:03:48-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Remote host closed the connection] 20161010 04:04:14-!- vultraz_iOS [uid24821@wesnoth/developer/vultraz] has joined #wesnoth 20161010 04:19:57-!- bumbadadabum [~bumbadada@wesnoth/developer/bumbadadabum] has quit [Ping timeout: 240 seconds] 20161010 04:20:15-!- ancestral [~ancestral@75-168-189-115.mpls.qwest.net] has quit [Quit: i go nstuf kthxbai] 20161010 04:21:57-!- ChipmunkV [~vova@static-89-94-113-91.axione.abo.bbox.fr] has joined #wesnoth 20161010 04:25:26-!- ChipmunkV [~vova@static-89-94-113-91.axione.abo.bbox.fr] has quit [Client Quit] 20161010 05:01:00-!- vultraz [~chatzilla@124.109.10.167] has joined #wesnoth 20161010 05:01:00-!- vultraz [~chatzilla@124.109.10.167] has quit [Changing host] 20161010 05:01:00-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 05:11:06-!- Kwandulin [~Miranda@p200300760F2C71D3D56812C2C9812869.dip0.t-ipconnect.de] has quit [Read error: Connection reset by peer] 20161010 05:19:37-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 260 seconds] 20161010 05:23:50-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 06:19:50-!- vultraz_iOS [uid24821@wesnoth/developer/vultraz] has quit [Quit: Connection closed for inactivity] 20161010 07:10:02-!- zookeeper [~lmsnie@wesnoth/developer/zookeeper] has joined #wesnoth 20161010 07:14:59-!- edaq [~edaq3@h184-60-58-252.cytnin.broadband.dynamic.tds.net] has quit [Quit: Leaving] 20161010 07:15:21-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 260 seconds] 20161010 07:20:17-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 07:32:21-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 248 seconds] 20161010 07:37:22-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 07:47:37-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 240 seconds] 20161010 07:52:47-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 08:10:07-!- Smedles [~quassel@CPE-58-160-77-59.ssqn1.lon.bigpond.net.au] has joined #wesnoth 20161010 08:10:53-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 260 seconds] 20161010 08:15:52-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 08:17:05-!- celticminstrel [~celmin@unaffiliated/celticminstrel] has quit [Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] 20161010 08:24:53-!- cyphase [~cyphase@unaffiliated/cyphase] has quit [Ping timeout: 260 seconds] 20161010 08:29:20-!- cyphase [~cyphase@unaffiliated/cyphase] has joined #wesnoth 20161010 08:45:42-!- Ivanovic_ [~ivanovic@p579FBF3F.dip0.t-ipconnect.de] has joined #wesnoth 20161010 08:49:05-!- PjotrOrial_ [quassel@quassel.woboq.de] has joined #wesnoth 20161010 08:49:41-!- ArneBab [~quassel@55d46ee0.access.ecotel.net] has joined #wesnoth 20161010 08:49:44-!- enchi_ [enchilado@defocus/yummy/enchilado] has joined #wesnoth 20161010 08:50:21-!- Soliton [~Soliton@wesnoth/developer/soliton] has quit [Disconnected by services] 20161010 08:50:26-!- Soliton_ [~Soliton@wesnoth/developer/soliton] has joined #wesnoth 20161010 08:50:54-!- Soliton_ is now known as Soliton 20161010 08:54:51-!- Netsplit *.net <-> *.split quits: PjotrOrial, salluc69, enchi, APic, ArneBab_, Appleman1234, Sonderblade, root_____, Ivanovic 20161010 08:55:37-!- Ivanovic_ is now known as Ivanovic 20161010 09:01:19-!- Netsplit over, joins: APic 20161010 09:01:35-!- Netsplit over, joins: Sonderblade 20161010 09:02:17-!- Netsplit over, joins: salluc69 20161010 09:02:43-!- Netsplit over, joins: root_____ 20161010 09:13:55-!- Appleman1234 [~Appleman1@KD106154000208.au-net.ne.jp] has joined #wesnoth 20161010 10:08:37-!- bumbadadabum [~bumbadada@wesnoth/developer/bumbadadabum] has joined #wesnoth 20161010 10:16:36-!- enchi_ is now known as enchi 20161010 10:32:51-!- Vadatajs [~Vadatajs@63-152-66-240.cdrr.qwest.net] has joined #wesnoth 20161010 11:08:21-!- enchi [enchilado@defocus/yummy/enchilado] has quit [Ping timeout: 268 seconds] 20161010 11:15:41-!- enchi [enchilado@defocus/yummy/enchilado] has joined #wesnoth 20161010 11:39:46-!- Kwandulin [~Miranda@p200300760F2C7167B81AB181697B28FC.dip0.t-ipconnect.de] has joined #wesnoth 20161010 12:14:35-!- irco [~irco@HSI-KBW-134-3-111-4.hsi14.kabel-badenwuerttemberg.de] has joined #wesnoth 20161010 12:32:45-!- Kwandulin [~Miranda@p200300760F2C7167B81AB181697B28FC.dip0.t-ipconnect.de] has quit [Read error: Connection reset by peer] 20161010 12:44:51-!- irco [~irco@HSI-KBW-134-3-111-4.hsi14.kabel-badenwuerttemberg.de] has quit [Ping timeout: 250 seconds] 20161010 12:52:41-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Read error: Connection reset by peer] 20161010 12:53:12-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 13:07:53-!- Appleman1234_ [~Appleman1@KD106154010119.au-net.ne.jp] has joined #wesnoth 20161010 13:10:41-!- Appleman1234 [~Appleman1@KD106154000208.au-net.ne.jp] has quit [Ping timeout: 260 seconds] 20161010 13:17:25-!- Sonderblade [~Sonderbla@h-52-183.a157.priv.bahnhof.se] has quit [Quit: Lämnar] 20161010 13:21:04-!- ancestral [~ancestral@75-168-189-115.mpls.qwest.net] has joined #wesnoth 20161010 13:21:14-!- ancestral [~ancestral@75-168-189-115.mpls.qwest.net] has quit [Client Quit] 20161010 13:25:19-!- Appleman1234_ is now known as Appleman1234 20161010 14:38:00< DeFender1031> is there a way to prevent units from ending up on the recall list for the next level while still having them appear in linger mode? 20161010 14:45:17< mattsc> DeFender1031: store them in a variable (or store a variable in them) and kill in prestart event? 20161010 14:46:26< zookeeper> yeah, just get rid of them one way or another in a prestart event. earlier than that, no, except maybe in a preload event but i don't know if that has any pitfalls. 20161010 15:19:26-!- Kwandulin [~Miranda@p200300760F2C716759298D27268B3352.dip0.t-ipconnect.de] has joined #wesnoth 20161010 15:23:35< DeFender1031> prestart of the NEXT scenario, you mean? 20161010 15:25:17< mattsc> yes 20161010 15:26:43< DeFender1031> That could work, though i'll probably set it up with a lua hack to do it automatically rather than having to explicitly include something in the next scenario unrelated to itself (also because i have this right before a set of four scenarios that you can choose in any order) 20161010 15:41:06-!- Kranix [~magnus@x1-6-74-44-01-e4-f1-52.cpe.webspeed.dk] has joined #wesnoth 20161010 16:27:43-!- irco [~irco@HSI-KBW-134-3-111-4.hsi14.kabel-badenwuerttemberg.de] has joined #wesnoth 20161010 16:30:18-!- celticminstrel [~celmin@unaffiliated/celticminstrel] has joined #wesnoth 20161010 16:40:12-!- ChipmunkV [~vova@static-89-94-113-91.axione.abo.bbox.fr] has joined #wesnoth 20161010 16:40:17-!- Kranix [~magnus@x1-6-74-44-01-e4-f1-52.cpe.webspeed.dk] has quit [Ping timeout: 240 seconds] 20161010 17:10:27-!- claymore [~claymore@unaffiliated/claymore] has joined #wesnoth 20161010 17:27:30-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Read error: Connection reset by peer] 20161010 17:31:02-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 17:31:54-!- wario [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 17:50:29-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Ping timeout: 260 seconds] 20161010 17:50:56-!- vultraz [~chatzilla@124.109.10.167] has joined #wesnoth 20161010 17:50:56-!- vultraz [~chatzilla@124.109.10.167] has quit [Changing host] 20161010 17:50:56-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 18:13:26< DeFender1031> mattsc, finally getting around to looking at the AI stuff. Is there documentation somewhere on what all of this stuff is actually doing? I see the code, but it's not clear to me what parts of it are part of the AI framework and what parts are local calculations. (A sample AI skeleton with just basics might help here as well.) 20161010 18:15:41< mattsc> DeFender1031: https://wiki.wesnoth.org/Wesnoth_AI 20161010 18:17:13-!- Pepe_ [~ppjet@anderith.bouah.net] has quit [Ping timeout: 250 seconds] 20161010 18:17:20-!- Pepe_ [~ppjet@anderith.bouah.net] has joined #wesnoth 20161010 18:18:07< DeFender1031> The intro paragraph on https://wiki.wesnoth.org/Creating_Custom_AIs is none too reassuring :P 20161010 18:20:07< DeFender1031> does the colon syntax work in 1.12? How does it differ from the dot syntax? (Mostly asking celticminstrel, as I think mattsc already told me that he was uncertain and to ask celmin.) 20161010 18:20:08-!- wario_ [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 18:24:12-!- wario [~wario_@unaffiliated/wario] has quit [Ping timeout: 260 seconds] 20161010 18:24:41-!- Kranix [~magnus@x1-6-74-44-01-e4-f1-52.cpe.webspeed.dk] has joined #wesnoth 20161010 18:25:23< DeFender1031> okay, according to the page, it seems colon implicitly defines self. 20161010 18:26:05< DeFender1031> my question is still, does that work in 1.12? 20161010 18:26:53< mattsc> The colon syntax works in 1.12 20161010 18:28:52< mattsc> DeFender1031: I’ll be afk for the next 2 hours or so. 20161010 18:29:03< DeFender1031> okay 20161010 18:29:29-!- wario_ is now known as wario 20161010 18:31:11< DeFender1031> is there documentation on what functions exist in ai_helper? 20161010 18:31:48< DeFender1031> nevermind, found it 20161010 18:32:39< DeFender1031> oh, no, i actually didn't 20161010 18:36:39< DeFender1031> ah, i see. looked at the file itself. there's a notice about not guaranteeing compatibility. Fine, so i'll have to read the source to see what is in there. That's fine. 20161010 18:41:42-!- Kwandulin [~Miranda@p200300760F2C716759298D27268B3352.dip0.t-ipconnect.de] has quit [Read error: Connection reset by peer] 20161010 19:03:25< celticminstrel> DeFender1031: blah:thing(arg) is exactly the same as blah.thing(blah, arg). 20161010 19:03:52< celticminstrel> It's a feature of Lua syntax. 20161010 19:04:11< celticminstrel> When defining a function with the colon, the implicit argument is called "self". 20161010 19:10:06< DeFender1031> celticminstrel, then according to https://wiki.wesnoth.org/Creating_Custom_AIs self.blah would be (in the example) the same as ca_return_guardian.blah? 20161010 19:11:25< DeFender1031> then why not just skip the self thing and just use the object that you already have access to from the parent scope? Also, why set values on the object instead of creating local variables in the file and using those within the closure? 20161010 19:20:19-!- wario_ [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 19:23:56-!- wario [~wario_@unaffiliated/wario] has quit [Ping timeout: 250 seconds] 20161010 19:23:57-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Ping timeout: 240 seconds] 20161010 19:24:07-!- vultraz [~chatzilla@124.109.10.167] has joined #wesnoth 20161010 19:24:08-!- vultraz [~chatzilla@124.109.10.167] has quit [Changing host] 20161010 19:24:08-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 19:36:00< celticminstrel> I don't really have an answer for you... 20161010 19:36:14< celticminstrel> But yes, I guess self.blah would be the same as ca_return_guardian.blah in that specific case. 20161010 19:36:38< celticminstrel> Though, it's possible the C++ code passes some other object as self. I can't remember. 20161010 19:37:23< DeFender1031> celticminstrel, i guess what i'm asking is whether in http://paste.nachsoftware.com/DeFender1031/BmThCg810f258b0f2435d5d0757fbe908cc2a9Xr versions a and b are the same, and if so, why not just do version c instead? 20161010 19:38:25< DeFender1031> oh, maybe i should also clarify for this case... as i understand it, the purpose of the extra self parameter is to pass persistent data from the evaluation to the execution. Is this correct? 20161010 19:38:42< DeFender1031> And then, if so, why not just do version c? 20161010 19:39:35-!- ancestral [~ancestral@63.236.20.2] has joined #wesnoth 20161010 19:42:29-!- ancestral [~ancestral@63.236.20.2] has quit [Client Quit] 20161010 19:50:15< DeFender1031> okay, it looks like you only NEED to use that persistent data thing when you need something that will persist across ai cycles and save/loads. 20161010 19:51:33< celticminstrel> I'm not used to seeing Lua with semicolons... 20161010 19:52:24< celticminstrel> Well, you'd need ca_custom_thingy={} for that to even work. 20161010 19:52:31< celticminstrel> And version B is inconsistent. 20161010 19:53:30< DeFender1031> celticminstrel, i tend to explicitly semicolon my code even when unnecessary... 20161010 19:53:39< celticminstrel> And I know no reason not to do version C with respect to the use of persistent variables. However, only one of A or C will actually work when called by the engine. 20161010 19:53:53< DeFender1031> and yes, those lines are supposed to contain the "= {}" 20161010 19:53:55< celticminstrel> I don't remember which one, and it might be different between 1.12 and 1.13 as well. 20161010 19:54:19< DeFender1031> what do you mean that only one will work? 20161010 19:54:42< celticminstrel> They declare functions with different numbers of parameters. 20161010 19:55:00< celticminstrel> Version A declares ternary functions, and version C declares binary functions. 20161010 19:55:15< DeFender1031> and yeah, b is inconsistent 20161010 19:55:17< DeFender1031> right 20161010 19:55:21< DeFender1031> i made a bunch of typos here 20161010 19:55:51< DeFender1031> i guess i don't understand how these get called 20161010 19:56:20< DeFender1031> oh! 20161010 19:56:46< celticminstrel> I'm pretty sure the engine passes three parameters, and in 1.12 the AI table is probably the second parameter, which means that for C to work you'd need (self, ai, cfg) rather than just (ai, cfg)... I could be wrong though. 20161010 19:56:50< DeFender1031> you're saying that the colon defines that whatever is the first parameter of the function gets passed as an implicit "self" 20161010 19:57:01< celticminstrel> Yes, exactly. 20161010 19:57:25< DeFender1031> ah, i thought it meant that whatever came before the colon in the DEFINITION ended up as self 20161010 19:57:36< celticminstrel> "function var:blah(a, b)" is exactly equivalent to "function var.blah(self, a, b)" 20161010 19:57:43< DeFender1031> (I honestly don't particularly like this colon syntax) 20161010 19:57:58< DeFender1031> odd... 20161010 19:58:02< celticminstrel> And when you call it, "var:blah(a, b)" is exactly equivalent to "blah(blah, a, b)". 20161010 19:58:07< DeFender1031> so self has no relation to var whatsoever? 20161010 19:58:14< celticminstrel> Sorry, that last one should be "var.blah". 20161010 19:58:17< DeFender1031> right 20161010 19:58:23< celticminstrel> "var.blah(var, a, b)" to be precise. 20161010 19:58:25< DeFender1031> and passing var 20161010 19:58:27< DeFender1031> yeah 20161010 19:58:38< DeFender1031> oh, okay 20161010 19:58:49< DeFender1031> so it basically expects reciprocal useof the colon 20161010 19:58:54< celticminstrel> "self" will always be "var" unless you do something silly like "var.blah(other_var, a, b)". 20161010 19:59:07< celticminstrel> In that case "self" would be "other_var". 20161010 19:59:38< DeFender1031> though if i define "function var:blah(a, b)" and then call "var.blah(otherVar, a, b)" then var isn't actually seen by the function anyway. 20161010 19:59:47< DeFender1031> heh 20161010 20:00:00< DeFender1031> okay, have i mentioned that i think lua is a terrible language? 20161010 20:00:33< DeFender1031> this semicolon syntax is basically a shortcut that only works if you use it consistently, and otherwise means something entirely different. 20161010 20:00:59< DeFender1031> it also seems as though in 1.12 the order is ai, cfg, self 20161010 20:01:13< DeFender1031> which means that this colon thing would NOT be correct. 20161010 20:01:25< celticminstrel> Indeed. 20161010 20:01:38< DeFender1031> alright then 20161010 20:02:16< DeFender1031> (though, even in 1.13, i'd not use the colon thing, as it strikes me as messy and misleading) 20161010 20:03:16< DeFender1031> so i think i understand how to structure these functions, now it's just a matter of figuring out what to actually put inside them. 20161010 20:06:28-!- knotwork_ [~markm@99.192.88.35] has joined #wesnoth 20161010 20:06:28-!- knotwork_ [~markm@99.192.88.35] has quit [Changing host] 20161010 20:06:28-!- knotwork_ [~markm@unaffiliated/knotwork] has joined #wesnoth 20161010 20:07:29-!- knotwork [~markm@unaffiliated/knotwork] has quit [Ping timeout: 258 seconds] 20161010 20:09:16< DeFender1031> It's really surprising actually that self is bound at call time, not at define time. 20161010 20:09:50< DeFender1031> Like, I'd expect "function something:func()" to bind func's self to always be something. 20161010 20:13:57-!- knotwork__ [~markm@99.192.76.212] has joined #wesnoth 20161010 20:14:20-!- knotwork_ [~markm@unaffiliated/knotwork] has quit [Ping timeout: 260 seconds] 20161010 20:20:27-!- wario__ [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 20:24:11-!- wario_ [~wario_@unaffiliated/wario] has quit [Ping timeout: 250 seconds] 20161010 20:25:10< mattsc> DeFender1031: I am back, on and off. Let me know if you have questions about AI behavior or so. 20161010 20:25:39< mattsc> I’m not going to get into discussions about syntax and the like because a) I don’t know and b) I don’t care. ;) 20161010 20:25:54< DeFender1031> mattsc, managed to figure out the structure, now tryng to read through the code example you sent me to try to figure out what it's doing 20161010 20:26:08< mattsc> Sounds good. 20161010 20:26:19< DeFender1031> mattsc, yeah yeah, you non-CS types are all the same. ;P 20161010 20:26:30< mattsc> Indeed. :) 20161010 20:26:57-!- knotwork__ [~markm@99.192.76.212] has quit [Ping timeout: 240 seconds] 20161010 20:31:40-!- root_____ [~root@159.203.13.106] has quit [Quit: WeeChat 1.4] 20161010 20:34:38< celticminstrel> DeFender1031: That wouldn't have the desired effect though. 20161010 20:34:50< DeFender1031> celticminstrel, what wouldn't? 20161010 20:35:10< celticminstrel> When used in a metatable, "self" generally shouldn't be bound to the table that actually contains the function. 20161010 20:36:34< DeFender1031> so you define it one way and call it a different way? That makes the syntax make even less sense. 20161010 20:37:48< DeFender1031> how does it even get called then? 20161010 20:38:13-!- ChipmunkV [~vova@static-89-94-113-91.axione.abo.bbox.fr] has quit [Quit: ChipmunkV] 20161010 20:44:18< celticminstrel> local mt = {}; function mt:blah(a, b) end; local var = {}; setmetatable(var, mt); var:blah(a, b); 20161010 20:47:27< DeFender1031> wait... now i'm confused as to what a metatable is. 20161010 20:48:08< DeFender1031> is it like a prototype in js? 20161010 20:48:44< celticminstrel> Kinda. 20161010 20:49:20< DeFender1031> ah, so the instance passed as self is NOT the same as the table on which the function is defined. 20161010 20:49:38< DeFender1031> and in fact, there may be multiple "self"s, depending how many objects are created with this metatable 20161010 20:49:54< celticminstrel> Yeah. 20161010 20:50:11< celticminstrel> It's not the table the function is defined on but rather the one it's called through. 20161010 20:50:53< DeFender1031> what does setmetatable actually do though? does it just copy all of mt to var, or is it doing some other kind of magic? 20161010 20:51:19< DeFender1031> or does it do a "if this key isn't there, then use this" thing? 20161010 20:51:23< celticminstrel> It doesn't copy it. 20161010 20:51:31< celticminstrel> Actually my example isn't quite right. 20161010 20:51:47< celticminstrel> The function would be defined in an __index table in the metatable. 20161010 20:52:35< DeFender1031> i'm lost again 20161010 20:53:33< DeFender1031> but i want to understand 20161010 20:53:56< DeFender1031> what would a correct example be? and what's this __index thing? 20161010 20:58:03< celticminstrel> local mt = {__index = {}}; function mt.__index:blah(a,b) end; 20161010 20:58:07< celticminstrel> The other half is the same. 20161010 20:58:40< celticminstrel> The members of the metatable are used to override operators; the __index member in particular represents the element access operator, and can be either a function or another table. 20161010 21:04:26< DeFender1031> ah, and if it's a function then it takes the key being accessed and returns a value 20161010 21:04:37< DeFender1031> which is how the wml tags metatable is set up 20161010 21:04:49< DeFender1031> (i had been wondering about that.) 20161010 21:05:09< celticminstrel> Yup. 20161010 21:05:19< celticminstrel> I think the key is passed as the second parameter to the function, but yes. 20161010 21:05:27< DeFender1031> what else can be in a metatable other than __index, and what do those other keys do? 20161010 21:05:30< celticminstrel> (The first parameter would be the actual table it was called on.) 20161010 21:05:33< DeFender1031> what's the first then? 20161010 21:06:22< celticminstrel> Well, anything can be in the metatable. Some are used to overload operators (like __le, __lt, __add, __concat, etc), some are used by core functions (such as __tostring) to customize behaviour. The __gc member is a finalizer. 20161010 21:06:35< celticminstrel> There's also __newindex which is called when adding a new key to the table. 20161010 21:06:41< celticminstrel> (It's never called if the key is already present.) 20161010 21:06:51< celticminstrel> There's a list of them in the Lua reference docs. 20161010 21:08:33< DeFender1031> oh, cool! 20161010 21:08:49< DeFender1031> erm... i mean... i still hate lua. 20161010 21:08:52< DeFender1031> :P 20161010 21:09:06< DeFender1031> (though having operator overloads is certainly nice) 20161010 21:10:29< DeFender1031> so basically you're telling me that this ca object that one creates for custom AI stuff gets passed as the __index for the metatable of the actual object being used for a specific round of AI evaluation, and it goes from there. Fascinating. 20161010 21:12:53< celticminstrel> Well, in those cases there actually is no metatable, so it's the table itself that's passed, but in theory, yes, that could happen. 20161010 21:13:18< celticminstrel> That ca object is used as-is by the engine. 20161010 21:13:32< celticminstrel> It could have a metatable, if you wanted it to. 20161010 21:13:42< celticminstrel> Not much reason to do so in this case, I think. 20161010 21:13:45< DeFender1031> ah 20161010 21:13:49< DeFender1031> well that's good to know 20161010 21:13:55< DeFender1031> so there IS only one instance 20161010 21:14:20< DeFender1031> i thought so at the beginning, but then when you explained metatables i realized that's not necessarily true 20161010 21:14:51< DeFender1031> meaning, for all i know from the example, it's creating hundreds of instances which each have their own .data member 20161010 21:15:17< DeFender1031> (in which case my version c wouldn't work even if written correctly) 20161010 21:15:30< DeFender1031> but if there's only one instance, version c would work 20161010 21:15:41< celticminstrel> Oh, I see what you mean. 20161010 21:15:54< DeFender1031> though now that i understand this, it's probably safer to use .data just in case it's changed in the future to have multiple instances or whatever. 20161010 21:16:07< celticminstrel> It uses wesnoth.require(), so there's only one instance. 20161010 21:16:25< DeFender1031> i don't mean one instance of the file scope 20161010 21:16:42< DeFender1031> i mean one instance of a table with these functions on it 20161010 21:17:04< celticminstrel> Well, it doesn't do anything with the returned table except call functions on it. 20161010 21:17:07< DeFender1031> even if there were multiple instances of the file scope, each would get its own set of locals so it'd be fine 20161010 21:17:17< DeFender1031> right, i understand that 20161010 21:17:37< DeFender1031> whatever, i'm talking about a case that isn't what actually happens, based on my new understanding of metatables 20161010 21:18:40< DeFender1031> meaning, if whatever included the custom CA lua called setmetatable on multiple things, instead of just passing what it got back around verbatim, then using the closure method would be invalid as it'd be using one set of variables to track what should be multiple instances. 20161010 21:18:52< celticminstrel> Right. 20161010 21:19:02< DeFender1031> and if that doesn't make sense thne just forget it, because i'm pretty sure i understand and that's not actually what happens anyway 20161010 21:19:38< DeFender1031> but the point is, i now understand IN THEORY what the difference between using self and using closures would be. 20161010 21:20:30-!- wario_ [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 21:22:11< DeFender1031> whew, my brain is tired. 20161010 21:24:05< DeFender1031> oh, celticminstrel, one other question, what, if anything, does setting a random key on a metatable do? For example, if my metatable was { something = "thing", __index = whatever }, "__index" would use whatever to access elements, but what, if anything, does "something" do? 20161010 21:24:21-!- wario__ [~wario_@unaffiliated/wario] has quit [Ping timeout: 248 seconds] 20161010 21:25:47< DeFender1031> oh, and last thing, If a table has its metatable set using a __index function, and then that table has some member explicitly set to something, will accessing that member return the result of __index, or what was explicitly stored? 20161010 21:25:51< celticminstrel> It won't do anything, though it could be used by other metafunctions if they have some way to access the metatable. 20161010 21:26:06< DeFender1031> alright 20161010 21:26:18< celticminstrel> The __index and __newindex metafunctions are used only when a key does not already exist in the table. 20161010 21:26:24< DeFender1031> (though i'd again just use local functions in the defining scope for that) 20161010 21:26:57< DeFender1031> __newindex is the setter version of __index's getter, i assume? 20161010 21:26:58< celticminstrel> So, if that table has some member explicitly set to something, then accessing that member will not invoke the __index function. 20161010 21:27:00< celticminstrel> Yes. 20161010 21:28:03< DeFender1031> interesting... so one could bork other lua code by setting a bunch of common members of wml_tags_metatable to "haha" 20161010 21:28:07< DeFender1031> oh, actually, no 20161010 21:28:13< DeFender1031> that's created from a function, isn't it? 20161010 21:28:21-!- claymore [~claymore@unaffiliated/claymore] has quit [Quit: Leaving] 20161010 21:28:50< celticminstrel> Um, it might be possible. I'm not quite sure. 20161010 21:29:00< celticminstrel> But I don't think it would affect other code. 20161010 21:29:09< DeFender1031> yeah, just checked. 20161010 21:29:26< celticminstrel> What would affect other code is if you fiddled with the __index or __newindex members of the metatable. 20161010 21:29:29< DeFender1031> it creates a new table instance, so you'd only bork stuff that used the instance you yourself created. 20161010 21:29:45< celticminstrel> But the metatable ideally should have a __metatable element to prevent that. 20161010 21:29:51< DeFender1031> right, though it doesn't seem like one would have access to that 20161010 21:30:16< DeFender1031> the metatable has a metatable? 20161010 21:30:38< celticminstrel> Well, if __metatable is not present in the metatable, then you can call getmetatable(wesnoth.set_wml_tags_metatable{}) to get the metatable, and then do whatever you want to it. 20161010 21:30:53< celticminstrel> Potentially changing its behaviour throughout Wesnoth code. 20161010 21:30:58< DeFender1031> wait, you can gain direct access to the metatable from a child? 20161010 21:31:08< DeFender1031> that's... icky. 20161010 21:31:15< celticminstrel> Yes, but the __metatable element prevents that - if present, getmetatable() returns that instead of the actual metatable. 20161010 21:31:35< DeFender1031> which you should use if your metatable ought to be compartmentalized. 20161010 21:31:49< celticminstrel> Something like that. 20161010 21:31:54< DeFender1031> like {__metatable = "Nice try, doofus!", __index = whatever} 20161010 21:32:07< celticminstrel> Most of the internal metatables used by Wesnoth set it to a descriptive string. 20161010 21:32:09-!- can-ned_food [~me@pool-71-253-116-81.eriepa.dsl-w.verizon.net] has joined #wesnoth 20161010 21:32:18< celticminstrel> So eg getmetatable(some_unit) returns the string "unit". 20161010 21:32:39< DeFender1031> i'm actually looking at the tag metatable code now. It doesn't seem to set that. 20161010 21:32:43< DeFender1031> (At least in 1.12) 20161010 21:33:08< DeFender1031> I actually don't see any of these setting it. 20161010 21:35:17-!- zookeeper [~lmsnie@wesnoth/developer/zookeeper] has quit [Ping timeout: 240 seconds] 20161010 21:36:38< DeFender1031> what is the first parameter passed to __index? 20161010 21:36:54< celticminstrel> "self" 20161010 21:37:41< DeFender1031> and that's automatic without any of the colon stuff from earlier? 20161010 21:39:21< celticminstrel> It applies equally for colon syntax, dot syntax, and bracketed syntax, I think. 20161010 21:39:47< celticminstrel> In the case of colon syntax, __index would be used to look up the function which is then called via the colon expansion. 20161010 21:40:14< DeFender1031> ahhhhh 20161010 21:40:22< DeFender1031> that makes sense 20161010 21:41:40-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has quit [Ping timeout: 260 seconds] 20161010 21:46:57-!- Kranix [~magnus@x1-6-74-44-01-e4-f1-52.cpe.webspeed.dk] has quit [Quit: Konversation terminated!] 20161010 22:00:50-!- edaq [~edaq3@h184-60-58-252.cytnin.broadband.dynamic.tds.net] has joined #wesnoth 20161010 22:20:40-!- wario__ [~wario_@unaffiliated/wario] has joined #wesnoth 20161010 22:22:11-!- Blukunfando [~bkf@90.77.79.239] has joined #wesnoth 20161010 22:24:32-!- wario_ [~wario_@unaffiliated/wario] has quit [Ping timeout: 260 seconds] 20161010 22:59:47-!- wario__ [~wario_@unaffiliated/wario] has quit [Quit: Leaving] 20161010 23:06:13-!- vultraz [~chatzilla@wesnoth/developer/vultraz] has joined #wesnoth 20161010 23:56:07-!- can-ned_food [~me@pool-71-253-116-81.eriepa.dsl-w.verizon.net] has quit [Quit: Konversation terminated!] --- Log closed Tue Oct 11 00:00:21 2016