• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Recent content by stetre

  1. stetre

    Windows I have no experience with lua; I would like some help with a neural net.

    To have some help you need someone that is familiar with Lua, and possibly with neural networks, and with that particular software. And, of course, that is willing to dedicate you some of their time. I'm sure you realize that the range of 'candidates' fullfilling all these implicit requirements...
  2. stetre

    How to Create a Thread which prints a word ervery 3 seconds in lua?

    That's fairly simple, with a few caveats (see below): local next_time = os.time() + 3 while true do if os.time() > next_time then print(string.format("[%d] Hallo", os.time())) -- print also the current time next_time = next_time + 3 end end The above code assumes that...
  3. stetre

    How to Create a Thread which prints a word ervery 3 seconds in lua?

    By 'thread' do you mean a coroutine, or are you just happy with a single threaded script that does this and nothing else?
  4. stetre

    Lists and such

    Yes, Lua (not an acronym) is a very minimal language and some do find it off-putting at first for this reason. But once you get the grasp of it, you really appreciate its minimality, believe me. As for how to implement data structures other than associative arrays (that's what tables are), you...
  5. stetre

    Lua is setting a valid table entire to nil

    Inconsistent variable names in the for loop. First you assign the values returned by pairs( ) to the names 'k' and 'v'. Then you reference them with the names 'key' and 'value' (the latter, being uninitialized, are nil).
  6. stetre

    How works _G and _ENV and what can I do with them?

    As I explained earlier, _G holds the global variables. In the second code, lookup_tom is local so there is no entry for it in _G. (I'm not sure I understood what you're trying to do. Still, I'd bet there is some way to do it without resorting to _G or _ENV.)
  7. stetre

    How works _G and _ENV and what can I do with them?

    What matters is the Lua version you're using. _ENV was introduced in Lua 5.2, if I recall correctly.
  8. stetre

    How come there are no table methods?

    According to the manual "By default, a value has no metatable, but the string library sets a metatable for the string type (see §6.4).". The table.insert function and its siblings that act on tables are just that: functions, not methods. You could turn them easily into methods for a specific...
  9. stetre

    Lua HTTP client

    See the doc in the repo, at luasocket/doc/http.html (unfortunately the online version no longer exists).
  10. stetre

    Lua HTTP client

    The de facto standard TCP/IP library for Lua is LuaSocket. It should also be available as a 'rock' (methink... not sure because I don't use LuaRocks).
  11. stetre

    How works _G and _ENV and what can I do with them?

    You can think of _ENV as a table that implicitly holds your global variables. For example, try running the lua shell and executing the following in it (here the > is the shell prompt): > x = "this is x" > print(_ENV.x) > _ENV.x = "this is _ENV.x" > print(x) You'll see that the value of...
  12. stetre

    Instance scripts?

    Concurrent programming is a very important topic, but also very interesting! You will surely encounter it often, since it comes up almost naturally in all sorts of situations. A related and partiallly overlapping topic is parallel programming, which is also very important (and interesting) and...
  13. stetre

    Instance scripts?

    I'm not familiar with CoreGames but I can easily guess the presence of _ENV, here, and of a concurrency model. These are programming models where you have similar entities running concurrently, each in its dedicated context, and possibly with mechanism to synchronize and communicate with each...
  14. stetre

    Is there a way to reffer a table itself inside the same table?

    I honestly don't know. My guess is that it shouldn't be very different, but of course if you are doing really heavy computations the differences could add up to the point of being relevant. To have a more precise idea you should do some measures. In my opinion, however, when you feel the need...
  15. stetre

    Is there a way to reffer a table itself inside the same table?

    They should be faster, but the comparison is meaningful only in the case that the table doesn't have a metatable, in which case they probably aren't that faster since the lack of a metatable is detected almost immediately. On the other hand, if the table has a metatable then their behaviour is...
Top