|
I'm trying to convert my current knowledge form JS and Python Into Lua and it's hard, I have a few questions.
PLEASE try to answer one for me if you can't answer all of them.
1. How do you make a object or array in Lua?
2. Whats the boolean? Ex: || && !
3. How does the local and global variables work? Can a local variable made in something like a function be used outside the function but not outside the script?
4. Is a object orientated structure possible?
5. Is there a way I can change the text size inside the script? It's really annoying me.
|
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
I cannot answer all your questions but i can answer these:
1. Arrays are formed as this:
Array = {
[Index] = [Value]
}
2. A boolean has two values(True,False) Sort of like saying True is Yes and no is false.
3. Global variables are globally scoped so they can be used anywhere sort of the same with local if i am correct. |
|
|
## local part = Instance.new("Part", game.Workspace) local array = ### ## ## ## ### ### ## Not exactly sure what you mean. Lua uses "or", "and" and "not" keywords. "==" > compare variables, "=" > assign values, "~=" > does not equal, ">=" "" greater than and smaller than, the first 2 are including the value itself. 3) A local variable can not be used outside of the function. 4) To an extent, others are probably able to explain this better. 5) No idea, it's the perfect size for me. |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
4. This is possible due to mertatables: http://wiki.roblox.com/index.php?title=Object-Oriented_Programming
5. You can zoom in with mouse scroll
(Sorry it was seperated) |
|
|
|
Thanks!
Its odd '&&' is called 'and' though. Maybe its just me.
I'll keep looking to see if Lua has object oriented. But thanks a-lot both of you. |
|
|
Ah mouse scroll is text size XD |
|
INOOBE_YTJoin Date: 2014-02-08 Post Count: 5067 |
The operators are and, or, ~=, =, ==
|
|
|
Wait, wait, wait what is ~=?
Is the not equal to? or not strictly equal? |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
is Not equal to |
|
|
NikkulaiJoin Date: 2014-06-01 Post Count: 946 |
It is basically not equal oto For examples: ### # # ###### Statement ### ## # ###### Statement 6-2 = 8 --False Statement Its basically used just to check if something is not true. |
|
|
search learnxinyminutes and look up Lua
it should provide the basic knowledge that you need to start out in lua.
read the everything up until the end of modules because everything beyond that pretty much is not relevant to roblox lua
|
|
|
3. local variables are available only inside of the scope they are created
variable = true
local localVariable = false
local otherVariable = 1
function thing()
local localVariable = "nope"
otherVariable = 2
print(localVariable) ---> nope
local aSpecialVariable = "cant access me"
diffVar = true
end
thing()
print(localVariable) ---> false
print(otherVariable) ---> 2
print(aSpecialVariable) ---> nil
print(diffVar) ---> true
4. yes, absolutely. there are examples on the lua website and on the roblox wiki
5. yes, file -> settings -> studio -> scroll down to script editor
|
|
|
1. Instance.new("InstanceType")
2. true, false. to answer your question it's or, and, not.
do not touch the "not" to the boolean, i.e. not true is correct.
if (a || b && !c) {
console.log("hello")
}
if a or b and not c then
io.write("hello") --you will have to use print with roblox.
end
local variables go like
local function hello()
local variable = true
end
the script can't access "variable" because it is outside of the scope.
oop is possible yes
ctrl and + twice or ctrl + scroll wheel
if (dev.ShouldLearnNewLanguage){dev:LearnJS()} |
|
|
...
wiki.roblox.com
Lua is my moon, Java is my coffee, Pascal is my dad, C++ is my grade, Ruby is my jewelry, php is my site 😎😎 |
|
KapKing47Join Date: 2012-09-09 Post Count: 5522 |
1. local array = {} or local object = Instance.new('ObjectName').
2. and, or, not, >=, <=, ==.
3. Local variables cannot be used outside the scope that they are declared in. To share a variable across scripts (Only server-server and client-client though) u can use _G.VariableName = Value.
4. Metatables I guess.
5. In Studio settings I think. Or just zoom in by ctrl+mouse scroll.
|
|
KapKing47Join Date: 2012-09-09 Post Count: 5522 |
2. Whoops, forgot to add ~=.
|
|
TaaRtJoin Date: 2009-04-26 Post Count: 5070 |
4. Is a object orientated structure possible?
As far as I am aware, it never gets truly object-oriented under the hood; you can edit the Lua source files, using xml objects the way ROBLOX does. In behavior metatables can be used to recreate classes in almost any aspect, but deep down they're not the same as a virtual function table which is what I believe defines a language as OO (but if I'm wrong please do tell) |
|
LaeMVPJoin Date: 2013-06-24 Post Count: 4416 |
[1] = by object did you mean userdata? if so you could make your own using metatables and nexproxy
[2] = or, and, not
[3] = scope
[4] = *yes*
[5] = go into settings and change it |
|