Search Results

Search found 406 results on 17 pages for 'lua'.

Page 10/17 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Making web server in C with native scripting support

    - by guitar-
    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.

    Read the article

  • C++ Expose Already Existing Instance of Objects to a Scripting Language

    - by user947871
    So, I want to be able to modify already instanced C++ objects in a scripting language. I have been looking at Lua with LuaBind and Python with SWIG or Boost::Python, but all I see is how to make new instances of the objects, but I want to modify already existing ones. Example: C++: Player playerOne = new Player(); Scripting Language : playerOne.Transform.x += 5; Is this possible, and if so, wat would you suggest as a good Language/library to achieve this with?

    Read the article

  • Generating strongly biased radom numbers for tests

    - by nobody
    I want to run tests with randomized inputs and need to generate 'sensible' random numbers, that is, numbers that match good enough to pass the tested function's preconditions, but hopefully wreak havoc deeper inside its code. math.random() (I'm using Lua) produces uniformly distributed random numbers. Scaling these up will give far more big numbers than small numbers, and there will be very few integers. I would like to skew the random numbers (or generate new ones using the old function as a randomness source) in a way that strongly favors 'simple' numbers, but will still cover the whole range, I.e. extending up to positive/negative infinity (or ±1e309 for double). This means: numbers up to, say, ten should be most common, integers should be more common than fractions, numbers ending in 0.5 should be the most common fractions, followed by 0.25 and 0.75; then 0.125, and so on. A different description: Fix a base probability x such that probabilities will sum to one and define the probability of a number n as xk where k is the generation in which n is constructed as a surreal number1. That assigns x to 0, x2 to -1 and +1, x3 to -2, -1/2, +1/2 and +2, and so on. This gives a nice description of something close to what I want (it skews a bit too much), but is near-unusable for computing random numbers. The resulting distribution is nowhere continuous (it's fractal!), I'm not sure how to determine the base probability x (I think for infinite precision it would be zero), and computing numbers based on this by iteration is awfully slow (spending near-infinite time to construct large numbers). Does anyone know of a simple approximation that, given a uniformly distributed randomness source, produces random numbers very roughly distributed as described above? I would like to run thousands of randomized tests, quantity/speed is more important than quality. Still, better numbers mean less inputs get rejected. Lua has a JIT, so performance can't be reasonably predicted. Jumps based on randomness will break every prediction, and many calls to math.random() will be slow, too. This means a closed formula will be better than an iterative or recursive one. 1 Wikipedia has an article on surreal numbers, with a nice picture. A surreal number is a pair of two surreal numbers, i.e. x := {n|m}, and its value is the number in the middle of the pair, i.e. (for finite numbers) {n|m} = (n+m)/2 (as rational). If one side of the pair is empty, that's interpreted as increment (or decrement, if right is empty) by one. If both sides are empty, that's zero. Initially, there are no numbers, so the only number one can build is 0 := { | }. In generation two one can build numbers {0| } =: 1 and { |0} =: -1, in three we get {1| } =: 2, {|1} =: -2, {0|1} =: 1/2 and {-1|0} =: -1/2 (plus some more complex representations of known numbers, e.g. {-1|1} ? 0). Note that e.g. 1/3 is never generated by finite numbers because it is an infinite fraction – the same goes for floats, 1/3 is never represented exactly.

    Read the article

  • Awesome Window Manager - Rule assigning programs to tags

    - by Peter
    I have a set of tags 'main', 'www', and 3: -- {{{ Tags tags = { names = {"main", "www", 3}, for s = 1, screen.count() do tags[s] = awful.tag(tags.names, s, tags.layout) end } -- }}} I want Firefox to open in tag "www". I've tried the following rule: -- {{{ Rules awful.rules.rules = { { rule = {class = "Firefox" }, properties = { tag = tags[1]["www"] }}, } -- }}} However, if I hit Super+R then type 'firefox' or run 'firefox &' from a terminal, Firefox opens in whatever tag I'm viewing. I've tried {class = "firefox"} and properties = { tag = tags[1][2] } but those modified rules did not work either. What is the correct way to set up a rule to make firefox always open in a particular tag?

    Read the article

  • I want to replace a number with successive numbers, starting at 1 and going up.

    - by Pär-Magnus Green
    I'm aware that this is something people can easily program, but I'm not familiar with those things, so I was hoping there was an easier solution. I've edited a large database of questions, including sorting, and ended up getting all the question ID's mixed up. I'm trying to do this in Notepad++, but any other suggestions are welcome. I'm wondering if there's a way to search for a string (ex. "Question[any number]") and replace the numbers with first 1, then 2, et.c. For clarification, this is how one question looks like: TriviaBot_Questions[3]['Question'][63] = "Acronyms: What does WTT stand for?"; TriviaBot_Questions[3]['Answers'][63] = {"Want To Trade"}; TriviaBot_Questions[3]['Category'][63] = 7; TriviaBot_Questions[3]['Points'][63] = 1; TriviaBot_Questions[3]['Hints'][63] = {}; and the next question, as is now, is not followed by 64. It might be 245 or 1029, and regardless of which number it is, I want it replaced with "previous number + 1", basically.

    Read the article

  • Configure lua prosody for localhost only

    - by Alfred
    I want to use prosody or maybe another xmpp server to test my xmpp bot. I want it to only accept connection from the address/localhost(don't want to configure firewall to block access). I would like to know the easiest way to accomplish this.

    Read the article

  • Configuration files for C in linux

    - by James
    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 solution for this problem? I looked up on google and so XML, phthon and Lua bindings for C. Is using a separate scripting language the best approach? If so, which one would you recommend for my need? Thanks

    Read the article

  • wrapp a function whose parameters are out type pointer to structure using swig

    - by pierr
    I have following function : typedef struct tagT{ int a ; int b ; }Point; int lib_a_f_5(Point *out_t) { out_t->a = 20; out_t->b = 30; return 0; } How should I direct the SWIG to generate the correct code for ruby (or lua)? When putting following statement to the interface file : %apply SWIGTYPE Point* {Point *out_t}; I got a warning : liba.i:7: Warning(453): Can't apply (Point *OUTPUT). No typemaps are defined. Did i need to write a typemap? How should I do it?

    Read the article

  • shared_ptr requires complete type; cannot use it with lua_State*

    - by topright
    Hello! I'm writing a C++/OOP wrapper for Lua. My code is: class LuaState { boost::shared_ptr<lua_State> L; LuaState(): L( luaL_newstate(), LuaState::CustomDeleter ) { } } The problem is lua_State is incomplete type and shared_ptr constructor requires complete type. And I need safe pointer sharing. (Funny thing boost docs say most functions do not require complete type, but constructor requires, so there is no way of using it. http://www.boost.org/doc/libs/1_42_0/libs/smart_ptr/smart_ptr.htm) Can can I solve this? Thank you.

    Read the article

  • Swig typecast to derived class?

    - by Zack
    I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following: A * getAnObject() { if(someBoolean) return (A *) new B; else return (A *) new C; } Where "A" is the parent of classes "B" and "C". One can then typecast the pointer returned into being a "B" type or "C" type at one's convenience like: B * some_var = (B *) getAnObject(); Is there some way I can typecast an object I've received from a generic-pointer-producing function at run-time in the scripting language using the wrappers? (In my case, Lua?) I have a function that could produce one of about a hundred possible classes, and I'd like to avoid writing an enormous switch structure that I'd have to maintain in C++. At the point where I receive the generic pointer, I also have a string representation of the data type I'd like to cast it to. Any thoughts? Thanks! -- EDIT -- I notice that SWIG offers to generate copy constructors for all of my classes. If I had it generate those, could I do something like the following?: var = myModule.getAnObject(); -- Function that returns an object type-cast down to a pointer of the parent class, as in the function getAnObject() above. var = myModule.ClassThatExtendsBaseClass(var); -- A copy constructor that SWIG theoretically creates for me and have var then be an instance of the inheriting class that knows it's an instance of the inheriting class?

    Read the article

  • Linker errors using LuaJava on OSX 10.5

    - by Daniel
    Hi, I'm having a bunch of problems getting this library to work on my OSX installation. In particular, I'd like to use it with a Java 1.6 VM but after I compile it up I get the following: java -cp "luajava-1.1.jar" org.keplerproject.luajava.Console Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/dharabor/src/luajava- 1.1/libluajava-1.1.jnilib: at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1739) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1030) at org.keplerproject.luajava.LuaState.<clinit>(LuaState.java:92) at org.keplerproject.luajava.LuaStateFactory.newLuaState(LuaStateFactory.java:59) at org.keplerproject.luajava.Console.main(Console.java:49) I'm running OSX 10.5.8 with Lua 5.1.4 I've also changed my OSX default VM to 1.6.0 as so: /System/Library/Frameworks/JavaVM.framework/Home -> Versions/1.6.0/Home/ /System/Library/Frameworks/JavaVM.framework/Versions/Current -> 1.6.0/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> 1.6.0/ What am I doing wrong? I notice when I use Java 1.5 everything works great. Except I don't want 1.5, I want 1.6.

    Read the article

  • Turning off antialiasing in Löve2D

    - by cjanssen
    I'm using Löve2D for writing a small game. Löve2D is an open source game engine for Lua. The problem I'm encountering is that some antialias filter is automatically applied to your sprites when you draw it at non-integer positions. love.graphics.draw( sprite, x, y ) So when x or y is not round (for example, x=100.24), the sprite appears blurred. The same happens when the sprite size is not even, because (x,y) points to the center of the sprite. For example, a sprite which is 31x30 big will appear blurred again, because its pixels are painted in non-integer positions. Since I am using pixel art, I want to avoid this all the way, otherwise the art is destroyed by this effect. The workaround I am using so far is to force the coordinates to be round by littering the code with calls to math.floor(), and forcing all the sprites to have even sizes by adding a row or column of transparent pixels with the paint program, if needed. Is there some command to deactivate the antialiasing I can call at program startup?

    Read the article

  • 2d trajectory planning of a spaceship with physics.

    - by egarcia
    I'm implementing a 2D game with ships in space. In order to do it, I'm using LÖVE, which wraps Box2D with Lua. But I believe that my question can be answered by anyone with a greater understanding of physics than myself - so pseudo code is accepted as a response. My problem is that I don't know how to move my spaceships properly on a 2D physics-enabled world. More concretely: A ship of mass m is located at an initial position {x, y}. It has an initial velocity vector of {vx, vy} (can be {0,0}). The objective is a point in {xo,yo}. The ship has to reach the objective having a velocity of {vxo, vyo} (or near it), following the shortest trajectory. There's a function called update(dt) that is called frequently (i.e. 30 times per second). On this function, the ship can modify its position and trajectory, by applying "impulses" to itself. The magnitude of the impulses is binary: you can either apply it in a given direction, or not to apply it at all). In code, it looks like this: def Ship:update(dt) m = self:getMass() x,y = self:getPosition() vx,vy = self.getLinearVelocity() xo,yo = self:getTargetPosition() vxo,vyo = self:getTargetVelocity() thrust = self:getThrust() if(???) angle = ??? self:applyImpulse(math.sin(angle)*thrust, math.cos(angle)*thrust)) end end The first ??? is there to indicate that in some occasions (I guess) it would be better to "not to impulse" and leave the ship "drift". The second ??? part consists on how to calculate the impulse angle on a given dt. We are in space, so we can ignore things like air friction. Although it would be very nice, I'm not looking for someone to code this for me; I put the code there so my problem is clearly understood. What I need is an strategy - a way of attacking this. I know some basic physics, but I'm no expert. For example, does this problem have a name? That sort of thing. Thanks a lot.

    Read the article

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

    - by egarcia
    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 consider that x,y are fixed, but tx, ty tend to vary from one instant to the other (i.e. they would be the mouse cursor). The turret has a rotor that can apply a rotational force (torque) on any given moment, clockwise or counter-clockwise. The magnitude of that force has an upper limit called maxTorque. The turret also has certain rotational inertia, which acts for angular movement the same way mass acts for linear movement. There's no friction of any kind, so the turret will keep spinning if it has an angular velocity. The turret has a small AI function that re-evaluates its orientation to verify that it points to the right direction, and activates the rotator. This happens every dt (~60 times per second). It looks like this right now: function Turret:update(dt) local x,y = self:getPositon() local tx,ty = self:getTarget() local maxTorque = self:getMaxTorque() -- max force of the turret rotor local inertia = self:getInertia() -- the rotational inertia local w = self:getAngularVelocity() -- current angular velocity of the turret local angle = self:getAngle() -- the angle the turret is facing currently -- the angle of the like that links the turret center with the target local targetAngle = math.atan2(oy-y,ox-x) local differenceAngle = _normalizeAngle(targetAngle - angle) if(differenceAngle <= math.pi) then -- counter-clockwise is the shortest path self:applyTorque(maxTorque) else -- clockwise is the shortest path self:applyTorque(-maxTorque) end end ... it fails. Let me explain with two illustrative situations: The turret "oscillates" around the targetAngle. If the target is "right behind the turret, just a little clock-wise", the turret will start applying clockwise torques, and keep applying them until the instant in which it surpasses the target angle. At that moment it will start applying torques on the opposite direction. But it will have gained a significant angular velocity, so it will keep going clockwise for some time... until the target will be "just behind, but a bit counter-clockwise". And it will start again. So the turret will oscillate or even go in round circles. I think that my turret should start applying torques in the "opposite direction of the shortest path" before it reaches the target angle (like a car braking before stopping). Intuitively, I think the turret should "start applying torques on the opposite direction of the shortest path when it is about half-way to the target objective". My intuition tells me that it has something to do with the angular velocity. And then there's the fact that the target is mobile - I don't know if I should take that into account somehow or just ignore it. How do I calculate when the turret must "start braking"?

    Read the article

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

    - by Amit Ron
    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 messy as hell. (The addon is Gryphonheart Items, in case you asked yourself.) How do I make the cursor stay?

    Read the article

  • LuaInterface and 64Bit

    - by Skintkingle
    Ok i'm currently using LuaScript v5.1 in a Game engine i'm using. and the handy LuaInterface that comes along with it. i've tested it on a range of systems running a range of OS's. LuaInterface seems to fail on 64bit Operating Systems. Could anyone point me to a 64bit Compiled LuaInterface.dll, or is there any alternative to the LuaInterface that can be used, because LuaInterface is extremely useful and i dont think i would be able to write a more extensive interface by myself using lua51. (I'm not that good, sadly) Any help or links would be greatly appreciated. Thanks alot guys!

    Read the article

  • Wiki-fying a text using LPeg

    - by Stigma
    Long story coming up, but I'll try to keep it brief. I have many pure-text paragraphs which I extract from a system and re-output in wiki format so that the copying of said data is not such an arduous task. This all goes really well, except that there are no automatic references being generated for the 'topics' we have pages for, which end up needing to be added by reading through all the text and adding it in manually by changing Topic to [[Topic]]. First requirement: each topic is only to be made clickable once, which is the first occurrence. Otherwise, it would become a really spammy linkfest, which would detract from readability. To avoid issues with topics that start with the same words Second requirement: overlapping topic names should be handled in such a way that the most 'precise' topic gets the link, and in later occurrences, the less precise topics do not get linked, since they're likely not correct. Example: topics = { "Project", "Mary", "Mr. Moore", "Project Omega"} input = "Mary and Mr. Moore work together on Project Omega. Mr. Moore hates both Mary and Project Omega, but Mary simply loves the Project." output = function_to_be_written(input) -- "[[Mary]] and [[Mr. Moore]] work together on [[Project Omega]]. Mr. Moore hates both Mary and Project Omega, but Mary simply loves the [[Project]]." Now, I quickly figured out a simple or complicated string.gsub() could not get me what I need to satisfy the second requirement, as it provides no way to say 'Consider this match as if it did not happen - I want you to backtrack further'. I need the engine to do something akin to: input = "abc def ghi" -- Looping over the input would, in this order, match the following strings: -- 1) abc def ghi -- 2) abc def -- 3) abc -- 4) def ghi -- 5) def -- 6) ghi Once a string matches an actual topic and has not been replaced before by its wikified version, it is replaced. If this topic has been replaced by a wikified version before, don't replace, but simply continue the matching at the end of the topic. (So for a topic "abc def", it would test "ghi" next in both cases.) Thus I arrive at LPeg. I have read up on it, played with it, but it is considerably complex, and while I think I need to use lpeg.Cmt and lpeg.Cs somehow, I am unable to mix the two properly to make what I want to do work. I am refraining from posting my practice attempts as they are of miserable quality and probably more likely to confuse anyone than assist in clarifying my problem. (Why do I want to use a PEG instead of writing a triple-nested loop myself? Because I don't want to, and it is a great excuse to learn PEGs.. except that I am in over my head a bit. Unless it is not possible with LPeg, the first is not an option.)

    Read the article

  • Purpose of lua_lock and lua_unlock?

    - by anon
    What is the point of lua_lock and lua_unlock? The following implies it's important: LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; lua_lock(L); t = index2adr(L, idx); api_checkvalidindex(L, t); luaV_gettable(L, t, L->top - 1, L->top - 1); lua_unlock(L); } LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { StkId t; TValue key; lua_lock(L); t = index2adr(L, idx); api_checkvalidindex(L, t); setsvalue(L, &key, luaS_new(L, k)); luaV_gettable(L, t, &key, L->top); api_incr_top(L); lua_unlock(L); } The following implies it does nothing: #define lua_lock(L) ((void) 0) #define lua_unlock(L) ((void) 0) Please enlighten.

    Read the article

  • Timer with random seconds ¿How to update the random seconds?

    - by benLIVE
    I have a timer "tmr_sendCesta" which must be called each x seconds between 1 and 3 seconds. The problem is the timer "tmr_sendCesta" is called only one time, and the random seconds is never updated. I need to call the function "createCesta" each x seconds randomly. Any idea how to do it? function createCesta() cesta = display.newImageRect("cesta.png", 100, 55) cesta.x = -110 cesta.y = screenH - 110 cesta.name = "cesta" physics.addBody( cesta, physicsData:get("cestaSmall")) grupoCesta:insert(cesta) transition.to(cesta, {time = 4000, x = screenW + 110}) end function scene:enterScene( event ) local group = self.view physics.start() Runtime:addEventListener("touch", touchScreen) Runtime:addEventListener( "collision", onCollision ) tmr_sendCesta = timer.performWithDelay((math.random(1000, 3000), randomCesta, 0) end

    Read the article

  • How to embed iPhone-Wax into app

    - by John Smith
    Hello I have just learnt about iPhone-Wax (thanks to SO). Now the documentation is rather sparse for what I am trying to do. I want to embed it into an Objective-C app. I don't want it to be the main app. Has anyone done it and how can I achieve it?

    Read the article

  • Looking for marg_setValue fix in iPhoneOS

    - by John Smith
    I am trying to compile a library originally written for Cocoa. Things are good until it looks for the function marg_setValue(). It says there is a syntax error before char in marg_setValue(argumentList,argumentOffset,char,(char)lua_toboolean(state,luaArgument)); (it's talking about the third argument, not (char) ) I am trying to port LuaObjectiveCBridge to the iPhone. It has two choices, either using Runtime or Foundation. I have discovered there are some problems with foundation so I am trying runtime. But the compiler is not co-operating.

    Read the article

  • Removing entry from table

    - by Bnhjhvbq7
    Can't remove an entry from table. here's my code dropItem = dropList[ math.random( #dropList ) ] dropSomething[brick.index] = crackSheet:grabSprite(dropItem, true) dropSomething[brick.index].x = brick.x dropSomething[brick.index].y = brick.y dropSomething[brick.index].name = dropItem dropSomething[brick.index].type = "dropppedItems" collision function bounce(event) local item = event.other if item.type == "dropppedItems" then if item.name == "bomb" then Lives = Lives - 1 LivesNum.text = tostring(Lives) end item:removeSelf(); end end What I've tried: item:removeSelf(); - removes the whole table item = nil - seams to do nothing, the object continue to move and i still see the image

    Read the article

  • Delete object[i] from table or group in corona sdk

    - by Rober Dote
    i have a problem (obviusly :P) i'm create a mini game, and when i touch a Object-A , creates an Object-B. If i touch N times, this create N Object-B. (Object-B are Bubbles in my game) so, i try when I touch the bubble (object-B), that disappears or perform any actions. I try adding Object-B to Array local t = {} . . . bur = display.newImage("burbuja.png") table.insert(t,bur) and where i have my eventListeners i wrote: for i=1, #t do bur[i]:addEventListener("tap",reventar(i)) end and my function 'reventar' local function reventar (event,id) table.remove(t,id) end i'm lost, and only i want disappears the bubbles.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >