Author Topic: lua!!!!  (Read 24901 times)

0 Members and 2 Guests are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: lua?
« Reply #60 on: June 05, 2007 »
i suspect youve possible mised one of the steps above

here is the project folder i have and exe that works on my system.

note you will have to add the fonts folder and the freetype dll.
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #61 on: June 05, 2007 »
Yeah, i just edited my previous post, I  forgot to set a screen mode in the lua script.

Anyway, if I set the graphics with screenres it works just fine, but if I set it with screen it doesn't work right, it runs but all I get is a single row of pixels spread across the top of the window

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: lua?
« Reply #62 on: June 06, 2007 »
hmm i dont know much about fb functions i used the same methode to blit the bmp as is used to blit the font via screenptr but im using integers so the only thing i can think of is that using screen isnt opening a 32 bit color window but im not sure :-\
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #63 on: June 06, 2007 »
hmm... well thanks again, this gives me something to play around with


but for now GameTap just finished downloading Tomb Raider Anniversary, so I'm gonna be busy for a while  ;D

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: lua?
« Reply #64 on: June 06, 2007 »
lol yeah im currently busy trying to get broken sword 2 to run on my psp.

oh well have fun!
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #65 on: June 07, 2007 »
Alright, thanks to some files posted by Tigra on the Freebasic board I've been able to get FBlua to compile with v0.17.  Use the liblua.a in this archive to replace the liblua.a in the lib\win32 folder that gets installed by 0.17, and use the -lang deprecated option when you compile.

http://www.mediafire.com/?a40b2i4xtxj

This works, but I've noticed a few problems:

-- lua's error reporting function isn't printing the errors anymore -- probably because of the change in the liblua.a or the headers, I just need to figure out the new setup

-- my sPrint function isn't working correctly anymore, it looks like there was a change in the way that colors are used in the higher color depth screen modes

--You're image loading functions don't seem to work with 0.17, something about missing a pointer?

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: lua?
« Reply #66 on: June 07, 2007 »
Some of the flags for the graphics mode stuff got changed around in 0.17.  I don't know if that affects you.

Jim
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #67 on: June 07, 2007 »
got the error reporting thing worked out, need to put this after the pcall function: print *lua_tostring(L, 1)

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: lua?
« Reply #68 on: June 07, 2007 »
hey merick its cool that your sorting this out!

i dont know why your getting an error about a missing pointer is the fb screenptr command still supported as thats the only fb reliant function in my loader. does the freetype fonts work in 0.17?
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #69 on: June 07, 2007 »
Freetype works, or at least as much as it did before, it still has some problems with the text not being drawn depending on the length of the text and where you're trying to print it in the window

as for screenptr, I just tried a test and it still works so I don't think that's it. Heres a copy of the error log when I try to compile with your image loader included:

Code: [Select]
Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\projects\FBLua\FBIDETEMP.bas"  -lang deprecated

Compiler output:
C:/FreeBasic/projects/FBLua/FBgraphics.bi(212) warning 5(0): Implicit conversion
C:/FreeBasic/projects/FBLua/FBgraphics.bi(219) warning 5(0): Implicit conversion
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(77) error 29: Expected pointer, before '->'
                If ( BmpImageStack->Image ) Then
                                       ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(78) error 29: Expected pointer, before '->'
                    If ( BmpImageStack->Image->IntegerBuffer ) Then
                                           ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(79) error 29: Expected pointer, before '->'
                        DeAllocate( BmpImageStack->Image->IntegerBuffer )
                                                      ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(79) error 55: Type mismatch, at parameter 1 of DEALLOCATE()
                        DeAllocate( BmpImageStack->Image->IntegerBuffer )
                                                      ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(81) error 29: Expected pointer, before '->'
                    If ( BmpImageStack->Image->ByteBuffer ) Then
                                           ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(82) error 29: Expected pointer, before '->'
                        DeAllocate( BmpImageStack->Image->ByteBuffer )
                                                      ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(85) error 29: Expected pointer, before '->'
                DeAllocate( BmpImageStack->Image )
                                              ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(103) error 9: Expected expression
        If BmpSlot > NoImagesBmpStack Then Return
                                           ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(104) error 29: Expected pointer, before '->'
        BmpImageStack->Image = LoadBmp( FileName )
                                ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(238) error 29: Expected pointer, before '->'
        Dim ImageWidth As Integer = BmpImageStack->Image->SizeX
                                                               ^
C:/FreeBasic/projects/FBLua/ImageLoader.Bi(238) error 123: Too many errors, exiting

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc:   FreeBASIC Compiler - Version 0.17 (05-11-2007) for win32 (target:win32)
OS:    Windows XP (build 2600, Service Pack 2)

« Last Edit: June 07, 2007 by Merick »

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #70 on: June 10, 2007 »
New version (includes both the source and an exe): http://www.mediafire.com/?2xng1dvneyg

In this version I've added most of the flags from fbgfx.bi to the lua state. However, the only functions on the lua side that can actually use them atm are Screen() and ScreenRes(). If you want to set multiple flags you have to set them with "+", you can't use "or" because the lua or works differently than the FB or:

ScreenRes(400,400,32,1,GFX_ALWAYS_ON_TOP+GFX_NO_FRAME+GFX_ALPHA_PRIMITIVES)

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #71 on: June 11, 2007 »
woot! I've got the image pointer thing worked out now, in a day or two I should be able to post an update that can use png images (using yetifoot's png loader) and possibly bmp's as well if I can adapt nino's bmp loader

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #72 on: June 14, 2007 »
gah, this is driving me crazy. I've got the image loading and unloading worked out, but I just can't figure out how to set up lua's __gc metamethod to link the image deallocation to lua's garbage collector


http://www.mediafire.com/?3hmnetngbmg

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua?
« Reply #73 on: June 24, 2007 »
Update: test version 2007.6.23

http://www.mediafire.com/?6orj12rwjnh

Thanks to Voodooattack at the FreeBasic forums, I've now got preliminary image loading for .bmp and .png, with the memory management being done automatically in the background. (everything will be freed on program exit, or else use image = nil to remove an image from memory while the program is still running)  I've also renamed all of the screen functions, check the readme file for the new syntax.

(sorry nino, but Voodooattack wrote a different bmp loader)

*edit*
there was a bug in when trying to blit partial images, but Voodooattack just showed me what I did wrong, link updated to the fixed version
*end edit*

There's also a slight change in the way scripts are loaded. The file that's auto-run now is the "system.lua" in the main folder, atm I'm only having it load "main.lua" from the scripts folder
« Last Edit: June 24, 2007 by Merick »

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: lua!!!!
« Reply #74 on: June 24, 2007 »
thats come a long way merick congrats!

i can see how the new stuff works and it looks much better!
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua!!!!
« Reply #75 on: June 24, 2007 »
Just discovered there's a bug with fullscreen modes, at least on my winXP machine. Although you can set fullscreen, when the program exits the desktop is all messed up.

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua!!!!
« Reply #76 on: June 30, 2007 »
now with sound: http://www.mediafire.com/?9wtcwz2mt1j

check the readme for the new functions

forgot to add this to the readme -  to use the fbgfx flags in FBlua, you need to put FB. in front of them, just like using the FB namespace in FreeBasic -FB.GFX_FULLSCREEN, FB.GFX_NO_SWITCH, etc...
« Last Edit: June 30, 2007 by Merick »

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua!!!!
« Reply #77 on: July 05, 2007 »
update: version 2007.7.4

source: http://www.mediafire.com/?3mlzziparme

exe with test script: http://www.mediafire.com/?4iy1b5xglgj

Changes:

Added support for the MultiKey input function. Use like this:

If mKey(SC.ESCAPE) then
[code block]
end

see the readme for all the scancode (SC) flags

I've changed the way that GetMouse() works. Instead of using:

x,y,buttons = GetMouse()

you need only one variable:

mouse = GetMouse()

this will set "mouse" as a table with the following elements:

mouse.X = mouse x pos
mouse.Y = mouse y pos
mouse.C = true (1) if the mouse is being captured to the program window, false (nil) if not
mouse.L = left button - true if pressed
mouse.R = right button - true if pressed
mouse.M = middle button - true if pressed

SetMouse() has been changed to three different functions:

SetMouse.Visible(true/false) --set to false to hide the mouse cursor, true to show it again
SetMouse.Clip(true/false) --set to true to hold the mouse cursor inside the program window
SetMouse.Pos(x,y) - sets mouse cursor to an x,y pos inside the program window


added support for using joysticks, works similar to the new version of GetMouse(), see readme for details.


Also, I found a pdf reference file with the standard lua functions and have included it in the archives.

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: lua!!!!
« Reply #78 on: July 22, 2007 »
update: version 2007.7.22

http://www.mediafire.com/?9goouzmemzp

Changes:

Added more wrappers for the FBsound functions - see readme

Added the spPrint function. This is a test function based on a by-pixel font print function made by Joshy.

OpenGL ---

I've started adding function for OpenGL. These functions are not part of the main exe, instead I've put them into a .dll for use with the lua binary module system. To use the opengl functions you need to use require("OGlua") first.

For a demo of how to use it, the archive has a copy NeHe lesson 4 converted to lua. ATM, the functions used in this demo are the only ones implemented so far.