Jump to content

Learning Programming Question - Function Arguments Example in Tutorial


Monkey Frog Studio
 Share

Recommended Posts

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.

Creating professional 2D and 3D content is my passion!
Monkey Frog Studio

Link to comment
Share on other sites

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.

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

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. :)

  • Thanks 1
  • Upvote 1

Creating professional 2D and 3D content is my passion!
Monkey Frog Studio

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...