Jump to content

Aaron Symons

Members
  • Posts

    90
  • Joined

  • Last visited

Posts posted by Aaron Symons

  1. Okay. I've defined it, now I get: "The specified module could not be found." lol I think we're getting somewhere though. :P

     

    I've read that this message can be given if my DLL is dependent on other DLL files. The only things dependent would be the Lib files I included in the VS project. Could this be the issue here?

  2. I'm thinking it might be to do with the other DLL files I linked into my VS project, info.

     

    I'm not running in sandbox mode, and I think it can't find "luaopen_power".

     

    simpleDLL.h

    extern "C" {
     #include "lua.h"
       #include "lauxlib.h"
       #include "lualib.h"
    }
    
    
    static int isquare(lua_State *L);
    
    static int icube(lua_State *L);
    
    int luaopen_power(lua_State *L);
    

     

    simpleDLL.cpp

    #include "simpleDLL.h"
    
    static int isquare(lua_State *L)
    {
       float rtrn = (float)(lua_tonumber(L, -1));
       printf("Top of square(), nbr = %f\n", rtrn);
       lua_pushnumber(L, rtrn * rtrn);
       return 1;
    }
    
    static int icube(lua_State *L)
    {
       float rtrn = (float)(lua_tonumber(L, -1));
       printf("Top of cube(), number=%f\n", rtrn);
       lua_pushnumber(L, rtrn*rtrn*rtrn);
       return 1;
    }
    
    int luaopen_power(lua_State *L)
    {
       lua_register(L, "square", isquare);
       lua_register(L, "cube", icube);
       return 0;
    }
    

  3. I tried loading my DLL with this:

     

    
    

    local dll = assert(package.loadlib("C:\root\to\simpleDLL.dll", "luaopen_power"))

     

    which results in: "The specified procedure could not be found." Also, I don't have a lua.exe file on my computer. :/

  4. Hi,

     

    Got my DLL compiled with no warnings or errors. Woop!

     

    @Rick, I did as you suggested and included all header and source files into the project, as well as including the LIB files. smile.png

     

    The only thing now is: where do I put the DLL in my Leadwerks project (if it matters), and how do I require() it from within Leadwerks? lol

     

    At least I have my DLL now! biggrin.png

  5. In C++ there are a couple options to including a library. You can include a .lib file and the headers only OR you can include all source if it's available to you. That's cpp and h files. I suggested including all the source (.h & .cpp) because it's easier for someone new than going into the config properties and adding .lib file (I think anyway). Did you copy all source and header files to your local project AND add all of those files to your project?

     

    I see now.

     

    I just copied all the downloaded files to my project folder and then I just #include the three header files I stated in the code snippet, pointing to the downloaded ones, of course, like:

     

    // Path to downloaded header
    #include "C:\path\lua.h"
    

     

    So you're saying I should include all Lua / LuaJIT files into my project as if I created them: so they show in the "solution explorer" in VS, then include the three headers I included in my snippet?

  6. It might be more than a few. I don't recall. Download this http://luajit.org/download/LuaJIT-2.0.3.zip and just copy them to your VS project dir. Then go into VS and include all these existing files into your project. It should work then.

     

    Include all header files, or just the three I include already? I'm still having difficulties using the lua_ methods. I must be missing something!

     

    If I redefine them in my DLL project, I get an error stating as such. I don't want to redefine them, but that's one of the "solutions" I've tried.

     

    I'm really not sure where to go from here. It's obviously doable, as many people have created DLL files for Lua, but I can't seem to get things working.

     

    It could be:

    • The setup of my VS project, including;
    • The compiler used in my VS project isn't suitable
    • Missing included files
    • Missing definitions

     

    I don't know, and I'm sure the list could go on! lol

  7. @shadmar Thanks for the info! :)

     

    Is there any documentation on the Leadwerks 3.x shader convension, as I can't see any? The most useful documentation I've always found has been LE 2.x (I think), where the likes of TVec types are used - very old.

     

    I'd love to know how you did your

    , as this has always been of interest to me since I first saw it in a game. I'm sure there are many different ways of going about it (I can think of a few ideas), but using a shader is most intriguing to me. :P
  8. Hello,

     

    I was just wondering if anyone can point me to any in-depth theories, practices, and tutorials for creating shaders for Leadwerks. I've spent a very short time dissecting some of the shaders that come with Leadwerks, but I don't fully understand how they work.

     

    Thanks in advance!

  9. If you're doing it via script, try setting the global coordinates to true, as described here:

     

     entity:SetPosition(x, y, z, true)

     

    Get the player's position, then add onto that, eg: if you want the object 2 units in front of the player on the X axis:

     

    
    

    -- Get player position (if this script is attached to the player)

    local playerPos = self.entity:GetPosition()

     

    -- Set the object's position, using global coordinates

    self.object:SetPosition(playerPos.x + 2, playerPos.y, playerPos.z, true)

  10. Yeah, I've used NuGet in VS with .NET stuff but never in C++. Personally I think you should download the Lua source and just include it into your project. It's only like 2-3 files. You might need to get LuaJIT as I believe LE uses that.

     

    Yeah. I think I'm missing something here, because I definitely can't seem to use the lua_pushnumber method, and other lua_ prepended methods.

     

    Where do you download your Lua source? On the Lua.org website, I only see downloads available that will give me more than the 2-3 files you mention.

  11. I knew I wasn't going crazy smile.png

     

    It matters. Nothing new is drawn if you don't sync. It'll just be the last thing that was drawn on the screen. Syncing draws everything. 2D and 3D. If you have your normal App.lua and comment out the sync call you'll get a white screen.

     

    You're not going crazy at all! I think I might be regressing in IQ, though! biggrin.png

     

    My last comment, I meant that I'm not sure if "Sync() then DrawText()" would make much difference to "DrawText() then Sync()" in this case, seeing as it's just a loading screen.

     

    I have my animated loading screen working wonderfully now! smile.png Thank you Rick, you've been most helpful.

     

    One quick aside question: is there a way to change the compression of multiple texture files at once in Leadwerks? I've just had to spend nearly twenty minutes changing the compression of over 300 texture files for my "animation" (I uncompressed them in order to have transparency, as well as nice smooth graphics). If not, hopefully I can do something through code instead, unless I'm missing something yet again. tongue.png

  12. It shouldn't be. Map:Load() is a blocking function and doesn't come back until it's done as far as I know (yes it calls the callback for each entity it loads but shouldn't come back from the Load() call in order to reach your context:Sync() in your main loop). The world doesn't have anything to do with 2D drawing though as far as I know, but even then Sync() on the context is what draws to the screen the 2D stuff. I must be missing something here because that doesn't make sense to me how this is working. How long does your map take to load?

     

    Can you post your entire App.lua file?

     

    Yeah, I just tested that if you don't call Context::Sync() nothing is drawn to the screen. I just get a white screen, so I don't think this is perhaps working the way you think it is. How are you getting out of your ShouldSwitchMap() function because there is no if check in there to see if you should indeed switch maps, so if that function is being called all the time in App:Loop() then it would be switching maps all the time.

     

    So my impression is whatever you are seeing was left over from the last frame that Context:Sync() was called in, but that wouldn't be what you are drawing in the map loader callback. That's why it confusing and seeing you App.lua would probably clear things up.

     

    Sorry! You were right. I accidentally missed out a line in my code when I posted it on here ( in LoadingScreen() ) where I Sync() the context before drawing. Sorry about that!

     

    I'm not sure if syncing after drawing would make any difference, perhaps I'll experiment. I'm updating it to now show an "animated" loading icon. :)

  13. besides drawing a black rectangle you could use a table with the images

    loadingscreen = {}
    loadingscreen[0](image stuff here)
    loadingscreen[1](image stuff here)
    loadingscreen[2](image stuff here)
    etc...
    

     

    and just call it in the update world so as long as it's true, cycle through each pic.while it loads till it loads set to false, this would be fine showing pictures for my game, not sure if you just want pic., of course I'd rather have a animated screen, but even portal 2's loading screen some times lagg's from loading.

     

    Yeah. That's my next step. I'll be using Blender to render an animation to png files and cycle through them using a similar method to your suggestion. :)

     

    @Aaron Does that work for you? It seems like it wouldn't because when you load the map it should call that callback function for each entity it's loading, but you are drawing to the context, but it is my understanding that whatever you draw to the context will not actually be displayed until context:Sync() is drawn (http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextsync-r48). I don't see that being called in your LoadingScreen() function so how would what you are drawing there be shown on the screen?

     

    This definitely works for me. There is no other code included in my Loading Screen "system", only what you see here. :)

    I wonder if the call to update the context in App.lua is still running during Map:Load(), as the world (self.world) is never destroyed or created for each map load - the original always exists. ;)

  14. This installation of Lua, did it include the entire source or just the lib or lib/dll?

     

    As far as I can see, NuGet installed both lib and dll files for Lua. NuGet is a tool in Visual Studio 2013 Express. You just type into the NuGet console:

     

     Install-Package "Lua" 

     

    and it finds the files from some online repository (I guess) and downloads them for use in the current project. smile.png

  15. The way I displayed the loading text (in App.lua):

     

    function App:LoadingScreen()

    self.context:SetFont(self.DefaultFont)

     

    local loadingText = "L O A D I N G . . ."

    local x = (App.window:GetWidth() / 2) - (self.DefaultFont:GetTextWidth(loadingText) / 2)

    local y = (App.window:GetHeight() / 2) - (self.DefaultFont:GetHeight() / 2)

     

    -- Fill screen with black

    self.context:SetColor(0, 0, 0)

    self.context:DrawRect(0, 0, App.window:GetWidth(), App.window:GetHeight())

     

    -- Draw "Loading" text

    self.context:SetColor(1, 1, 1)

    self.context:DrawText(loadingText, x, y)

    end

     

    function LoadingScreen()

    App:LoadingScreen()

    end

     

    function App:ShouldSwitchMap()

    -- Clear all entities

    self.world:Clear()

     

    -- Load the next map

    Time:Pause()

    if Map:Load(self.mapfile, "LoadingScreen") == false then return false end

    Time:Resume()

    end

     

    You probably don't need to "fill the screen with black" by drawing the rectangle, but that's what I have until I update it and I hope this helps. smile.png

    • Upvote 1
  16. Hey there,

     

    I've had some issues with creating my DLL. Namely, the "LNK2019" issue. For some reason lua_pushnumber() and lua_tonumber() are an "unresolved external symbol". I've had a read online, but I'm just getting back into C/C++ and most of my knowledge of it has gone! xD

     

    I've "installed" Lua into the Visual Studio project via NuGet.

     

    My "simpleDLL.h":

    extern "C" {
    #include <lua.h>
    #include <lauxlib.h>
    #include <lualib.h>
    }
    
    namespace myNameSpace
    {
     class MyClass
     {
    	 public:
    		 static __declspec(dllexport) int isquare(lua_State *L);
     };
    }

     

    My "simpleDLL.cpp":

    #include "simpleDLL.h"
    
    namespace myNameSpace
    {
     int MyClass::isquare(lua_State *L)
     {
    	 float rtrn = lua_lua_tonumber(L, -1);
    	 printf("Top of square(), nbr = %f\n", rtrn);
    	 lua_pushnumber(L, rtrn * rtrn);
    	 return 1;
     }
    }

     

    I'm just aiming to create a very simple DLL at the moment to get the hang of how they work. Any help will be appreciated!

  17. You can always write a LUA plugin (DLL) in C. I did one my self and it works just fine. Remember to switch off LUA sand-boxing when "requiring" a module.

     

    I'm interested in trying out creating a DLL module for Lua. Do you have any pointers or tips? smile.png

     

    I'm guessing I'll have to download Lua source in order to get the header files. Looks like I'll have to install mingw as well. I'm sure this is all basic stuff, but I've never dabbled in creating a DLL file before.

  18. Hi,

     

    I was just wondering if there's a way to "upgrade" from the Indie edition to the Standard edition on Steam. Would I have to purchase the Standard edition at full price, even though I have already purchased the Indie edition?

     

    Thanks!

     

     

    EDIT: Already found my answer. One needs to purchase the "base application" (Indie Edition) before purchasing the Standard Edition (as stated on Steam).

    • Upvote 1
  19. @Josh There are some old posts pointing to the Leadwerks wiki, as well as a Google search, of course. I'm guessing he found it through one of those ways.

     

    While we're talking about it, are there plans for an updated wiki, or are you thinking of just keeping all the documentation, examples, and tutorials accessible via the Leadwerks website?

     

    Also, in response to CrazyVulcan's question, do you think you'll plan for an auto-complete in the script editor? Personally, I've never felt I've needed it, but I do think it might be an idea worth considering later down the line if Leadwerks keeps evolving and expanding (which I'm sure it will). smile.png

  20. I've never seen such an option in the Leadwerks Editor. I think it would be a useful addition though.

     

    In the mean time, you don't have to scour the Wiki. You can look through the documentation which gives examples in both Lua and C++, or you can use the index page on the Leadwerks website which lists functions, and more, alphabetically.

     

    Hope this helps for now! smile.png

×
×
  • Create New...