#Lua Basics #1 - Basic syntax, Variables and Basic Functions!

1 messages · Page 1 of 1 (latest)

winter holly
#

Welcome!

Today you going to learn functions, variables and basic syntax in lua Lua!

Syntax

If you know Python, you will learn Lua very easy,
All because similar syntax in these languages.

Also, cubzh adding some extra rules in Lua for world scripts.

We can write comments in code (in end of the line type -- and any text)

Variables

Variables is a thing that stores value, that can be changed

To create variables in Lua we need this simple code:

variable_name = variable_value

Variable name should start with English lowercase letter
Variable can store all value types that Lua have, here's a list of all:

Value types:
• Number - any number (Example: 5, 5.2)
• String - Text value, should be in " " (Example: "SysFAB")
• Functions - Code parts that can be called later (In next part)
• Tables - Multifunctional type (In next lessons)
• Boolean - true and false, only lowercase
• nil - nothing, default value of any variable, only lowercase

Let's create our first variable!

text = "Hello, world!"

Also we can do math operations with some variables, like:

c = 15 + number_b

If number_b be will be a number, c will be 15 + number_b

Basic functions

Function - Code part that can be called later

In Lua we have some starting functions:

print(value) -- Prints value in game chat

And many others.

Also we can create own functions:

cube = function(x)
  return x*x*x
end

When we creating function, we write arguments for it inside function( here )

return its a keyword that returns value.
If we return something, function will be stopped

If we not writing return keyword, function will return nil in end

This is our cube function, it just a variable, but now we can call it:

a = cube(3)
print(a) -- Prints 27 in chat

Thanks for reading this lesson
Next lesson: #1134008017550049360

formal field
#

only "number" type

winter holly
formal field
#

there are only one type

fallen roost
winter holly
fallen roost
#

what

#

does that mean

winter holly
#

you creating function

#

that runs when client starts the game

winter holly
fallen roost
#

?

winter holly
#

Syntax, Variables, Basic functions

#

this is lesson 1

fallen roost
winter holly
#

fully read tutorial

fallen roost
fallen roost
winter holly
winter holly
fallen roost
winter holly
#

@cedar dragon

winter holly
fallen roost
winter holly
#

steam?

#

epic games?

fallen roost
#

ye

#

steam

winter holly
#

build 123?

fallen roost
#

wdym

winter holly
#

last version

fallen roost
cedar dragon
#

@fallen roost thanks for the report.
when it crashed , Windows showed you a popup ?

winter holly
#

create ticket in help

cedar dragon
#

🤔

#

hum

winter holly
cedar dragon
#

thx

fallen roost
winter holly
#

or you have DirectX 11?

cedar dragon
#

it shouldn't be a GPU issue since the app started alright

fallen roost
winter holly
#

RMB cubzh

#

go to properties

cedar dragon
#

@fallen roost have you tried to create a game again ? does it crash every time ?

fallen roost
winter holly
#

type here --opengl and try again

winter holly
fallen roost
#

but i prefer english

winter holly
#

свойства - параметры запуска и напиши туда --opengl

#

try this

#

if not working, record this and send it

fallen roost
#

why does it take like 20 minutes to load

winter holly
#

cubzh or world?

fallen roost
#

it says loading scripts...

winter holly
#

its fine xd

fallen roost
#

ok i have win 10 pro

winter holly
fallen roost
winter holly
#

can you call me rn?

fallen roost
#

it just load for veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long time

winter holly
#

your internet speed is fine?

fallen roost
winter holly
#

it needs to be minimum 10 mbits/sec

#

i tested

winter holly
#

megabits

#

its ~1-2 megabytes per second

fallen roost
#

20.42 download mbps

winter holly
fallen roost
#

19.44 upload mbps

fallen roost
winter holly
#

ok

#

i loaded

fallen roost
winter holly
fallen roost
#

when idk

#

just randomly closed

#

around the time you said i loaded

winter holly
#

when loading script?

fallen roost
winter holly
#

can you call me rn? you can show me screen

fallen roost
#

call rn

winter holly
#

ok

#

then try to join other world

fallen roost
# winter holly ok

cubzh when i show my screen is displayed by black reactangle with white rectangle

fallen roost
winter holly
#

same?

fallen roost
winter holly
#

can you try on your phone?

#

to test if its your network

#

you can download Cubzh from Play Market or TestFlight for IOS

fallen roost
#

and it lags like insane

fallen roost
winter holly
fallen roost
#

wdym

winter holly
#

you are using wi-fi or 4g?

fallen roost
#

wifi

winter holly
#

try to switch to 4g

fallen roost
winter holly
#

oh ok

#

try to use vpn on pc, i think something with your internet provider

fallen roost
winter holly
#

script is maximum 50kb file

fallen roost
winter holly
#

you have normal internet speed but it can't download and game just crashes

#

@cedar dragon if script request will be declined game will crash?

fallen roost
#

ill wtch some cat videos better

#

or play gmod

winter holly
#

ok, sorry for this situation, i hope soon it will be fixed

#

(im not dev tho)

cedar dragon
winter holly
winter holly
#

in cubzh we have number and integer

#

try yourself

#

with the type() function