| | ROBLOXian Lua Guide (Incomplete right now) | |
| | Author | Message |
---|
ihaveamac Whisperer
Number of posts : 37 Age : 26 Mood : Registration date : 2009-05-12
Special Info Rewards: Great Advisor/Mentor Infractions: N/A
| Subject: ROBLOXian Lua Guide (Incomplete right now) Fri 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. | |
| | | ihaveamac Whisperer
Number of posts : 37 Age : 26 Mood : Registration date : 2009-05-12
Special Info Rewards: Great Advisor/Mentor Infractions: N/A
| Subject: Re: ROBLOXian Lua Guide (Incomplete right now) Tue 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... | |
| | | Mayu Community Princess
Number of posts : 295 Age : 25 Location : Sydney Mood : Registration date : 2009-04-25
Special Info Rewards: Treasured Helper Infractions: N/A
| Subject: Re: ROBLOXian Lua Guide (Incomplete right now) Tue Jul 07, 2009 3:23 pm | |
| its k | |
| | | ihaveamac Whisperer
Number of posts : 37 Age : 26 Mood : Registration date : 2009-05-12
Special Info Rewards: Great Advisor/Mentor Infractions: N/A
| Subject: Re: ROBLOXian Lua Guide (Incomplete right now) Mon 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. | |
| | | Sponsored content
| Subject: Re: ROBLOXian Lua Guide (Incomplete right now) | |
| |
| | | | ROBLOXian Lua Guide (Incomplete right now) | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Statistics | We have 18 registered users The newest registered user is cielo_wii
Our users have posted a total of 1149 messages in 186 subjects
|
Who is online? | In total there are 9 users online :: 0 Registered, 0 Hidden and 9 Guests None Most users ever online was 229 on Sat Oct 02, 2021 11:55 pm |
Poll | | What should this forum domain become? | .societyforum.net | | 50% | [ 5 ] | .forumslife.com | | 10% | [ 1 ] | .online-talk.net | | 10% | [ 1 ] | other (please type as post) | | 30% | [ 3 ] |
| Total Votes : 10 |
|
Latest topics | » Corrupt a WishMon Nov 09, 2009 10:24 am by Dark Guardian» The World of White - Written By "Adora"Thu Nov 05, 2009 12:11 pm by hobomctyler» Food AppearanceMon Oct 19, 2009 3:37 am by Dark Guardian» 10-Word SentenceTue Oct 13, 2009 3:23 am by Dark Guardian» 15-Word SentenceMon Oct 12, 2009 4:42 am by Mayu» Riddle RulesMon Oct 12, 2009 4:38 am by Dark Guardian» 20-Word SentenceSat Oct 10, 2009 11:44 am by Dark Guardian» Dark Guardian's Friend Code roomThu Aug 27, 2009 12:36 pm by Dark Guardian» Unscramble The Word!Thu Aug 27, 2009 3:09 am by Dark Guardian» 7-Letter WordThu Aug 27, 2009 3:02 am by Dark Guardian |
May 2024 | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|
| | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | Calendar |
|
|