Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ Lua ➜ How to add Lua scripting to SMAUG

How to add Lua scripting to SMAUG

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 4  5  6  

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #30 on Tue 10 Jul 2007 02:06 AM (UTC)
Message

const unsigned char * text = luaL_checkstring (L, 1);


becomes


const unsigned char * text = (const unsigned char*) luaL_checkstring (L, 1);


and


maxvalue = 4503599627370496 / base; // 2^52


becomes


maxvalue = ((Integer) 4503599627370496) / ((Integer) base); // 2^52


That should do it...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Gatewaysysop2   USA  (146 posts)  Bio
Date Reply #31 on Tue 10 Jul 2007 02:14 AM (UTC)
Message
The maxvalue line is still generating the same error as before. Any other ideas on how to get around this?

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #32 on Tue 10 Jul 2007 02:18 AM (UTC)
Message
Err... well you could try dividing it by 64 (using an external calculator), and then adding the result together 64 times. (Adjust 64 by whatever factor is needed to bring the result to a value that fits inside an int.)

Then you'd divide that by 'base'.

Not a pretty solution, but . . .

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #33 on Tue 10 Jul 2007 02:53 AM (UTC)
Message
Don't get too bogged down with this function. I am not even using bit_tonumber at this stage. Just comment out the entire function, and remove the line:


 {"tonumber", bit_tonumber},  // new by Nick


... which is near the end of the file.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Gatewaysysop2   USA  (146 posts)  Bio
Date Reply #34 on Tue 10 Jul 2007 03:08 AM (UTC)

Amended on Tue 10 Jul 2007 03:10 AM (UTC) by Gatewaysysop2

Message
At this point, that works for me. :)

Looks like Lua is in, up and running at this point. I'm gonna have to get those Lua texts I saw on Amazon and start pouring through at at work when I'm supposed to be programming in SAS (which is far, far too easy by comparison to C!).

Kudos again for all your help guys!

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #35 on Tue 10 Jul 2007 03:24 AM (UTC)

Amended on Tue 10 Jul 2007 03:25 AM (UTC) by Nick Gammon

Message
Excellent!

This is what I had to do to get it to compile under Cygin:


  • Install Lua 5.1 and make it like this:

    
    make "CC=gcc -mno-cygwin" mingw
    


  • Copy various Lua .h files around so they could be found:

    
    cp ~/lua-5.1.1/src/lua.h /usr/include
    cp ~/lua-5.1.1/src/luaconf.h /usr/include
    cp ~/lua-5.1.1/src/lualib.h /usr/include
    cp ~/lua-5.1.1/src/lauxlib.h /usr/include
    


  • Edit the Makefile that comes with SMAUG Fuss to uncomment the line about Cygwin:

    
    #Uncomment to compile in Cygwin
    CYGWIN = -DCYGWIN
    


  • Copy the Lua DLL into the src directory:

    
     cp ~/lua-5.1.1/src/lua51.dll ~/smaugfuss/src
    


  • Amend the Makefile to link against the Lua DLL:

    
    L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) lua51.dll -lm
    


  • Edit the lua_bits.c file to remove the bit_tonumber function.

  • Edit the lua_bits.c file to comment out or remove this line:

    
      {"tonumber", bit_tonumber},  // new by Nick
    



Then it should compile and run OK.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #36 on Fri 27 Jul 2007 07:41 PM (UTC)
Message
Well, I've tried to add the task, whereis and the reset modules to my SMAUG 1.4a source. I've fixed most of the errors that popped up that were mostly 'caused by tweaks/changes that had been made to the source. However, there's a set of errors that keep coming up and I'm not quite sure what should be done to fix them.

lua_scripting.c: In function `L_getchar':
lua_scripting.c:123: `LUA_ENVIRONINDEX' undeclared (first use in this function)
lua_scripting.c:123: (Each undeclared identifier is reported only once
lua_scripting.c:123: for each function it appears in.)
lua_scripting.c: In function `L_system_info':
lua_scripting.c:365: warning: implicit declaration of function `lua_setfield'
lua_scripting.c: In function `L_mob_info':
lua_scripting.c:1016: warning: passing arg 2 of `lua_pushstring' from incompatible pointer type
lua_scripting.c: In function `build_nested_object':
lua_scripting.c:1645: warning: implicit declaration of function `lua_objlen'
lua_scripting.c:1650: warning: implicit declaration of function `lua_getfield'
lua_scripting.c: In function `RegisterLuaRoutines':
lua_scripting.c:2444: `LUA_ENVIRONINDEX' undeclared (first use in this function)
lua_scripting.c:2450: warning: implicit declaration of function `luaL_register'
lua_scripting.c: In function `open_lua':
lua_scripting.c:2475: warning: implicit declaration of function `luaL_newstate'
lua_scripting.c:2475: warning: initialization makes pointer from integer without a cast
lua_scripting.c:2484: warning: implicit declaration of function `luaL_openlibs'
lua_scripting.c: In function `open_mud_lua':
lua_scripting.c:2677: warning: assignment makes pointer from integer without a cast


I searched through the smaugfuss files to find where/if LUA_ENVIRONINDEX was defined and I can't seem to find it anywhere. Also, there are a lot of implicit declarations of lua functions that I'm not sure how to fix either.

Any suggestions?
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #37 on Fri 27 Jul 2007 09:00 PM (UTC)
Message
They will be in the lua include files mentioned above. Make sure you have installed Lua, and that the include files are in your normal include place (/usr/include).

If you can't modify that, copy the Lua includes to your src directory, and change the includes to use local files. eg.

Change:


#include <lua.h>

to:

#include "lua.h"


I think those includes are just in mud.h.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #38 on Fri 27 Jul 2007 09:06 PM (UTC)
Message
My server admins installed Lua on their system, so these files should be available. Would the version of Lua installed make a difference to which header file should be included?
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #39 on Fri 27 Jul 2007 09:24 PM (UTC)
Message
Ok, I copied the header files into the src directory and still comes up with the same errors. I'm thinking there's a version conflict. They've got Lua 5.0.2 installed. What version do these changes require?
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #40 on Fri 27 Jul 2007 09:29 PM (UTC)
Message
My Lua code used some of the features of Lua 5.1, from memory.

You should be able to type "lua" at the command prompt to see if Lua is available. Also check that the include files are where you expect them. Perhaps they installed Lua without copying the include files.

There is absolutely nothing to stop you doing a local install. To quote from the INSTALL file that comes with Lua:


  If you want to install Lua locally, then do "make local". This will
  create directories bin, include, lib, man, and install Lua there as
  follows:

    bin:        lua luac
    include:    lua.h luaconf.h lualib.h lauxlib.h lua.hpp
    lib:        liblua.a
    man/man1:   lua.1 luac.1


That gives you the include files, and the liblua.a that you link against in the Makefile.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #41 on Fri 27 Jul 2007 09:30 PM (UTC)
Message
Quote:

They've got Lua 5.0.2 installed. What version do these changes require?


You replied while I was typing. :)

Lua 5.1 would be good, just use a local version as I described above. The size is so small it won't matter if you aren't using the one they installed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #42 on Sat 28 Jul 2007 12:32 AM (UTC)
Message
This is beginning to become a pain in the neck. I know the payoff will be worth it once I get this all right.

After, finally, successfully installing Lua 5.1.2 as local, I go to compile the MUD code. I get so many errors, well actually warnings, that it scrolls through about 3 or 4 pages worth.

Small section of the errors/warnings:
lua_scripting.c: In function `L_mob_info':
lua_scripting.c:1016: warning: passing arg 2 of `lua_pushstring' from incompatible pointer type
lua_scripting.c: In function `RegisterLuaRoutines':
lua_scripting.c:2450: warning: implicit declaration of function `luaL_register'
lua_scripting.c: In function `open_lua':
lua_scripting.c:2475: warning: implicit declaration of function `luaL_newstate'
lua_scripting.c:2475: warning: initialization makes pointer from integer without a cast
lua_scripting.c:2484: warning: implicit declaration of function `luaL_openlibs'
lua_scripting.c: In function `open_mud_lua':
lua_scripting.c:2677: warning: assignment makes pointer from integer without a cast
gcc -c  -O -g3 -Wall -Wuninitialized    -DSMAUG  -DTIMEFORMAT   lua_bits.c
lua_bits.c: In function `luaopen_bits':
lua_bits.c:138: warning: implicit declaration of function `luaL_register'
gcc -c  -O -g3 -Wall -Wuninitialized    -DSMAUG  -DTIMEFORMAT   mt19937ar.c
gcc -c  -O -g3 -Wall -Wuninitialized    -DSMAUG  -DTIMEFORMAT   lua_tables.c
distcc[21152] ERROR: compile ***** on localhost failed
lua_tables.c:79: `AT_BLACK_BLINK' undeclared here (not in a function)
lua_tables.c:79: initializer element is not constant
lua_tables.c:79: (near initialization for `at_colours_table[34].val')
lua_tables.c:79: initializer element is not constant
lua_tables.c:79: (near initialization for `at_colours_table[34]')
lua_tables.c:79: initializer element is not constant
lua_tables.c:79: (near initialization for `at_colours_table[35]')

This goes on for many lines giving warnings for the same things through line 161 of lua_tables.c. This is a lot more than I was getting before.

What in the world have I done wrong? Suggestions for fixing this mess?

If this has something to do with linking against the liblua.a file in the Makefile, then I'm not sure I know what to do with that...
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #43 on Sat 28 Jul 2007 12:45 AM (UTC)
Message
All this stuff:

warning: implicit declaration of function `luaL_register'

Looks like it didn't find the lua .h files. What were the first few errors? They are usually the ones to fix.

Make sure the files:


lua.h
luaconf.h
lualib.h
lauxlib.h


... are in your src directory, and that you changed mud.h to use the quotes rather than the angled brackets, like I mentioned further up. There may be a file included from one of them (luaconfig.h or something) - just make sure you got all of the include files.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #44 on Sat 28 Jul 2007 12:46 AM (UTC)
Message
Further fiddling...

After making the includes use local headers it cleared up some of the warnings. lua_scripting.c still leaves me with this:
lua_scripting.c: In function `L_mob_info':
lua_scripting.c:1016: warning: passing arg 2 of `lua_pushstring' from incompatible pointer type

All the same errors/warnings remain for lua_tables.c though.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


243,866 views.

This is page 3, subject is 6 pages long:  [Previous page]  1  2  3 4  5  6  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.