Advertisement
smd111

spellcast to gearswap differences

Nov 12th, 2014
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.60 KB | None | 0 0
  1. if your used to spellcast these are the things that are different in gearswap
  2. 1. Lua has 3 primary types of values
  3.     String --strings can contain both capitol letters, lower case letters and numbers but thay must be surrounded by eather '' or ""
  4.     example:
  5.         "test"
  6.         'test'
  7.         'Test'
  8.         'tesT'
  9.         'test 999'
  10.     Boolean --booleans only have 2 values true and false
  11.     example:
  12.         true
  13.         false
  14.     Number --these represent a numerical value and can include . and 0-9
  15.     example:
  16.         9
  17.         99
  18.         999
  19.         99.99
  20.        
  21. 2. Lua does not use varables it uses nested-tables iterators and values
  22.     example:
  23.         table1 ={}
  24.         table1.table1b = {}
  25.         table1.table1b.table1c = {}
  26.     tables are located by <tablename>.<iterator> == <value>
  27.     example1:
  28.         table1 = {fire=true}
  29.     when looking for the boolean that fire has you would use
  30.         table1.fire = true or table1.fire
  31.     example2:
  32.         table1 = {}
  33.         table1.table1b = {fire=true}
  34.     when looking for the boolean that fire has you would use
  35.         table1.table1b.fire = true or table1.table1b.fire
  36.        
  37.     when creating a table you can nest them as deap as you want
  38.     Example1:
  39.         weaponskill = {
  40.                 element = {
  41.                 Transfixion={
  42.                         Fire = {
  43.                                 neck="Light Gorget",
  44.                                 waist="Light Belt"
  45.                                },
  46.                             },
  47.                           },
  48.                       }
  49.     the above can also be done like this
  50.     Example2:
  51.         weaponskill = {}
  52.         weaponskill.element = {}
  53.         weaponskill.element.Transfixion = {}
  54.         weaponskill.element.Transfixion.Fire = {}
  55.         weaponskill.element.Transfixion.Fire.neck = "Light Gorget"
  56.         weaponskill.element.Transfixion.Fire.waist = "Light Belt"
  57.    
  58.     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"
  59.     you need to look in the table weaponskill.element.Transfixion.Fire then check the iterator neck to get the value "Light Gorget"
  60.     but written in to lua it will just look like weaponskill.element.Transfixion.Fire.neck = "Light Gorget" but the layout is always the same
  61.     <table>.<iterator> = <value>
  62.    
  63.     also you must remember that every level of a table must be split with a . to denote the next layer
  64.    
  65.     now if your not using a nested-table like the above
  66.     Exanple:
  67.         a = 1
  68.         b = true
  69.         c = 'value'
  70.         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>
  71.        
  72. 3. Advanced string building
  73.     when using a string value you have a choice between using '<string>' and "<string>" but there are some things you need to know
  74.     when using a string and your string includes another "or' it will cause an error
  75.     Example:
  76.         "How are you" --correct
  77.         'How are you' --correct
  78.         "How "are" you" --incorrect
  79.         'How 'are' you' --incorrect
  80.     string do have special characters for use the specific situations like \
  81.     Example:
  82.         "How \"are\" you" --correct
  83.         'How \'are\' you' --correct
  84.         "How 'are' you" --correct
  85.         'How "are" you' --correct
  86.        
  87.     also when building a string you can use an iterators value to build the string
  88.     example:
  89.         a = 'hello'
  90.         b = 'goodbuy'
  91.         "Someone said "..a == 'Someone said hello'
  92.         "Someone said "..b == 'Someone said goodbuy'
  93.         this can also be done with numbers and booleans but a little more is needed
  94.         example:
  95.             a = true
  96.             b = 999
  97.             "Someone said "..tostring(a) == 'Someone said true'
  98.             "Someone said "..tostring(b) == 'Someone said 999'
  99.  
  100. 4. Basic math on numbers only
  101.     when trying to do math in lua you nee to use specific characters
  102.         - --subtraction
  103.         + --addition
  104.         / --division
  105.         * --multiplication
  106.     Example:
  107.         1 + 1 = 2
  108.         2 - 1 = 1
  109.         1 * 1 = 1
  110.         2 / 1 = 2
  111.         2 * 2 + 4 - 2 / 3 = 2
  112.        
  113.     if you want to specify specific parts to be done first you need to use ()
  114.     Example:
  115.         2 * 2 + 4 - (2 / 3) = 7.333333333333333
  116.         2 * (2 + 4) - 2 / 3 = 3.333333333333333
  117.  
  118.  
  119. 5. Lua works in an if-then/elseif-then/else/end sequence block and to trigger thay must be true
  120.         if-then --only one of these (required)
  121.         elseif-then --as many of these as you need (optional)
  122.         else --only one of these (optional)
  123.         end --only one of these (required)
  124.  
  125.     Example 1(if true,elseif true):
  126.         if true then
  127.             --the code here will be used
  128.         elseif true then
  129.             --the code here will not be used
  130.         end
  131.     Example 2(if false,elseif true):
  132.         if false then
  133.             --the code here will not be used
  134.         elseif true then
  135.             --the code here will be used
  136.         end
  137.     Example 3(if false):
  138.         if false then
  139.             --the code here will not be used
  140.         else
  141.             --the code here will be used
  142.         end
  143.     You can also nest sequence blocks
  144.         Example(if true,second if true):
  145.         if true then
  146.             if true then
  147.                 --the code here will be used
  148.             end
  149.             --the code here will be uses as well
  150.         else
  151.             --the code here will not be used
  152.         end
  153.     if you want to do 2 separate things you can use multiple sequence blocks
  154.         Example(if true,second if true):
  155.         if true then
  156.             --the code here will be used
  157.         else
  158.             --the code here will not be used
  159.         end
  160.         if true then
  161.             --the code here will be uses as well
  162.         else
  163.             --the code here will not be used
  164.         end
  165.        
  166. 6. Lua has special commands for some things
  167.     local - makes the given variable local to function and or sequence block instead of making it a global variable
  168.     return - stops processing further code in the function
  169.  
  170.     if you want to return something to a previous function you can
  171.     Example:
  172.         local <variablename> = testcode()
  173.         function testcode()
  174.             if true then
  175.                 return <variable>
  176.             end
  177.         end
  178.  
  179. 7. Info about rules
  180.     I will add to this at a later date.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement