HiddenCoders
Welcometo the HiddenCoders forum!

Please log in for additional features, such as posting, replying, and reciving advanced support.

Thank you for visiting out site!
Log in

I forgot my password

Top posting users this week

Latest topics
» Bugreport #0002 (in progress)
Fri Jan 24, 2014 2:19 am by Wolf

» Bugreport #0003 (Solved)
Fri Jan 24, 2014 2:18 am by Wolf

» Server Managment Fees
Wed Jan 22, 2014 12:10 am by Wolf

» Server Managment!
Wed Jan 22, 2014 12:04 am by Wolf

» [3] Valuable Variables
Fri Jan 03, 2014 2:50 am by Wolf


[2] Basics

Go down

[2] Basics

Post by Wolf on Fri Jan 03, 2014 2:37 am

So you decided to continue? Great!

Now you should be able to have a few things. Don't forget to have your console opened in garry's mod, as this will be your best and only debugging tool to find out, what is wrong with your future awasome script
Click -->here<-- to learn how to open console.
You'll also need to be playing on a map to use scripts.

So! Let's get to actual scripting!

The first thing you wan't to do, is to use your Notepad++ to type this, single line:

Code:
print("My first script runs great!")

Now, let me explain:

print
is a function, that runs everything that it's should (see functions), using the arguments.
The arguments this time is a string. You specify a string by putting it between "" quote marks. If you forgot to do so, it'll seem like a variable (see variables here), and it'll mess up your work. A string is a plain text, a given amount of numbers, letters, and almost anything you put in it.

print
function takes only one argument. All arguments must be put after the function's name, and in brackets.

print(argument)


print() does nothing, except prints the given data (aka argument, arg) to the console.

So let's type in

Code:
print("My first script runs great!")

to our notepad, and save it as basic_lesson.lua to the garrysmod/garrysmod/lua folder.
The name is fully whatever, but it is highly recommended to avoid spaces, numbers in it. .lua extension is required at all time in a script.

Start a single-player gameplay in any map (recommended gm_flatgrass), and open console.
Your first lua based console command should be:
lua_openscript basic_lesson.lua
.
This will load the script to the world.
Enter the command above, and you should get the output in your console, that says

My first script runs great!

in your console. It was easy right?

Let's move to the third lesson by clicking here.

If you have any questions, or problems, just comment below.
avatar
Wolf
Team Member
Team Member

Hozzászólások száma : 30
XP : 1959
Reputation : 0
Join date : 2013-10-09

View user profile http://hiddencoders.hypeforum.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum