Play Forumz!
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Welcome Fun-Cravers and all!
 
HomePortalGallerySearchLatest imagesRegisterLog in

 

 ROBLOXian Lua Guide (Incomplete right now)

Go down 
2 posters
AuthorMessage
ihaveamac
Whisperer
Whisperer
ihaveamac


Number of posts : 37
Age : 26
Mood :
ROBLOXian Lua Guide (Incomplete right now) Left_bar_bleue50 / 10050 / 100ROBLOXian Lua Guide (Incomplete right now) Right_bar_bleue

Registration date : 2009-05-12

Special Info
Rewards: Great Advisor/Mentor
Infractions: N/A

ROBLOXian Lua Guide (Incomplete right now) Empty
PostSubject: ROBLOXian Lua Guide (Incomplete right now)   ROBLOXian Lua Guide (Incomplete right now) EmptyFri Jul 03, 2009 1:50 pm

I put in a [ code] for a reason
Code:
----A ROBLOXian Lua guide by Ian (ihaveamac)
----This guide contains not everything that Lua in ROBLOX can do.
--Simple addition
answer = number + number

----FUNCTIONS
--Simple
function something(lol)
if lol == 1 then
   --do something
   end
end
something(1)

---Clicking
function IWASCLICKED()
--Your stuff goes here.
end
script.Parent.ClickDetector.MouseClick:connect(IWASCLICKED)

---Touching
function iwastouched(hit)
--What happens when something is touched? You decide.
end
script.Parent.Touched:connect(iwastouched)

---New Player
function YesssANewPersonCame(TheNewPlayer)
--What you do matters. Put the stuff you want to happen here.
end
game.Players.ChildAdded:connect(YesssANewPersonCame)

--There are waayyyy more functions, but these are the basic ones.

--Is it me or do I see a bug on my screen?

----LOOPS
---The simple forever
--WARNING: USING THE while true do WITH NO wait(number) WILL RESULT IN A ROBLOX CRASH.
while true do
wait(number) --This must be the first thing in the while true do
--Put the...You know.
end

---Forever IF something is true
while --[[SOMETHING]] do
wait(number) --This also has to be here.
--Z0MG HAX 2 DO UR STUF U WANT 2 DO
end

---The more advanced loops
--If you've used Scratch, you might know what this means.
for i = 1, 53478560347 do --Goes up 1 unless you do 'for i = 9000, 90000, 30 do' will go up every 30 numbers
wait(number) --If it's the first thing that happens in the script, keep this line, otherwise you can remove it.
--You know what to do.
end
--You can use 'i' (or anything else you put there) in the script.

--A loop that you should not do:
function something(something)
--
end
something()
--This is the same as 'while true do' and will also lag your place.

----OTHERS
---String operations
--I don't know all of them.
string.lower(thing) --Returns the 'thing' in lowercase
string.upper(thing) --Returns the 'thing' in UPPERCASE
string.sub("thing",1,2) --Returns the letters through 1 and 2 --Output for that would be 'th'
string.sub("thing",3) --Returns the letter 3 and the letters after 3. --Output for that would be 'ing'
string.find("thing one", "thing two") --All I know is it retuns it's position and how many letters.
---Math operations
--I don't know all of these too.
math.pi --Returns Pi. It will return: 3.1415926535898
math.random(1, 9000) --Returns a number between 1 and 9000.
math.random() --Retuns any number.

--That's it for now.
Back to top Go down
ihaveamac
Whisperer
Whisperer
ihaveamac


Number of posts : 37
Age : 26
Mood :
ROBLOXian Lua Guide (Incomplete right now) Left_bar_bleue50 / 10050 / 100ROBLOXian Lua Guide (Incomplete right now) Right_bar_bleue

Registration date : 2009-05-12

Special Info
Rewards: Great Advisor/Mentor
Infractions: N/A

ROBLOXian Lua Guide (Incomplete right now) Empty
PostSubject: Re: ROBLOXian Lua Guide (Incomplete right now)   ROBLOXian Lua Guide (Incomplete right now) EmptyTue Jul 07, 2009 3:20 pm

Code:
------Part 2------

----EXAMPLE SCRIPTS
---Kill-on-touch brick
function touch(hit) --When "touch" is called, hit defines the thing that touched the brick.
local human = hit.Parent:findFirstChild("Humanoid") --Looks for a humanoid.
if human ~= nil then --If there is a humanoid...
   human.Health = 0 --IT GETS OWNED!
   end
end
script.Parent.Touched:connect(touch) --Calls "touch" then the brick is touched.
---Simple commands
--This kind is from the wiki, only I edited it to make it work. This kind of script MIGHT not work...though you might be lucky.
vip = "YourNameHere" --Put your name in here, if you want only one person to use the commands.
function chatted(msg, speaker) --When chatted is called...
local smsg = string.lower(msg)
local source = speaker.Name
local ssource = string.lower(source) --The 3 lines; this one and the other 2 above. That's how I do it with commands. lol.
if smsg == "hi" then --If the message in lowercase is hi, then...
   local mes = Instance.new("Message") --This creates a new Message.
   mes.Parent = game.Workspace --Sets the message's 'parent' to the workspace.
   mes.Text = "Hello!" --Sets the message's text.
   wait(2) --Waits 2 seconds.
   mes:remove() --Removes the message!
   end
end
--Now we're not done yet. It's not the simple thing.something:connect(lol)
function playerentered(player)
if string.lower(player.Name) == string.lower(vip) then --If you want anyone to use the commands, remove this line.
   player.Chatted:connect(function(msg) chatted(msg, player) end) --This type is really different.
   end --If you removed the if checking if the player is the vip, then remove this line too.
end
game.Players.ChildAdded:connect(playerentered)

--I'm bored. *does moonwalk for the 20th time*

---Tables
--This each item on a table
IAMATABLELOL = {"Hello!", "Moonwalk", "lol", "ihaveamac"} --The 'table'
for i = 1, #IAMATABLELOL do --The statement #IAMATABLELOL tells the number of items in that table. This thing would start from 1, to the number of items in the table.
msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = IAMATABLELOL[i] --The statement IAMATABLELOL[i] tells the item in the position. In this case, i is the position.
wait(2)
msg:remove()
end
--There.
--This is a ban script.
banned = {"noob", "weirdo", "ihatealltheplacesinthewordwhyaminthisworldofalltheplacesihatelolxd"}
function newplayer(p)
for i = 1, #banned do
if string.lower(p.Name) == string.lower(banned[i]) then
   p:remove() --Whoops! The player is gone!
   return --WARNING: Without this, the script will NOT work. You MUST have this.
   end
end
end
game.Players.ChildAdded:connect(newplayer)

--That's it for now. Sorry it's a bit short...
Back to top Go down
Mayu
Community Princess
Mayu


Number of posts : 295
Age : 25
Location : Sydney
Mood :
ROBLOXian Lua Guide (Incomplete right now) Left_bar_bleue2 / 1002 / 100ROBLOXian Lua Guide (Incomplete right now) Right_bar_bleue

Registration date : 2009-04-25

Special Info
Rewards: Treasured Helper
Infractions: N/A

ROBLOXian Lua Guide (Incomplete right now) Empty
PostSubject: Re: ROBLOXian Lua Guide (Incomplete right now)   ROBLOXian Lua Guide (Incomplete right now) EmptyTue Jul 07, 2009 3:23 pm

its k queen
Back to top Go down
ihaveamac
Whisperer
Whisperer
ihaveamac


Number of posts : 37
Age : 26
Mood :
ROBLOXian Lua Guide (Incomplete right now) Left_bar_bleue50 / 10050 / 100ROBLOXian Lua Guide (Incomplete right now) Right_bar_bleue

Registration date : 2009-05-12

Special Info
Rewards: Great Advisor/Mentor
Infractions: N/A

ROBLOXian Lua Guide (Incomplete right now) Empty
PostSubject: Re: ROBLOXian Lua Guide (Incomplete right now)   ROBLOXian Lua Guide (Incomplete right now) EmptyMon Jul 13, 2009 11:07 pm

Code:
------Part 3------
----IF STATEMENTS
--[[If equal signs
less than: <
greater than: >
equals: ==
not equals: ~=]]
---Simple 'if's with variables
variable = 0 --Sets a new variable to 0. In this case, it's name is variable.
if variable == 0 then --There must be 2 == in an if statement.
   print("YAY! VARIABLE IS 0!!") --Checks if the variable is 0.
   end --Ends the if.
---'if else' statement
variable = 0 --Sets a new variable to 0. In this case, it's name is variable.
--Why did I repeat that line? lol
if variable == 0 then --Is it 0?
   print("Variable is 0.")
else
   print("Variable is NOT 0.")
   end
--Did you get that thing?
---More 'if's
thing = 1337
if thing == 1337 then
   print("thing is LEET")
elseif thing == 9000 then
   print("thing is 9000!!!!!!!!!!")
else
   print("thing is not LEET or 9000!!!!!.")
   end
--There's an elseif in there.
----VARIABLES
--I know I used these earlier.
--3 Types: Numbers, Strings, and Bools.
---Global and Local Variables
--A Global Variable is a variable that anywhere of the script can be used.
--A Local Variable is a variable that can only be used in the area it was made in.
--Global Variables start like this:
var-name = 0
--Local Variables start like this:
local var-name = 0
--A common thing used in Lua is this kind:
local thing = thing
--The Local Variable "thing" is being set to the Global Variable "thing".
---TYPE ONE: Numbers
--Numbers. Easy.
thing = 1337
--But wait! It can be set to another variable too!
thing = variable2
--LOL!
---TYPE TWO: Strings
--A string is text.
s = "This is a string."
--Strings can be combined with others.
n = 57438906543
s = "This is a string. n is "..n.."!!!"
---TYPE THREE: Bools
--Bools. True and false
thing = true
anotherthing = false
--So you got it, right?

--Looks like that is it for now.
Back to top Go down
Sponsored content





ROBLOXian Lua Guide (Incomplete right now) Empty
PostSubject: Re: ROBLOXian Lua Guide (Incomplete right now)   ROBLOXian Lua Guide (Incomplete right now) Empty

Back to top Go down
 
ROBLOXian Lua Guide (Incomplete right now)
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Play Forumz! :: Other Stuff :: Garbage :: Websites Section :: Video Gaming Websites :: Roblox :: Roblox Lua Codes Board-
Jump to: