lua

A couple of pattern matching issues with pattern matching in Lua

I'm fairly new to lua programming, but I'm also a quick study. I've been working on a weather forecaster for a program that I use, and it's working well, for the most part. Here is what I have so far. (Pay no attention to the zs.stuff. That is program specific and has no bearing on the lua coding.) if not http then http = require("so...

Executing remote script - Architecture

Hi, I want to make an application that executes a remote script. The user can create a script (probabily a LUA script) then stores it in the server. Then he can uses an API for execute the script. I was thinking that API could be a webservice. So my questions are: I need high performance to execute the script. So my first choice was LU...

Lua Alien Module - Trouble using WriteProcessMemory function, unsure on types (unit32)

require "alien" --the address im trying to edit in the Mahjong game on Win7 local SCOREREF = 0x0744D554 --this should give me full access to the process local ACCESS = 0x001F0FFF --this is my process ID for my open window of Mahjong local PID = 1136 --function to open proc local op = alien.Kernel32.OpenProcess op:types{ ret = "pointer...

World of Warcraft addon — SetCursor not working when hovering over WorldFrame

In my World of Warcraft addon, I want to set the cursor to a certain image. I do this using SetCursor. Problem is, whenever the cursor exits my frame and hovers over the WorldFrame, the cursor is reset back to the normal one. I know of a certain addon that does overcome this problem, but I am not too sure how, because its source code is...

Execute remote Lua Script

Hi, I want to make an application that executes a remote script. The user can create a script (probabily a LUA script) then stores it in the server. Then he can uses an API for execute the script. I was thinking that API could be a webservice. So my questions are: I need high performance to execute the script. So my first choice was LUA...

Pass C++ object to Lua function

Hello there. I have a C++ project, where 1 method of a 1 class changes very often. So I want to take that code from C++ to Lua. Note, I'm novice to Lua. The whole task: Bind some class methods to Lua state machine; Pass reference to class object to a function, written in Lua; Operate with passed C++ object in Lua function. I've foun...

Lua on the iPhone

I'm trying to load at run-time Lua scripts on the iPhone. Is there a possibility to do that? How can I getting started with Lua? I can't find something. The only thing I can find is that this should be possible, but I am wondering how. ...

Is LuaJIT really faster than every other JIT-ed dynamic languages?

According to the computer language benchmark game, the LuaJIT implementation seems to beat every other JIT-ed dynamic language (V8, Tracemonkey, PLT Scheme, Erlang HIPE) by an order of magnitude. I know that these benchmarks are not representative (as they say: "Which programming language implementations have the fastest benchmark prog...

Assistance with Lua functions

As noted before, I'm relatively new to lua, but again, I learn quick. The last time I got help here, it helped me immensely, and I was able to write a better script. Now I've come to another question that I think will make my life a bit easier. I have no clue what I'm doing with functions, but I'm hoping there is a way to do what I wa...

physics game programming box2d - orientating a turret-like object using torques

This is a problem I hit when trying to implement a game using the LÖVE engine, which covers box2d with Lua scripting. The objective is simple: A turret-like object (seen from the top, on a 2D environment) needs to orientate itself so it points to a target. The turret is on the x,y coordinates, and the target is on tx, ty. We can consid...

Making web server in C with native scripting support

I'm an intermediate C developer, trying to get better. I want to make a very basic and lightweight HTTP server with its own scripting language. Could I use something like Lua for scripting? If not, what? I don't want to use CGI/FastCGI like Apache does for PHP in most cases, I want my server to natively support my scripting language. ...

Lua - Reflection - Get list of functions/fields on an object?

I'm new to Lua and dealing with Lua as a scripting language in an alpha release of a program. The developer is unresponsive and I need to get a list of functions provided by some C++ objects which are accessible from the Lua code. Is there any easy way to see what fields and functions these objects expose? ...

Best Lua OOP library

Hi! What is the best Lua OOP library in terms of speed, syntax convenience, LOC and license? Thank you. I've found LOOP. http://loop.luaforge.net/index.html It offers pretty nice syntax: local oo = require "loop.base" local Date = oo.class { -- default field values day = 1, month = 1, year = 1900, } local birthday = Date {...

How to determine if a C++ usertype has been registered with tolua

We use tolua++ to generate Lua bindings for C++ classes. Assume I have a C++ class: class Foo { //Some methods in Foo, irrelevant to question. }; and a tolua .pkg file with the following contents class Foo { }; Consider the following function: void call_some_lua_function(lua_State* luaState) { Foo* myFoo = new Foo(); ...

Configuration files for C in linux

Hi, I have an executable that run time should take configuration parameters from a script file. This way I dont need to re-compile the code for every configuration change. Right now I have all the configuration values in a .h file. Everytime I change it i need to re-compile. The platform is C, gcc under Linux. What is the best soluti...

Lua and C++: separation of duties

Please help to classify ways of organizing C++/Lua game code and to separate their duties. What are the most convenient ways, which one do you use? For example, Lua can be used for initializing C++ objects only or at every game loop iteration. It can be used for game logic only or for graphics, too. Some game engines provide full contro...

How would I go about sharing variables in a C++ class with Lua?

I'm fairly new to Lua, I've been working on trying to implement Lua scripting for logic in a Game Engine I'm putting together. I've had no trouble so far getting Lua up and running through the engine, and I'm able to call Lua functions from C and C functions from Lua. The way the engine works now, each Object class contains a set of var...

Lua, game state and game loop

Call main.lua script at each game loop iteration - is it good or bad design? How does it affect on the performance (relatively)? Maintain game state from a. C++ host-program or b. from Lua scripts or c. from both and synchronise them? (Previous question on the topic: http://stackoverflow.com/questions/2674462/lua-and-c-separation-of-d...

Convert hex to decimal keeping fractional part in Lua

Lua's tonumber function is nice but can only convert unsigned integers unless they are base 10. I have a situation where I have numbers like 01.4C that I would like to convert to decimal. I have a crummy solution: function split(str, pat) local t = {} local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find...

Lua task scheduling

I've been writing some scripts for a game, the scripts are written in Lua. One of the requirements the game has is that the Update method in your lua script (which is called every frame) may take no longer than about 2-3 milliseconds to run, if it does the game just hangs. I solved this problem with coroutines, all I have to do is call ...