Jump to content


Photo

Gmlua [v0.4]


  • Please log in to reply
62 replies to this topic

#41 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 888 posts

Posted 22 March 2011 - 12:48 AM

I found a problem:

When I tried registering more than 50 scripts using luaRegister, it will randomly crash the game. It doesn't show an error, it just crashes.

I use a shortcut script to determine the name of the script I'm registering and directly apply that to the Lua reference name like so:
// luaEngineRegister(lua, script);
if(!script_exists(argument1)) return 0;
return luaRegister(argument0, script_get_name(argument1), argument1);

And here's what does the crashing.
lua = luaNew();
if(!lua) show_error("Failed to create a new Lua instance.", true);

// Register functions to the Lua instance
luaRegister(lua, "ShowMessage", ShowMessage);
luaRegister(lua, "GetFramerate", GetFramerate);
luaRegister(lua, "IsAltKeyDown", IsAltKeyDown);
luaRegister(lua, "IsShiftKeyDown", IsShiftKeyDown);
luaRegister(lua, "IsCtrlKeyDown", IsCtrlKeyDown);
luaRegister(lua, "Screenshot", Screenshot);
luaRegister(lua, "ReloadUI", ReloadUI);

luaLoadFile(lua, "Interface\base\Engine.lua");

//luaEngineRegister(lua, CreateFrame);
//luaEngineRegister(lua, MakeIntoActionBar);

//luaEngineRegister(lua, GetFont);
//luaEngineRegister(lua, GetJustifyH);
luaEngineRegister(lua, GetJustifyV);
luaEngineRegister(lua, GetText);
luaEngineRegister(lua, GetTextColor);
luaEngineRegister(lua, GetTextHeight);
luaEngineRegister(lua, GetTextWidth);
luaEngineRegister(lua, SetFont);
luaEngineRegister(lua, SetFontName);
luaEngineRegister(lua, SetJustifyH);
luaEngineRegister(lua, SetJustifyV);
luaEngineRegister(lua, SetText);
luaEngineRegister(lua, SetTextColor);

luaEngineRegister(lua, AddLine);
luaEngineRegister(lua, AddDoubleLine);
luaEngineRegister(lua, AddTexture);
luaEngineRegister(lua, AddWord);
luaEngineRegister(lua, NewLine);
luaEngineRegister(lua, ClearLines);

luaEngineRegister(lua, ClearAllPoints);
luaEngineRegister(lua, GetAlpha);
luaEngineRegister(lua, GetBottom);
luaEngineRegister(lua, GetCenterScreenX);
luaEngineRegister(lua, GetCenterScreenY);
luaEngineRegister(lua, GetCenterX);
luaEngineRegister(lua, GetCenterY);
luaEngineRegister(lua, GetHeight);
luaEngineRegister(lua, GetLeft);
luaEngineRegister(lua, GetRight);
luaEngineRegister(lua, GetScreenBottom);
luaEngineRegister(lua, GetScreenLeft);
luaEngineRegister(lua, GetScreenRight);
luaEngineRegister(lua, GetScreenTop);
luaEngineRegister(lua, GetTop);
luaEngineRegister(lua, GetWidth);
luaEngineRegister(lua, SetAllPoints);
luaEngineRegister(lua, SetAlpha);
luaEngineRegister(lua, SetDimensions);
luaEngineRegister(lua, SetHeight);
luaEngineRegister(lua, SetPoint);
luaEngineRegister(lua, SetWidth);

luaEngineRegister(lua, GetID);
luaEngineRegister(lua, GetName);
luaEngineRegister(lua, GetObjectType);
luaEngineRegister(lua, GetParent);
/*
luaEngineRegister(lua, GetScript);
luaEngineRegister(lua, Hide);
luaEngineRegister(lua, RegisterForClicks);
luaEngineRegister(lua, SetScript);
luaEngineRegister(lua, Show);
luaEngineRegister(lua, MakeVisible);
luaEngineRegister(lua, MakeInvisible);
luaEngineRegister(lua, Toggle);*/
It doesn't matter which of these commented functions I call, 1 more of them (51 total) that I call, it will 100% guaranteed crash the program. I thought it might have been too much to handle at one time, so I split it up into alarm events separated by 6 steps each. On the 51st script call, it crashed the program.

-DF81
Edit: Whoops! Hold on, I found the problem. Scratch what I wrote above.

Edited by DFortun81, 22 March 2011 - 12:51 AM.

  • 0

#42 Kofel

Kofel

    GMC Member

  • New Member
  • 50 posts

Posted 10 April 2011 - 12:16 PM

-DF81
Edit: Whoops! Hold on, I found the problem. Scratch what I wrote above.

Can you describe what gone wrong?


I glad to say, that project hosting moved on GitHub. Source code, and issue tracker can be now found on: https://github.com/Kofel/gmLua
Happy forking guys! I know that project is dead, and unuseful. :D

Edited by Kofel, 10 April 2011 - 12:18 PM.

  • 0

#43 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 888 posts

Posted 10 April 2011 - 07:47 PM

Can you describe what gone wrong?

The problem was caused by an additional feature that I added to the DLL. (Where it would automatically instantiate table hierarchy so that it could register parent table functions.)

luaEngineRegister does this:
// luaEngineRegister(lua, function);
luaRegister(argument0, "Engine." + script_get_name(argument1), argument1);

Traversing through the hierarchy of tables would cause a overload of stack access and crash the DLL. I solved this problem by setting a "parent" directory inside of the current directory's hierarchy.
  • 0

#44 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 278 posts
  • Version:GM:Studio

Posted 31 May 2011 - 09:52 AM

Guys what does Lua even offer to GM that GM does not have i want a good answear...
  • 0

#45 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 31 May 2011 - 11:17 AM

Guys what does Lua even offer to GM that GM does not have i want a good answear...

http://en.wikipedia.org/wiki/Lua_(programming_language)

I can see quite a few features on that page. If you look into the standard functions Lua has, you'll see more.
  • 0

#46 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 888 posts

Posted 31 May 2011 - 11:32 AM

Guys what does Lua even offer to GM that GM does not have i want a good answear...

Lists, dictionaries, and tables in general are FAR easier and more efficient in Lua. Also, anything you create in Lua can be transferred over to a different medium that uses Lua as its interface. For example, I can make a mod for World of Warcraft, then transfer it over to my game and back so long as I implement the API functions that I use in the WoW API for my game. I've actually created a fully working WoW API in GM and I am currently using it to develop for World of Warcraft. This means that I don't even need a World of Warcraft account to make addons for it anymore! :D

It's a bit slower in the game engine than it is in WoW, but that's the side effect of using Game Maker to perform such tasks.
-DF81

Edited by DFortun81, 12 June 2011 - 10:14 PM.

  • 0

#47 paul23

paul23

    GMC Member

  • Global Moderators
  • 3383 posts
  • Version:GM8

Posted 31 May 2011 - 12:49 PM

Also LUA is a generally "understood" language for mod/map editing..

So if you want an advanced mod-system added to your game, you'll want to load/execute LUA code (and the LUA calls the internal GM functions) instead of gamemaker code. - It allows other people to actually write mods without learning too many specific things about your game.. (And gamemaker)
  • 0

#48 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 278 posts
  • Version:GM:Studio

Posted 12 June 2011 - 03:14 PM

I find no use for this in my games really... but sure it is good for 3D maps but not for 2D...
  • 0

#49 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 12 June 2011 - 04:44 PM

I find no use for this in my games really... but sure it is good for 3D maps but not for 2D...

Uh no. It works just as well in both types of games. Why would they be different?
  • 0

#50 ash47

ash47

    O_o

  • GMC Member
  • 1326 posts

Posted 26 June 2011 - 11:31 AM

I find no use for this in my games really... but sure it is good for 3D maps but not for 2D...

You're right! It's amazing for 3D maps, I made my map system use LUA, a modified version of this DLL I made, and it's awesome, it allows me to make the map files a lot smaller, and I can give the map instructions :P
  • 0

#51 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 888 posts

Posted 11 August 2011 - 12:16 PM

Are you still working on this project? I'd like to see a port to GM 8.1 if possible. If not, I'll be starting up a rewrite of what you have just to see if the performance gains in GM8.1 are worth going after.
  • 0

#52 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 14 August 2011 - 09:11 PM

I don't own GM 8.1 so no.
  • 1

#53 Karjam

Karjam

    GMC Member

  • New Member
  • 8 posts

Posted 03 September 2011 - 06:54 PM

You know that you can JUST embend the source code of the interpreter into the project and use it like that, right? You won't get prosecuted for that. The only requirement for doing that, is to post the following stuff somewhere in the program or documentation:

Copyright © 1994-2008 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


Also, since some versions of Game Maker (particulary GM8.1) does not have a GMAPI port, can you please redesign the DLL as to NOT use it? I can already see some workarounds in implementing it.

Edited by Karjam, 04 September 2011 - 09:11 AM.

  • 0

#54 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 278 posts
  • Version:GM:Studio

Posted 03 September 2011 - 08:32 PM

I don't own GM 8.1 so no.


Then you must be a spammer with no money.
  • 0

#55 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 03 September 2011 - 08:35 PM


I don't own GM 8.1 so no.


Then you must be a spammer with no money.

What? I can't just not buy it? I don't need it. I don't want it.
  • 1

#56 Karjam

Karjam

    GMC Member

  • New Member
  • 8 posts

Posted 04 September 2011 - 09:10 AM

What? I can't just not buy it? I don't need it. I don't want it.


If you have GM8, you can get GM8.1 for free.

Anyway, You probably need it for compatabilitty reasons anyway.

Also, please reply to my thread at the top.
  • 0

#57 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 September 2011 - 10:43 PM


What? I can't just not buy it? I don't need it. I don't want it.


If you have GM8, you can get GM8.1 for free.

Anyway, You probably need it for compatabilitty reasons anyway.

Also, please reply to my thread at the top.

I've never really used GameMaker and I don't want to start now. Ask someone else.
  • 0

#58 e_barroga

e_barroga

    ES Studios Leader

  • GMC Member
  • 2443 posts

Posted 26 September 2011 - 11:20 PM



What? I can't just not buy it? I don't need it. I don't want it.


If you have GM8, you can get GM8.1 for free.

Anyway, You probably need it for compatabilitty reasons anyway.

Also, please reply to my thread at the top.

I've never really used GameMaker and I don't want to start now. Ask someone else.

Coming from a guy with 5000 posts on the forums dedicated to Game Maker. ;)
  • 0

#59 ash47

ash47

    O_o

  • GMC Member
  • 1326 posts

Posted 27 September 2011 - 12:42 AM

The DLL I used in http://gmc.yoyogames...howtopic=520185 is based off GMLUA :P
  • 0

#60 Karjam

Karjam

    GMC Member

  • New Member
  • 8 posts

Posted 13 August 2012 - 07:20 PM

NOTE: It is now possible to port this to GameMaker 8.1 properly, as there's now another version of GMApi that supports it. Posted Image
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users