Announcement

Collapse
No announcement yet.

Jon Shafer on Modding in Civ5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I've used it for a grand total of about 10-15 minutes so far. If you disagree with me, I'm probably wrong.

    Specifically, I find the way it denotes blocks to be a bit odd. The only way I can think of to describe it is BASIC-style:

    if [condition] then
    [stuff]
    end
    If there is no sound in space, how come you can hear the lasers?
    ){ :|:& };:

    Comment


    • #17
      Don't tell me you expected all languages to use curly braces to do that.
      Graffiti in a public toilet
      Do not require skill or wit
      Among the **** we all are poets
      Among the poets we are ****.

      Comment


      • #18
        Hardly. I've used Python and Visual Basic before.
        If there is no sound in space, how come you can hear the lasers?
        ){ :|:& };:

        Comment


        • #19
          Then why is it strange? A block is everything that goes between keywords like "then" and "end". Not much different from Visual Basic
          The whole problem with the world is that fools and fanatics are always so
          certain of themselves, but wiser people so full of doubts.
          -- Bertrand Russell

          Comment


          • #20
            Originally posted by Hauldren Collider View Post
            I'd try the Lua site for more info, this might be promising though it isn't really a tutorial.
            From the link, the all LUA is defined here:
            Code:
            chunk ::= {stat [`;´]} [laststat [`;´]]
            
            	block ::= chunk
            
            	stat ::=  varlist `=´ explist | 
            		 functioncall | 
            		 do block end | 
            		 while exp do block end | 
            		 repeat block until exp | 
            		 if exp then block {elseif exp then block} [else block] end | 
            		 for Name `=´ exp `,´ exp [`,´ exp] do block end | 
            		 for namelist in explist do block end | 
            		 function funcname funcbody | 
            		 local function Name funcbody | 
            		 local namelist [`=´ explist] 
            
            	laststat ::= return [explist] | break
            
            	funcname ::= Name {`.´ Name} [`:´ Name]
            
            	varlist ::= var {`,´ var}
            
            	var ::=  Name | prefixexp `[´ exp `]´ | prefixexp `.´ Name 
            
            	namelist ::= Name {`,´ Name}
            
            	explist ::= {exp `,´} exp
            
            	exp ::=  nil | false | true | Number | String | `...´ | function | 
            		 prefixexp | tableconstructor | exp binop exp | unop exp 
            
            	prefixexp ::= var | functioncall | `(´ exp `)´
            
            	functioncall ::=  prefixexp args | prefixexp `:´ Name args 
            
            	args ::=  `(´ [explist] `)´ | tableconstructor | String 
            
            	function ::= function funcbody
            
            	funcbody ::= `(´ [parlist] `)´ block end
            
            	parlist ::= namelist [`,´ `...´] | `...´
            
            	tableconstructor ::= `{´ [fieldlist] `}´
            
            	fieldlist ::= field {fieldsep field} [fieldsep]
            
            	field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | exp
            
            	fieldsep ::= `,´ | `;´
            
            	binop ::= `+´ | `-´ | `*´ | `/´ | `^´ | `%´ | `..´ | 
            		 `<´ | `<=´ | `>´ | `>=´ | `==´ | `~=´ | 
            		 and | or
            
            	unop ::= `-´ | not | `#´
            The only thing which is missing are examples.
            The whole problem with the world is that fools and fanatics are always so
            certain of themselves, but wiser people so full of doubts.
            -- Bertrand Russell

            Comment


            • #21
              Originally posted by MxM View Post
              Then why is it strange? A block is everything that goes between keywords like "then" and "end". Not much different from Visual Basic
              Because visual basic is strange. Obviously it's an opinion. You're free to disagree with it.
              If there is no sound in space, how come you can hear the lasers?
              ){ :|:& };:

              Comment


              • #22
                Originally posted by Hauldren Collider View Post
                Because visual basic is strange. Obviously it's an opinion. You're free to disagree with it.
                I am not trying to argue, but rather curious, why visual basic is strange? The only "strangeness" of visual basic that I know, is that they use new line as separator between statements, and sometimes you have to have new line, but I do not think that this is the case for lua. You can write everything into single line.
                The whole problem with the world is that fools and fanatics are always so
                certain of themselves, but wiser people so full of doubts.
                -- Bertrand Russell

                Comment


                • #23
                  Originally posted by MxM View Post
                  I am not trying to argue, but rather curious, why visual basic is strange? The only "strangeness" of visual basic that I know, is that they use new line as separator between statements, and sometimes you have to have new line, but I do not think that this is the case for lua. You can write everything into single line.
                  Visual basic is a strange language for many reasons. It's been years since I've written in it, and I have never used .NET, so I can't really comment on it in its present state, but let me just say that I think BASIC syntax is atrocious.

                  newlines as statement terminators is not one of the parts of BASIC syntax I find bad.

                  Please don't take my comments on BASIC syntax as some sort of statement about Visual Basic. I haven't used the latter in years.
                  If there is no sound in space, how come you can hear the lasers?
                  ){ :|:& };:

                  Comment


                  • #24
                    Here's an example of strange lua code (I'm making it up in order to look obfuscated, but I've seen code more or less like that):

                    x = 0 -- trick: What's the scope of x? It's global. You probably screwed someone else's local variable by writing this line. The global by default is probably the single worst feature of lua.
                    local x = x -- Now x refers to the value of x. This line is actually pretty common in order to protect oneself from screwing your x from the outside.
                    x = nil or x and 2 -- So now what's the value of x? Probably "true"
                    x = x and false or 7 -- Now x is worth 7

                    As for OO, metatables don't make lua OO. It makes it easier to have some inheritance, and it's possible to have object inheritance (prorotypes) in any language in about 5 lines of code anyway.

                    Some syntactic sugar also makes some calls unobvious, like this:
                    thisIsAMethodCall { "this is a string in a table which is the parameter of the method" }
                    is the same as
                    thisIsAMethodCall ( { "this is a string in a table which is the parameter of the method" } )
                    There are a few ways strings and table parameters can be passed to functions that I am uncomfortable with because they save about 1 second of typing and hamper the ability of newcomers to read the code by hours.
                    But overall, lua is a neat, fast language.
                    Clash of Civilization team member
                    (a civ-like game whose goal is low micromanagement and good AI)
                    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                    Comment


                    • #25
                      So lua DOES have implicit global variables? That really sucks.

                      I thought we learned that lesson with javascript.

                      Lua
                      If there is no sound in space, how come you can hear the lasers?
                      ){ :|:& };:

                      Comment


                      • #26
                        Implicit global variables
                        Implicit type conversion for boolean tests but inevitable in weakly-typed languages
                        Programmers using implicit type conversion for boolean tests
                        Graffiti in a public toilet
                        Do not require skill or wit
                        Among the **** we all are poets
                        Among the poets we are ****.

                        Comment


                        • #27
                          ===
                          If there is no sound in space, how come you can hear the lasers?
                          ){ :|:& };:

                          Comment


                          • #28
                            Originally posted by onodera View Post
                            Implicit global variables
                            Implicit type conversion for boolean tests but inevitable in weakly-typed languages
                            Programmers using implicit type conversion for boolean tests
                            Actually, the code I wrote is not about implicit type conversion. x == 0 is true for instance. The only things which are false are 'nil' (uninitialised variable) and 'false'. Writing x = y or z is just a shorthand for writing the C equivalent: x = y ? y : z;
                            The 'or' operator is not, despite the appearances, a boolean operator, but the 'and' operator is one.
                            Clash of Civilization team member
                            (a civ-like game whose goal is low micromanagement and good AI)
                            web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                            Comment

                            Working...
                            X