Time Nick Message 01:22 ball I feel like it's going to take me a while to tunnel back from -7000 at -32 but it's better than trying to hack my way through the jungle trees. 02:34 ball join #bikes 02:34 ball oops 03:33 Icalasari Hey. Been told my indenting sucks and it's hiding errors from me. Issue is... I can't figure out what is wrong with my indenting and I can't find any good guides on indenting. Could somebody please either look at my indenting and help explain to me so I can avoid such mistakes, or point me to a good guide on how to properly indent since my Google 03:33 Icalasari skills are failing me on this? 03:37 ball Icalasari: I don't code for Minetest but I'm willing to have a look at some code if you have an example handy. 03:37 Icalasari Self teaching Lua by modding for SRB2 was a mistake I swear to god XD I probably have SO many bad practices 03:37 Icalasari Thanks Ball 03:37 ball brb 03:37 Icalasari I need to go find the snippet anyways so that'll take a minute or two 03:39 Icalasari https://pastebin.com/JDhCLVWv 03:45 ball I don't know lua but I'm willing to have a look. 03:46 Icalasari Thanks 03:46 Icalasari Posted the pastebin there 03:47 ball Trying to match up some brackets, now... 03:54 Icalasari I hope it isn't too horrendous 03:55 ball It might be awesome. Like I said, I don't know lua. I used to code, years ago though, so I'm having a crack at it. 04:00 ball I seem to have two or three stray 'ends" and a couple of stray closing braces at the end. 04:01 ball Ah wait, I probably misnested your elseifs. 04:01 Icalasari Ah crap over copied, the }) and end right after that map to an earlier snippet of the code 04:02 ball Hang on, I'll paste what I have... 04:02 Icalasari Thanks again 04:03 ball Not sure whether those elseifs are supposed to be staircased... 04:04 ball http://grex.org/~ball/Icalasari.lua 04:05 ball ...and I used spaces where lua people probably use tabs, just to keep my editor sane. 04:05 ball How does it look? 04:07 Icalasari It looks great, I'm going to compare to my code to see what I can glean from how you indented it and learn from it so I can catch errors myself better in the future and indent better 04:07 Icalasari Thank you SO much 04:08 ball Like I said, I don't know lua so my assumptions may be off and that'll be reflected in my indenting. 04:08 ball Hope it helps though. 04:10 Icalasari Lua can be coded all on one line. The indenting is meant to help people organize it, so it will help a lot 04:10 Icalasari Also I still question the sanity of whoever made a language that can code a program all on one line 04:13 ball That's partly historical. When your source code comes in on a spool of paper tape, lines are for human convenience. 04:14 Icalasari Ah, so not so much sanity based as "Oh dear god I hate these limitations of the time" based 04:14 ball ...and carriage returns etc. used to get stripped out as whitespace (by the preprocessor?) as a first step towards making it digestable to the compiler 04:15 ball I think I prefer languages where whitespace (outside of quotes) has no meaning. It means I can arrange things for readability. 04:15 ball ...since it's not going to impact the object code in any case. 04:15 ball I think lua's interpreted, so perhaps that doesn't apply. 04:16 ball Thinking about some BASIC interpreters I used in the 8-bit era, only the really good ones let us indent code. 04:16 ball Some of the more constrained machines didn't. 04:22 Icalasari Still can't spot the error that I've been told was buried in the indenting, but it did finally click how to properly indent, so thank you again for that 04:26 ball You may have just learned how to indent like an old man. ;-) 04:27 Icalasari XD 04:27 Icalasari Hey, I'm 30 myself so I'm not a spring chicken anymore either 04:33 hedae[m] For most programming languages I recommend just using automatic formatters since it saves time trying to get everything formatted. 04:33 ball Good luck with your project, anyway. I'll sit in the comfy chair now and listen to the radiogram for a bit. 04:33 ball hedae[m]: That sounds like a good idea. I'm guessing there's one for lua? 04:35 hedae[m] ball: For Lua I use https://github.com/Tencent/LuaHelper 04:37 ball Thanks. I might feed it Icalasari's code to see what it thinks. 04:38 hedae[m] Icalasari: The main issues I've noticed in your code are that you've forgotten to close some blocks with end, and your if statements use "=" (assignment) instead of "==" (equality comparison) 04:39 ball Oooh, that'd break things. 04:41 Icalasari I'm not spotting which blocks I forgot to close (might be my newbiness in that regard). As for the ==, I was actually told I needed to use == for it (which... I did think a bit weird as they said it spits out a true/false statement but also can be used to make the variables the same, but they've been the closest thing I've have to a teacher on this 04:41 Icalasari so figured it was some other weird function) 04:42 ball o/ Goodnight 04:44 Icalasari Ciao, Ball, even though you can't see this XD 04:44 hedae[m] There's one missing end, which I assume would be inserted after line 30 to close the if statement on line 28. As for ==, it doesn't do assignment (that would just be =). What it does is it checks if the left and right hand sides are equal, that is, a == b checks if a and b are equal. 04:47 Icalasari ...Whelp, it WAS newbieness - Guess the people on the forum never considered that I may be misunderstanding how Return works and thinking it *could not have an end before it without breaking things* XD 04:47 Icalasari Goes to show, a newbie will always find a way to baffle an expert 04:48 Icalasari Gah, still having the unexpected symbol near local error 04:50 hedae[m] Could you share your updated file? 04:52 Icalasari https://pastebin.com/JDhCLVWv 04:52 Icalasari Error currently is 'then' expected near '=' on line 34. As for my use of tabs, it's easier on my own eyes ^^; 04:55 hedae[m] You need the double equals to do comparisons in if statements 05:01 Icalasari kk 05:03 Icalasari Now I'm confused. So I do need the == after all? 05:04 hedae[m] Yes. Essentially, you get a boolean by comparing two values with ==, then you can use that boolean as the condition of an if statement (for example, you probably want to check if melrot is 0, so you'd use if melrot == 0) 05:06 Icalasari Oh you are ki-_I mixed up where to put the == and somehow it didn't click once_ 05:15 Icalasari I really hope that's due to my insomnia else I have a feeling my coding adventures are going to be... Something 05:16 Icalasari Now it's not growing when it did before but I can look at an earlier version to likely deduce what I broke there. Thanks again for all the help 05:19 Icalasari ...Or like an idiot I forgot to save iterations between major changes 05:22 Icalasari Speaking of insomnia, should probably get some sleep. Night 10:40 ghoti BuckarooBanzai: I figured it out, I just had my luacontroller time test in the wrong place. :/ Should I submit my change as a PR, do you think? Might others want to proteect themselves from fast interrupts on luacontrollers too? 11:02 ghoti BuckarooBanzai: and while I'm at it, could you tell me if there is any standard way of documenting knobs that can be added to world.mt or a config file? I'm coming up short. 11:06 sfan5 settingtypes.txt is the standard way 11:37 ghoti Ah, I hadn't come across that yet! Thanks. 11:45 ghoti So .. when specifying "fload default/min/max", what if there is no real upper limit to be applied? Is that why I see 1000000 there in a few places? 11:57 ghoti What is limited when luacontroller_lightweight_interrupts==false? 12:03 ghoti I see that it uses a node timer instead of the "global action queue", I just don't know how that is significant. :) 12:09 BuckarooBanzai ghoti: node timers only run when a player is near or the area is forceloaded, the "global action queue" always runs (_everywhere_) 12:21 ghoti Does that mean that a luacontroller with interrupts functions as if it is near a world anchor, and never goes to sleep? 12:39 ghoti There we go, https://github.com/minetest-mods/mesecons/pull/621 12:40 ghoti My first minetest PR. :) 12:44 ghoti Oh bother, it even includes a typo. Fixed. 12:46 ghoti Meh, I will close and resubmit. 12:47 MTDiscord lol yeah just commented a few secs after you closed it 12:48 ghoti sorry about that. :/ 12:48 ghoti Other than the typo, did it look reasonable? 12:51 MTDiscord I just skimmed over it and you should probably wait for someone that knows Lua ? 12:55 calcul0n ghoti, i guess it should just emit a warning and adjust the time value instead of an error 12:55 calcul0n there's a send_warning function passed as param to get_interrupt for that 12:56 ghoti calcul0n: would a warning actually stop people from specifying low interrupt times though? 12:58 calcul0n no, but you can just adjust it yourself to themin value 12:58 calcul0n error would certainly stop them as it would crash the game :) 12:59 ghoti I think I'm not getting what you're saying.. my goal here is to stop the fast cycling on luacontrollers. How does a warning do that? 12:59 ghoti Where I placed the error, it shows up when the player presses "Execute" in the luacontroller. 13:00 ghoti Would a warning stop the code from being executed as well? 13:00 calcul0n a warning doesn't, modifying time yourself if necessary will 13:01 calcul0n ie if time < minvalue then send_warning(...) time = minvalue end 13:01 ghoti The line right before my edit was: `if type(time) ~= "number" then error("Delay must be a number") end` 13:01 ghoti Ah, I see. Yes, that would let existing luacontrollers continue functioning, though slower. 13:01 calcul0n yes 19:05 MTDiscord howdy ghoti 19:20 ghoti hi PrairieWind 19:27 ghoti Hey, could anyone help me learn from Desour's comment on https://github.com/minetest-mods/mesecons/pull/622 ? This works for the case I wrote it for, but presumably there are other ways luacontrollers can be exploited as high speed switches. How? 21:13 calcul0n_ ghoti, imho a comment saying "useless" with no explanation is just... useless :) 21:14 calcul0n_ even if there are other possible exploits your change would probably remove 99% of the abusive uses 21:32 Desour ghoti: I just saw your message in the logs. to answer your question: you can easily for example make a loop with diode gates from one luacontroller port to another one to get shorter delays 21:33 Desour or build some fast oscillator and connect it with a luacontroller 21:34 Desour if you want to avoid circuits oscillating with a high frequence, you can change the mesecons heat settings 21:35 Desour of course, this doesn't mean that one can not build lag machines with mesecons then 21:35 Desour (as one can still place many effectors next to each other and power all at once) 21:36 Desour mesecons should maybe try at some point to run its actionqueue steps over more than one server step each