FANDOM


This is the old version follow the link to go to the new version.

SIMPLE LUAEdit

Slightly revised version

  • Waiting
  • Redstone
    • Inputs
    • Outputs
  • Values
  • Functions And Arguments
  • loops

WaitingEdit

Well you've created an Infinite Loop, but when you ran it your program your Minecraft crashed? Well what do you do....

You add a sleep( double Value ) Well you will learn what a double Value is later but a simple Explanation is:

A number with a decimal.

RedstoneEdit

Well now you have a wait and a loop(I will teach you how to do a loop in loops)Edit

Now you want to edit redstone signals:

Outputs/Inputs
back
front
left
bottom
right
top


the back is the side behind the monitor

left is the left of the moniter

top is the top of the monitor

etc...

well theres 2 ways to call the redstone funtion

  1. rs()
  2. redstone()
Inputs: 

inputs are for when you want to do something when a redstone signal is read

so its redstone.getInput( side )
Outputs:
outputs are for when you want to set a redstone signal

so its redstone.setOutput( side, boolean )


If you want to get all the sides and test which is true you use :

redstone.getSides()

And for extra help

type

  • help programming
  • help api
  • help redstone

Values:Edit

There are mas

  1. Integers
  2. Booleans
  3. Tables
  4. Doubles
  5. Objects
  6. nil
  7. string


Now lets go into detail:

to define a value you need a name and a value

like this <Name> = <Value>

for a table you do <Name> = {<Value1>,<Value2>...etc}

without the <>

Integer : a single number like 1
Table: a collection of different data types
Double: a number with a decimal like 1.1
Boolean: a true or false value
Nil: nothing not even nothing

Objects: An object like a function

String: Text defined in between " TEXT HERE "

Functions And ArgumentsEdit

A function is code put in a special carrier to get differant values or call it over and over again
functions are called like function(args) Simular isn't it ? Yes, redstone.*() is a function
APIS are made out of many functions and values to work togeather
to make a function you need
function <name>(<args>)
-- code here
end

Logic and loopsEdit

logic is what makes computers work

Ever heard of IF gates?

If not its simple

if value1 == value2 then--if value1 equals value2 then

--code here

end

the logic operators are

put in the middle

theres greater than >

less than <

greater or equal to >=

less or equal to <=

not ~=

you can compare values and the same if statement

like and, or, not this goes like this

if v1==v2 and v3~=v4 then

end

if you want to do something if the condition is met and something else if its not then you add an else

if v1==v2 then

--code

else

--code

end

but what if you want 3 or more possibilitys?

then theres elseif

if v1 == v2 then

--code

elseif v1>v2 then

--code

else

--code

end




So when are we learning about Loops?


Well there are 2 mainly used loops

while loops

and

for loops


a while loop is a special kind of loop that repeats until its condition is met

so if you want an infanite loop

while true do
sleep(1)
end


but if you want a loop that stops



con = 5
met = 0
while met < con do
met = met+ 1
sleep(1)
print met
end



If you want to read a players action like for a password

you type

write "Enter Password: "-- this displays Enter Password: (and reads only past here)

a = read()-- allows an Input into the variable name a Which is a string


Well that covers it....

Sorry if it's messy





without the <>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.