Monkey Frog Studio Posted August 12, 2018 Share Posted August 12, 2018 Hello. I am fairly new to programming (been an artist all my life) and am learning from the Leadwerks Tutorial on LUA scripting. All is pretty simple to understand in principle, but I am struggling to understand this one example from Function Arguments: function PrintUpper(text) print(string.upper(text)) end PrintUpper("Functions can be fun.") The actual code in the function, print(string.upper(text)) ... what is going on there? I get "print" and I get "string", but what is "upper" in this case? Actually, a little help understanding what is going on here overall would be a big help. The other ways of using/declaring functions seem to make sense to me, but this one is eluding me for some reason. Any help would be appreciated. Thanks. Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio Link to comment Share on other sites More sharing options...
Josh Posted August 12, 2018 Share Posted August 12, 2018 5 minutes ago, Argent Arts said: Hello. I am fairly new to programming (been an artist all my life) and am learning from the Leadwerks Tutorial on LUA scripting. All is pretty simple to understand in principle, but I am struggling to understand this one example from Function Arguments: function PrintUpper(text) print(string.upper(text)) end PrintUpper("Functions can be fun.") The actual code in the function, print(string.upper(text)) ... what is going on there? I get "print" and I get "string", but what is "upper" in this case? Actually, a little help understanding what is going on here overall would be a big help. The other ways of using/declaring functions seem to make sense to me, but this one is eluding me for some reason. Any help would be appreciated. Thanks. string.upper is a Lua command that converts text to upper case: http://lua-users.org/wiki/StringLibraryTutorial They just put the "upper" function onto a table called "string" in order to categorize all the string commands together. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted August 12, 2018 Share Posted August 12, 2018 Make it a leadwerks system print and you will be able to see the results in the script editor: System:Print(string.upper(text)) Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Monkey Frog Studio Posted August 12, 2018 Author Share Posted August 12, 2018 Ah! Thanks. What confused me was "upper" because the function name also contained "Upper" (though with a capital. Even though LUA is case sensitive, I was seeing the same thing when I read it. I understand this function now. Duh! Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio Link to comment Share on other sites More sharing options...
Monkey Frog Studio Posted August 12, 2018 Author Share Posted August 12, 2018 Just a suggestion (and I hope you don't mind), but since the tutorial is aimed at non-programmers, it might be good to go into a little more explanation on things. For example, it might be good to have pointed out that things like "string.upper" is a LUA command and what it does. Even clarifying some things like explaining that the name, like MyFunction, can be any name, like how you name a variable however you choose. You sort of do this, but a little more would be helpful to complete newbs to programming. 1 1 Quote Creating professional 2D and 3D content is my passion! Monkey Frog Studio Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.