Game Maker Community: Gmlua [v0.2 Last Update: 26 December 2009] - Game Maker Community

Jump to content

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • This topic is locked

Gmlua [v0.2 Last Update: 26 December 2009] *closed at owner's request*

#1 User is offline   Kofel 

  • GMC Member
  • Group: GMC Member
  • Posts: 49
  • Joined: 15-October 07

Posted 05 March 2009 - 06:56 AM

Last update: 26 December 2009
Version: 0.2
gmLua

It's Lua interpreter wrapper for Game Maker which make able to execute Lua scripts, it help you with making your game moddable.

Using standard execute_string isn't too much expensive and safe. In gmLua you decide which GM functions and scripts will be avaiable in Lua.

Manual:
  • luaNew() Initalize Lua interpeter for that object in which you call it, returns pointer
  • luaRegister( Pointer, LuaFunctionName, scriptPointer ) register your script as Lua function, or:
  • luaRegister( Pointer, GMFunctionName ) make able to call GM function in Lua, such as: luaRegister( Pointer, "show_message" );
  • luaLoadFile( Pointer, FileName ) Load a Lua script file
  • luaEvent( Pointer, EventName, ... ) Calls a function in Lua code called like EventName, it takes also up to 14 arguments
  • luaCall( Pointer, LuaFunctionName, ... ) Calls a Lua function
  • luaSetErrorScript( Pointer, GMScriptName ) Set your script as a error handle instead of classic show_message
  • luaDestroy( Pointer ) You don't need solution? :> // You don't have call it ;o


Package includes Lua dll, example and gmLua binary.

If you found any bug please post it here: http://code.google.c...lua/issues/list

Download:


More info: gmLua at Google Code

Thanks to Snake_PL for make GMAPI <3

Source code is avaiable on SVN:

SVN said:



GMAPI ( both gmLua ) for now works only with GM 6 and 7. No 8.0 support.

gmLua now is developed only by TheMagicNumber.

Greetings,
Kofel.

This post has been edited by KC LC: 01 May 2010 - 10:13 AM

0

#2 User is offline   allong 

  • GMC Member
  • Group: GMC Member
  • Posts: 183
  • Joined: 24-December 04

Posted 05 March 2009 - 10:30 AM

Wow, that's pretty cool. Could it be as extensive as the functions used by the Half-life2 source engine or World Of Warcraft? Please post more info on possibilities and what the Dll allows you to do
0

#3 User is online   TheMagicNumber 

  • HJIFHVJSXUVBHIGYGFFS
  • Group: GMC Member
  • Posts: 3848
  • Joined: 09-December 07

Posted 05 March 2009 - 11:11 AM

You can use all the functions and features in Lua, but you can't extend on it.

And yes, make an example. :blink:
0

#4 User is offline   Kofel 

  • GMC Member
  • Group: GMC Member
  • Posts: 49
  • Joined: 15-October 07

Posted 05 March 2009 - 03:05 PM

Thanks for comments.

Simply, DLL allow you to create flexible game or game server for which user/developer can make nice scripts and events. :>

Mechanism is pretty cute, developer make a hooks in own game, example: ( step event )
if( player_damage )
{
	if( lua_event( "onPlayerDamage", instance_id, other_player_id ) ) //First argument is attacked player ( hmm... simply instance id ) and second is enemy which attack you ( also instance id )
	{ // Instructions below doesn't be executed if we return 1; in Lua function :>
		player.health -= 100;
	}
}


getPlayerHealth script in GM:
return argument0.health;


Create step:
lua_state();
lua_register( "getPlayerHealth", getPlayerHealth );
lua_load( "script.lua" );


And Lua code:
function onPlayerDamage( player, attacker )
	if( getPlayerHealth( player ) < 99 ) then
		return 1
	end
end


That example is so simple. :> I will create other example in future ( more advanced ), I think in this week.
0

#5 User is online   TheMagicNumber 

  • HJIFHVJSXUVBHIGYGFFS
  • Group: GMC Member
  • Posts: 3848
  • Joined: 09-December 07

Posted 05 March 2009 - 08:20 PM

Put it in a file, and does lua_event() just call a function in the Lua script?
0

#6 User is offline   Kofel 

  • GMC Member
  • Group: GMC Member
  • Posts: 49
  • Joined: 15-October 07

Posted 06 March 2009 - 07:28 AM

Yes :>
0

#7 User is offline   Hach-Que 

  • RoketGames Admin
  • Group: GMC Member
  • Posts: 1448
  • Joined: 08-December 04

Posted 06 March 2009 - 09:26 AM

I tried to make a test example to see how fast it ran and the game just closed instantly on run :/
0

#8 User is online   TheMagicNumber 

  • HJIFHVJSXUVBHIGYGFFS
  • Group: GMC Member
  • Posts: 3848
  • Joined: 09-December 07

Posted 06 March 2009 - 10:52 AM

Can you put the examples in editable files instead of posting events and code on the forum?

@Hach-Que:
Was it that fast or that bad...
0

#9 User is offline   Hach-Que 

  • RoketGames Admin
  • Group: GMC Member
  • Posts: 1448
  • Joined: 08-December 04

Posted 06 March 2009 - 12:08 PM

There's no game_end() call in my code. It just causes the game to crash.
0

#10 User is offline   Kofel 

  • GMC Member
  • Group: GMC Member
  • Posts: 49
  • Joined: 15-October 07

Posted 06 March 2009 - 03:46 PM

Damn it! I forgot, that works only with GM 7, I promise I'll post fixed version with GM 6 ( 5 maybe ) with example today. ;>


EDIT: Fixed version in this same link. I hope it will work.

This post has been edited by Kofel: 06 March 2009 - 11:01 PM

0

#11 User is offline   Hach-Que 

  • RoketGames Admin
  • Group: GMC Member
  • Posts: 1448
  • Joined: 08-December 04

Posted 07 March 2009 - 01:50 AM

There's only one problem with that solution. I am using Game Maker 7.
0

#12 User is offline   ditdingiscool 

  • GMC Member
  • Group: GMC Member
  • Posts: 335
  • Joined: 06-October 07

Posted 09 March 2009 - 05:38 PM

NEAT!!! i was just thinking 'bout that today, man thats cool, testing it now...
0

#13 User is offline   newbie013 

  • GMC Member
  • Group: GMC Member
  • Posts: 47
  • Joined: 22-August 07

Posted 17 March 2009 - 02:06 PM

Can this dll load mutiple lua scripts at one time.??
0

#14 User is offline   ditdingiscool 

  • GMC Member
  • Group: GMC Member
  • Posts: 335
  • Joined: 06-October 07

Posted 17 March 2009 - 04:33 PM

View Postnewbie013, on Mar 17 2009, 03:09 PM, said:

Can this dll load mutiple lua scripts at one time.??

yes, but one script has to finish before you start the next one,


EDIT:for some reason, two scripts running at the same time will mess up, i registered a function to change the speed off the calling object, and i have two off those objects, both with a different script, but their speed ends up the same(while one should be 5 and the other should be 1)

oh, and it would be nice if you could make your own error dialog...

This post has been edited by ditdingiscool: 17 March 2009 - 04:52 PM

0

#15 User is offline   newbie013 

  • GMC Member
  • Group: GMC Member
  • Posts: 47
  • Joined: 22-August 07

Posted 17 March 2009 - 06:01 PM

lua_event gives me the whole time a unexpected error. :D
0

#16 User is offline   ditdingiscool 

  • GMC Member
  • Group: GMC Member
  • Posts: 335
  • Joined: 06-October 07

Posted 19 March 2009 - 02:53 PM

View Postnewbie013, on Mar 17 2009, 07:04 PM, said:

lua_event gives me the whole time a unexpected error. :lol:

weird... are you using gm7?
0

#17 User is offline   Tahnok 

  • Friendly Madman
  • Group: GMC Member
  • Posts: 1713
  • Joined: 11-March 04

Post icon  Posted 19 March 2009 - 10:18 PM

This is a really fascinating DLL. It could really allow for some in-depth user mods to games. However, the buggyness people are experiencing makes me hesitant to use it in a serious project.

On my PC, opening the gm6 example in GM6 results in the game freezing when a script is called. Opening the same GM6 file in GM7 works perfectly.

Edit: Opening the LOL example in GM6 gives me an actual "unexpected error" error message. Opening it in GM7 works perfectly. So it appears its still rather buggy in GM6.

This post has been edited by Tahnok: 19 March 2009 - 11:51 PM

0

#18 User is online   TheMagicNumber 

  • HJIFHVJSXUVBHIGYGFFS
  • Group: GMC Member
  • Posts: 3848
  • Joined: 09-December 07

Posted 20 March 2009 - 03:03 AM

View PostKofel, on Mar 6 2009, 11:49 AM, said:

Damn it! I forgot, that works only with GM 7

Maybe your 'fix' wasn't too good.

What was this DLL made in? Can you give us (or me) some more information about the exported functions?
0

#19 User is offline   Mailas 

  • Send in the Mail
  • Group: GMC Member
  • Posts: 4895
  • Joined: 22-December 05

Posted 21 March 2009 - 11:42 PM

Oh wow! I've been waiting for something like this for a while! Thanks a bunch!!
Please do add an example, I would like to see how it works.
0

#20 User is offline   newbie013 

  • GMC Member
  • Group: GMC Member
  • Posts: 47
  • Joined: 22-August 07

Posted 22 March 2009 - 11:43 AM

I've tryed to change dll_cdecall to dll_stdcall but that doesn't work. I'm still keeping unexpected error in gm6 :)
0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users