When starting a prototype file, before entering data:extend, simply add

Code: Select all
function beltplanner_item(type)
return {
type = "item",
name = "beltplanner-"..type,
icon = "__beltplanner__/graphics/beltplanner-"..type..".png",
flags = {"goes-to-quickbar"},
place_result = "beltplanner-"..type,
stack_size = 50,
}
end
data:extend({
beltplanner_item("basic"),
beltplanner_item("fast"),
beltplanner_item("express"),
beltplanner_item("end"),
})
I'd say "programming is amazing". The same approach is possible for almost all programming languages.prg wrote: Lua is amazing.
That is true. However, Lua being a scripting language (or, the proper term I suppose being, "interpreted language", more specifically a multi-paradigm, dynamically typed, interpreted language), it allows for this sort of thing to be typed up in Notepad and just plugged into the main program without any recompilation. It doesn't need includes for basic functions, doesn't need you to cast data types into one another, and generally simple to use. I know there are a lot of programming languages offering similar functions, but I'd say Lua is still, in itself, amazing.ArderBlackard wrote:I'd say "programming is amazing". The same approach is possible for almost all programming languages.prg wrote: Lua is amazing.
BTW I guess that Factorio uses LuaJIT which allows compiling Lua code for a great performance boost. Run-time interpretation usually is slowSean Mirrsen wrote: Lua being a scripting language (or, the proper term I suppose being, "interpreted language", more specifically a multi-paradigm, dynamically typed, interpreted language)
Can't say I 'hate' it, but I also prefer using statically typed languages. In my opininon the main (dis)advantage of Lua is that it is extremely simple in it's syntax (while not in power).prg wrote: I actually hate duck typing and that everything that does not exist is implicitly nil
If this would be of any help, you may try a JetBrains IntelliJ IDEA with Lua plugin. It does not provide as good refactoring/control possibilities as for other languages in IDEA (or like a ReSharper for respective languagesprg wrote:Refactoring Lua code is a nightmare, if you missed something somewhere it'll only blow up at run time even if such an error could be easily detected with static type checking.
Factorio doesn't use luajit, at some point the devs actually said it would be unnecessary (wtf?) but seems to be planned for 0.13 nowArderBlackard wrote:BTW I guess that Factorio uses LuaJIT which allows compiling Lua code for a great performance boost. Run-time interpretation usually is slow
I'd dare to say that there's quite a lot of complexity the devs did not realize the mod community would want to make.ArderBlackard wrote:Nice to hear it!Seems like the devs themselves didn't realize a complexity of the mods the community would try to implement
There's problems, and there's problems. Modders not having quite the same power as they could does not quite measure up to the magnitude of "problem" that a keylogger or trojan hidden in 5000 lines of elaborate filesystem-accessing code can create. Especially if you consider the devs as being a company with a public image.Lutra wrote:the devs have also removed the file system included with Lua. i guess it means security, but makes a lot of problems...
How do you get from basic file access to a trojan or keylogger? The lua api wouldn't have any way to run an executable, obviously.Sean Mirrsen wrote:There's problems, and there's problems. Modders not having quite the same power as they could does not quite measure up to the magnitude of "problem" that a keylogger or trojan hidden in 5000 lines of elaborate filesystem-accessing code can create. Especially if you consider the devs as being a company with a public image.
Lua is a programming language. Any programming language with filesystem access can be used to create malicious code, in one way or another. The OS is often all too happy to automatically run plain-text scripts placed in certain strategic locations, for instance.Zeblote wrote:How do you get from basic file access to a trojan or keylogger? The lua api wouldn't have any way to run an executable, obviously.Sean Mirrsen wrote:There's problems, and there's problems. Modders not having quite the same power as they could does not quite measure up to the magnitude of "problem" that a keylogger or trojan hidden in 5000 lines of elaborate filesystem-accessing code can create. Especially if you consider the devs as being a company with a public image.
You could limit file access to subfolders inside the game folder, then. No harm done creating malicious files if you can't run them.Sean Mirrsen wrote:Lua is a programming language. Any programming language with filesystem access can be used to create malicious code, in one way or another. The OS is often all too happy to automatically run plain-text scripts placed in certain strategic locations, for instance.Zeblote wrote:How do you get from basic file access to a trojan or keylogger? The lua api wouldn't have any way to run an executable, obviously.Sean Mirrsen wrote:There's problems, and there's problems. Modders not having quite the same power as they could does not quite measure up to the magnitude of "problem" that a keylogger or trojan hidden in 5000 lines of elaborate filesystem-accessing code can create. Especially if you consider the devs as being a company with a public image.
But hey that's what makes lua fun to code! Just type whatever comes to your head , not think about formal stuff.prg wrote:I actually hate duck typing and that everything that does not exist is implicitly nil. Causes way too many unnecessary errors which could easily be avoided with a proper type system that checks if a function is called with the right number of arguments etc. Refactoring Lua code is a nightmare, if you missed something somewhere it'll only blow up at run time even if such an error could be easily detected with static type checking.
I wasn't aware there was even a need to pass info from data to control. Isn't data just a hub for all the things you've got spread around the mod's folders, with some final fixes thrown in? Could you describe a use case, I'm actually curious.ArderBlackard wrote:UPD: At least it can solve the long-term problem of "Pass some info from data.lua to control.lua"
And yeah, I suppose that could work. Still probably wise to not even have a hint of a possibility of a security hole, but with sufficient control it could be "safe enough" at least.Zeblote wrote:You could limit file access to subfolders inside the game folder, then. No harm done creating malicious files if you can't run them.