What is the difference between lua and c




















We can load libraries with the call:. We will start with the simplest way to use lua -- have the interpreter execute a file. This is functionally equivalent to the dofile command from within lua and unsurprisingly, has the same name! To execute the file "test. Note that if we are using relative paths other than absolute paths under windows, then the system will look in the current working directory -- which is the directory that the executable file is in if you double-click on the executable , or the directory that the project is in if you run from within Visual Studio You can, of course, change the working directory that the debugger uses under the project settings in Visual Studio.

Note that the dofile command not only computes these values and prints them out, it also adds the fib function to the global namespace of our lua enviornment stored in the C variable L. To call a lua function we:.

Let's look at a second example. The first parameter is at index 1, the second parameter is at index 2, and so on. Once we have extracted the parameters, we do our calculation, and then push the result on the top of the stack.

Once we have written the function, we just need to register it with lua. That is, we need to add the name of the function to the global lua namespace, and provide a pointer to the function so that lua cal access it. So, to register the above two functions:. We can also send a string straight to the lua interpreter, and it will be executed just as if that string was in a file that was executed with a dofile.

So, we could do something like:. Note that this would not work at all in a game environment! We will look at how to embed a command-line lua interpreter within a game next time. For now, this is enough for us to play around with a bit. Using visual studio: Open up Visual Studio, and create a new project Create a win 32 console application In the Project Creation wizard, check the "static library" radio button to build as a static library.

Add the lua source to the project. The same is true of Perl, and Python. Add a comment. Active Oldest Votes. John Bollinger John Bollinger k 8 8 gold badges 70 70 silver badges bronze badges. Alundaio Alundaio 3 3 silver badges 8 8 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete?

Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. Of course, it needs a proper security audit for side channel attacks, protocol vulnerabilities and so on -- but I was impressed by how much simpler a client-server application with crypto and complex terminal handling was in Go.

Get Advice. Follow I use this. Building a data driven culture with Snowplow. C vs Lua: What are the differences? C and Lua can be categorized as "Languages" tools. Advice on C and Lua. Needs advice. Decisions about C and Lua. Get Advice from developers at your company using Private StackShare.

Sign up for Private StackShare. Pros of C. Pros of Lua. Pros of C



0コメント

  • 1000 / 1000