Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if your used to spellcast these are the things that are different in gearswap
- 1. Lua has 3 primary types of values
- String --strings can contain both capitol letters, lower case letters and numbers but thay must be surrounded by eather '' or ""
- example:
- "test"
- 'test'
- 'Test'
- 'tesT'
- 'test 999'
- Boolean --booleans only have 2 values true and false
- example:
- true
- false
- Number --these represent a numerical value and can include . and 0-9
- example:
- 9
- 99
- 999
- 99.99
- 2. Lua does not use varables it uses nested-tables iterators and values
- example:
- table1 ={}
- table1.table1b = {}
- table1.table1b.table1c = {}
- tables are located by <tablename>.<iterator> == <value>
- example1:
- table1 = {fire=true}
- when looking for the boolean that fire has you would use
- table1.fire = true or table1.fire
- example2:
- table1 = {}
- table1.table1b = {fire=true}
- when looking for the boolean that fire has you would use
- table1.table1b.fire = true or table1.table1b.fire
- when creating a table you can nest them as deap as you want
- Example1:
- weaponskill = {
- element = {
- Transfixion={
- Fire = {
- neck="Light Gorget",
- waist="Light Belt"
- },
- },
- },
- }
- the above can also be done like this
- Example2:
- weaponskill = {}
- weaponskill.element = {}
- weaponskill.element.Transfixion = {}
- weaponskill.element.Transfixion.Fire = {}
- weaponskill.element.Transfixion.Fire.neck = "Light Gorget"
- weaponskill.element.Transfixion.Fire.waist = "Light Belt"
- the reason i seporate my thoughts on tables in to nested-tables, iterators and values is because when you look at the 2 tables above to get the value of "Light Gorget"
- you need to look in the table weaponskill.element.Transfixion.Fire then check the iterator neck to get the value "Light Gorget"
- but written in to lua it will just look like weaponskill.element.Transfixion.Fire.neck = "Light Gorget" but the layout is always the same
- <table>.<iterator> = <value>
- also you must remember that every level of a table must be split with a . to denote the next layer
- now if your not using a nested-table like the above
- Exanple:
- a = 1
- b = true
- c = 'value'
- this is still a table but because we do not need to look in a higher table to find our iterator we can just use <iterator> = <value>
- 3. Advanced string building
- when using a string value you have a choice between using '<string>' and "<string>" but there are some things you need to know
- when using a string and your string includes another "or' it will cause an error
- Example:
- "How are you" --correct
- 'How are you' --correct
- "How "are" you" --incorrect
- 'How 'are' you' --incorrect
- string do have special characters for use the specific situations like \
- Example:
- "How \"are\" you" --correct
- 'How \'are\' you' --correct
- "How 'are' you" --correct
- 'How "are" you' --correct
- also when building a string you can use an iterators value to build the string
- example:
- a = 'hello'
- b = 'goodbuy'
- "Someone said "..a == 'Someone said hello'
- "Someone said "..b == 'Someone said goodbuy'
- this can also be done with numbers and booleans but a little more is needed
- example:
- a = true
- b = 999
- "Someone said "..tostring(a) == 'Someone said true'
- "Someone said "..tostring(b) == 'Someone said 999'
- 4. Basic math on numbers only
- when trying to do math in lua you nee to use specific characters
- - --subtraction
- + --addition
- / --division
- * --multiplication
- Example:
- 1 + 1 = 2
- 2 - 1 = 1
- 1 * 1 = 1
- 2 / 1 = 2
- 2 * 2 + 4 - 2 / 3 = 2
- if you want to specify specific parts to be done first you need to use ()
- Example:
- 2 * 2 + 4 - (2 / 3) = 7.333333333333333
- 2 * (2 + 4) - 2 / 3 = 3.333333333333333
- 5. Lua works in an if-then/elseif-then/else/end sequence block and to trigger thay must be true
- if-then --only one of these (required)
- elseif-then --as many of these as you need (optional)
- else --only one of these (optional)
- end --only one of these (required)
- Example 1(if true,elseif true):
- if true then
- --the code here will be used
- elseif true then
- --the code here will not be used
- end
- Example 2(if false,elseif true):
- if false then
- --the code here will not be used
- elseif true then
- --the code here will be used
- end
- Example 3(if false):
- if false then
- --the code here will not be used
- else
- --the code here will be used
- end
- You can also nest sequence blocks
- Example(if true,second if true):
- if true then
- if true then
- --the code here will be used
- end
- --the code here will be uses as well
- else
- --the code here will not be used
- end
- if you want to do 2 separate things you can use multiple sequence blocks
- Example(if true,second if true):
- if true then
- --the code here will be used
- else
- --the code here will not be used
- end
- if true then
- --the code here will be uses as well
- else
- --the code here will not be used
- end
- 6. Lua has special commands for some things
- local - makes the given variable local to function and or sequence block instead of making it a global variable
- return - stops processing further code in the function
- if you want to return something to a previous function you can
- Example:
- local <variablename> = testcode()
- function testcode()
- if true then
- return <variable>
- end
- end
- 7. Info about rules
- I will add to this at a later date.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement