--- Log opened Tue Aug 14 00:00:02 2018 20180814 00:00:50-!- mattsc [~mattsc@wesnoth/developer/mattsc] has joined #wesnoth-umc-dev 20180814 00:36:42<+wesdiscordbot> How would I go about using an era as a dependency if I wanted to use.. for example, its custom units 20180814 00:37:07<+wesdiscordbot> would I just add these additions to the _main.cfg? [binary_path] path="data/add-ons/Obscured_Folklore_Era" [/binary_path] ... [units] {~add-ons/AFriendshipTested/units} {~add-ons/Obscured_Folklore_Era/units} [/units] 20180814 00:37:33<+wesdiscordbot> yes 20180814 00:37:45<+wesdiscordbot> if you want to add it to the _server.pbl file 20180814 00:38:08<+wesdiscordbot> you need to add a dependencies = ... line 20180814 00:38:15<+wesdiscordbot> e.g. dependencies="Genesis_Resources" 20180814 00:39:43<+wesdiscordbot> I did add that to, but whenever I try to use a unit from the era, it doesn't recognize them. 20180814 00:39:51<+wesdiscordbot> so I was thinking I may have forgotten something 20180814 00:41:12<+wesdiscordbot> https://pastebin.com/DpunKvrf 20180814 00:41:16<+wesdiscordbot> that's my _main.cfg 20180814 00:59:51<+wesdiscordbot> so under the units/ directory in your era 20180814 00:59:54<+wesdiscordbot> are there more directories 20180814 00:59:58<+wesdiscordbot> or are they all in units/ 20180814 01:02:06<+wesdiscordbot> basically you must do what is done in the _main.cfg, except hings like the textdomain 20180814 01:04:56<+wesdiscordbot> (the _main.cfg of the folklore era) 20180814 01:10:43<+wesdiscordbot> there are indeed more folders 20180814 01:11:34<+wesdiscordbot> {~add-ons/Obscured_Folklore_Era/units} 20180814 01:11:40<+wesdiscordbot> what this does is add all the files in the units/ directory 20180814 01:11:48<+wesdiscordbot> but it will not go into any subfolders 20180814 01:12:04<+wesdiscordbot> also 20180814 01:12:08<+wesdiscordbot> if your units have any custom abilities 20180814 01:12:13<+wesdiscordbot> you will need to add them as well 20180814 01:12:30<+wesdiscordbot> Hmm I see 20180814 01:12:30<+wesdiscordbot> thank you 20180814 01:12:42<+wesdiscordbot> mhmm 20180814 01:13:46<+wesdiscordbot> these Dwarven Chariots will be glorious 20180814 01:14:01<+wesdiscordbot> 😮 20180814 01:14:22<+wesdiscordbot> maybe you can do some sort of ride of the rohirrim thing with them 😉 20180814 01:14:37<+wesdiscordbot> HAHAHA 20180814 01:14:38<+wesdiscordbot> heck yea 20180814 01:18:24<+wesdiscordbot> hmm you have both difficluties= and a [difficulty] tag – you need only the later. Or, use the CAMPAIGN_DIFFICULTY macro 20180814 01:28:05-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 01:28:11-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 01:37:24-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 01:37:30-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 02:26:56-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 02:27:02-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 02:48:57-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 02:49:03-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 03:07:10-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 03:07:16-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 03:43:24-!- mattsc [~mattsc@wesnoth/developer/mattsc] has quit [Quit: So long and thanks for all the fish.] 20180814 04:20:30-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 04:20:36-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 06:58:57-!- zookeeper [~lmsnie@wesnoth/developer/zookeeper] has joined #wesnoth-umc-dev 20180814 12:02:00-!- sevu [~sevu@p548559DE.dip0.t-ipconnect.de] has joined #wesnoth-umc-dev 20180814 12:27:34< sevu> vn971, you can use helper.child_count for the unit_count_specials function 20180814 12:27:52< sevu> It's one of the new things from 1.13 20180814 12:40:45< vn971> sevu: it'll be even more lines of code though? Currently, I count tag names by storing them into a map (string -> number). If I use "child_count", I'll be forced to hardcode all possible tag names(?). 20180814 12:46:37< sevu> I think this https://bpaste.net/show/01671ee8464e can be replaced by result = helper.child_count(helper.child_array(attack, "specials") 20180814 12:46:44< sevu> ) 20180814 12:48:16< sevu> [whole, unmodifeid, function https://bpaste.net/show/951b7d28db26 ] 20180814 12:55:43< vn971> sevu: https://wiki.wesnoth.org/LuaWML:Variables#helper.child_count 20180814 12:55:43< vn971> > Returns the number of children in the config with the given tag name. 20180814 12:55:49< vn971> _with the given tag name_. 20180814 12:56:34< sevu> I got just a number as return value 20180814 12:56:41< vn971> So if I provide a tag name "berserk", I'll indeed get what I want. But the function only works if you provide any tag. 20180814 12:56:57< vn971> sevu: yes exactly, you get a number. My function should return a map, however. 20180814 12:57:34< vn971> map like { berserk = 1, plague = 2} 20180814 12:58:26< sevu> I see, then that won't do 20180814 12:58:41< vn971> The type of the function `unit_count_specials` is `unit_name` -> `map[string -> number]` 20180814 12:59:06< sevu> from the function name I assumed you wanted to know only the number 20180814 12:59:45< vn971> sevu: indeed, makes sense. 20180814 13:13:19-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 13:13:25-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 13:36:24-!- hk238 [~kvirc@unaffiliated/hk238] has joined #wesnoth-umc-dev 20180814 13:36:39< hk238> hi 20180814 14:05:51< sevu> Hi 20180814 14:23:41<+wesdiscordbot> Is there a way I can make a unit not have a Zone of Control (besides making them level 0) 20180814 14:28:41< sevu> yes, @Fairy setting zoc=no 20180814 14:31:00<+wesdiscordbot> I did not expect it to be that easy. Thanks! 20180814 15:18:29-!- hk238 [~kvirc@unaffiliated/hk238] has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/] 20180814 15:27:24-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 15:27:30-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 16:18:27-!- hk238 [~kvirc@unaffiliated/hk238] has joined #wesnoth-umc-dev 20180814 17:40:35-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 17:40:41-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 17:50:12-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 17:50:18-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 18:08:35-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 18:08:40-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 18:17:40-!- hk238 [~kvirc@unaffiliated/hk238] has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/] 20180814 18:32:23-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 18:32:29-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 19:16:05-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 19:16:11-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 19:50:45< sevu> vn971, would you like to look over my lua code? 20180814 20:31:04-!- zookeeper [~lmsnie@wesnoth/developer/zookeeper] has quit [Ping timeout: 256 seconds] 20180814 20:41:28< vn971> sevu: sure. 20180814 20:42:11< vn971> sevu: but don't forget to mention review type if that'll not be obvious: quality review, mistakes review, finding any bugs etc. Which one. 20180814 21:00:49< sevu> cool. I wondered about if the iterator variables are not local, and if some things can be loaded earlier, e.g. the "helper" function 20180814 21:01:06< sevu> Guess that would be wordened as quality review 20180814 21:01:17< sevu> mistakes and bugs should be gone 20180814 21:01:51< sevu> oh, and if there are code style sins… 20180814 21:01:57< sevu> https://github.com/sevu/Col/blob/main/macros/upgrade.cfg#L113-L153 20180814 21:02:29<+wesdiscordbot> > wordened 20180814 21:03:26<+wesdiscordbot> That's not an English word fyi. 20180814 21:03:46< sevu> 's/en//' 20180814 21:08:46< vn971> sevu: one small thing before I dig into it. Does your editor support Lua highlighting in *.lua files? 20180814 21:10:30< vn971> sevu: if yes, you can benefit from that. 1. Copy-paste the code to a Lua file. 2. write this at file start -- << Enhancement 3. write this at file end -- >> 4. include your Lua file contents into WML by using code={./enhancement.lua} 20180814 21:11:02< vn971> 4. or by using code={~add-ons/your_name/your_file.lua} if you prefer absolute paths. 20180814 21:16:01< vn971> line 117. If you always pass non-null variables into the function, you may avoid these lines. I know they were there in my own code that I pasted, but I did that so that function call would not need change. Since you changed it anyway (and it's good), feel free to remove those. 20180814 21:19:18< vn971> most important comment so far: you can avoid passing "attack_set" around. The reason for that is... the exact usage, and the fact that Lua arrays are mutable. See, when you pass an array into the function, it never changes the reference. It points to the same array. Your input (attack_set) is what you return at last line. 20180814 21:19:41< vn971> this makes assignment at line 130 unneeded: https://github.com/sevu/Col/blob/main/macros/upgrade.cfg#L130 20180814 21:22:10< vn971> though actually that's a subtle remark. But to highlight the fact that your code is in fact mutable, I'd go with the following: 20180814 21:22:10< vn971> 1. accept an array as argument as you do now 20180814 21:22:10< vn971> 2. don't return it, only mutate. Change line 130 to only mutate (don't do assignment). 20180814 21:22:10< vn971> 3. to use the function, declare a local variable first `local attack_set = {}`, then pass this reference to mutating function `search_unit_types(...,..., attack_set)`, then access the mutated `attack_set`. 20180814 21:22:38< vn971> Actually I'm not sure you need this. Can as well leave as is. But since you mentioned "style" overview as well, I'm mentioning it. 20180814 21:23:42< vn971> Oh and by the way, this variable can as well be named "result" or something like that. Otherwise it's hard to tell what's going on. Function is named "search_unit_types", which would ideally return a list of unit types or something like that. But it instead mutates `attack_set`. Something's gotta be fixed in naming. 20180814 21:23:50< sevu> When writing I didn't kown that it was using a reference... so, that gould go 20180814 21:24:54< sevu> I wondered about renaming it to "forsee_future" 20180814 21:26:10< sevu> The idea how you load the files is neat 20180814 21:26:28< vn971> On the last lines. I think you can beautifully work around the problem of clearing (resetting) a variable if you use code like this: 20180814 21:26:28< vn971> wesnoth.set_variable("...", count >= 2) This will set it to true OR false. 20180814 21:28:28< vn971> so actually, you might end up with smth like: 20180814 21:28:28< vn971> local is_non_standard = count == 1 and (not attack_set["melee"]) and (not attack_set["ranged"]) 20180814 21:28:28< vn971> wesnoth.set_variable("...", count == 2 or is_non_standard) 20180814 21:30:31< sevu> that cuts it down from 7 lines o.O 20180814 21:33:34< sevu> for line 117: it is still needed, because the call in line 137 doesn't work the way it looks. The empty arguments (these are tables, right?) given to the function are nil in the actual function 20180814 21:34:14< sevu> And in the first start of the recursion there is no value to put 20180814 21:34:24< vn971> ? 20180814 21:34:43< sevu> search_unit_types(this_unit, {}, {}) 20180814 21:34:53< vn971> you start it first here: https://github.com/sevu/Col/blob/main/macros/upgrade.cfg#L137 so you DO input something. 20180814 21:35:14< sevu> the function will assume it got only one argument, not three 20180814 21:35:30< vn971> will if you write what? 20180814 21:36:01< sevu> the {} arguments do nothing in fact, they don't initialize 20180814 21:36:10< vn971> but they do... 20180814 21:36:17< sevu> search_unit_types(this_unit, {}, {}) is the same as search_unit_types(this_unit) 20180814 21:36:22< vn971> they give you an empty array as input. 20180814 21:36:27< vn971> in the current code, yes. 20180814 21:36:48< vn971> if you remove lines 117 118 as I suggested, it'll start to matter. 20180814 21:37:40< sevu> Ahhh 20180814 21:40:43< vn971> BTW if the considerations about "mutable code" and "mutable arrays" feels too complicated, you can actually leave this part in the way you have it now. I just have habits of pure functional languages at times, but it's not always helpful in Lua. 20180814 21:40:57< vn971> other parts would be nice to fix tho. 20180814 21:46:57< sevu> I understood the part with mutable too :) 20180814 21:48:27< sevu> at the end of the [/lua] block, will all lua variables be revoked? e.g. non-local variables? 20180814 21:49:27< vn971> hmm? Behavior is identical. 20180814 21:49:41< vn971> WML engine literally inlines your Lua file to where WML was. 20180814 21:50:41< sevu> identical to what? 20180814 21:51:02< vn971> This all mostly helps only if you have good editor though (at least syntax highlight). Mine also supports global variable access detection, has jump-to-definition etc (but it's heavyweight, I'm not recommending it). 20180814 21:51:32< vn971> I mean identical results if you copy paste into WML or write it in a separate file. 20180814 21:52:19< vn971> Since this all is inside [command]... I think it'll be re-evaluated each time? Not 100% sure. It depends on WML (and I know few of it). 20180814 21:53:42< sevu> yes, so far so clear. The part I wonder is .... the WML und LUA don't have the same environment, they have both their own variables. Will the lua environment be cleaned up and removed ad the end of the tag, or do I join the same environment when anohter [lua] tag is used 20180814 21:54:49< vn971> sevu: Lua "global" environment resists until you re-load the game. Any "local" declarations are fully lost when you exit [lua] body. 20180814 21:55:09< vn971> Lua and WML always have the same view on what is stored in which WML variables. 20180814 21:55:58< vn971> if you ever used `my_global_var = 12` in Lua code, it'll remain for all future accesses of said global variable. 20180814 21:56:16< vn971> including in different events. 20180814 21:56:51< sevu> are the variables defined in the for loops as well global? 20180814 21:56:52< vn971> In contrast to WML variables, however, it is lost if you re-load the game. 20180814 21:57:23< vn971> sevu: if you accidentally forget to write `local` before first declaration, then yes. Your code has no single global variable yet. 20180814 21:57:41< sevu> for _, type in ipairs(possible_advancements) do 20180814 21:58:02< sevu> ^ would "type" be a göobal variable here? 20180814 21:58:04< vn971> `for _, type` will only declare this stuff inside the `for` loop 20180814 21:58:14< sevu> I'm glad =) 20180814 21:59:15< vn971> it's no problem anyway I think. Even if you'd, theoretically, declare stuff globally accidentally, you won't eat up all RAM anyway. Because if you do it again, you'll store new data on the same global variable. And the old reference will get lost and will be garbage-collected by Lua engine automatically. 20180814 22:00:49< vn971> though you can get seriously messed up if you use a global like "is_ok", and it'll work just fine until it'll conflict with a totally different add-on that used same global variable name with different purpose.) 20180814 22:01:17< sevu> and the _ variable, does it has more payoff besides that the prson reading knows that he doesn't need to remember the name? 20180814 22:01:38< vn971> So personally, I only declare global variables with names like `creepwars_my_name` or `creepwars = {} creepwars.test = 1` 20180814 22:02:46< vn971> sevu: it's a conventional way to mark that your variable won't be used, that's all. 20180814 22:02:46< vn971> Important note: it's controversal. Some Lua developers prefer or preferred in past to use `_` as a valid function name which would translate a string. 20180814 22:03:02< vn971> * I mean some **wesnoth** Lua developers. 20180814 22:03:23< sevu> uhhh there you mention something... 20180814 22:03:34< sevu> I run wmlxgettext over these files... 20180814 22:04:18< vn971> Personally, I can't accept wesnoth practice, I refuse it totaly. So if I need the translate function, I call it `translate`. And I use `_` the way it's mainstream in the Lua community overall (non-wesnoth). 20180814 22:04:19< sevu> I may be that the script does regard the wml files only as text files, and simly searches for _ 20180814 22:04:30< vn971> wmlxgettext won't make a difference. It can't parse Lua, I think. 20180814 22:05:13< vn971> opinions from more experienced WML people and/or people knowing wmlxgettext would be very valuable! ^^ 20180814 22:05:17< sevu> It finds translatable strings in both lua and wml, but it does at least not preprocess wml 20180814 22:05:17< vn971> -^ 20180814 22:05:41< vn971> you're pretty sure it finds in Lua as well? 20180814 22:06:47< sevu> I never tried as I never had lua files around, but when I started with it someone mentioned to not forget to read the lua files, so probably it does 20180814 22:08:08< vn971> https://wiki.wesnoth.org/LuaWML#Examples uses the underscore a lot. This is how underscore is defined for these cases: _ = wesnoth.textdomain "wesnoth-tutorial" 20180814 22:10:57< vn971> ok, feel free to make your own opinion on this. I laid out the facts. // I personally won't give up my underscore for translation no matter what, but luckily it's add-on-specific. 20180814 22:11:05< sevu> I guess the worst thing that can happen would be wmlxgettext crashing 20180814 22:11:33< sevu> And that could be easily worked around by not parsing that single file 20180814 22:12:09< sevu> Though, I wouldn't wonder if it takes care of that too… It are quite some line of code 20180814 22:12:43< sevu> I know the _ part from when I had to do with haskell, it's quite neat 20180814 22:16:46< vn971> ah, if you did haskell, it's no surprise you got my worries on "mutable/immutable". :) 20180814 22:19:44< sevu> Didn't do too much though, a bit more than lua 20180814 22:21:08< sevu> IIRC I would need to pass attack_set around when doing it in haskell, as there are no sideeffects 20180814 22:27:56< vn971> yes, you'd need to. Also you'd need to merge arrays at some step. 20180814 22:28:44< vn971> AFK. 20180814 22:44:08-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has quit [Remote host closed the connection] 20180814 22:44:14-!- janebot [~Gambot@unaffiliated/gambit/bot/gambot] has joined #wesnoth-umc-dev 20180814 23:54:57-!- mattsc [~mattsc@wesnoth/developer/mattsc] has joined #wesnoth-umc-dev --- Log closed Wed Aug 15 00:00:03 2018