[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Lua
. . -> [Subject]  How to add Lua scripting to SMAUG

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: How to add Lua scripting to SMAUG
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2  3  4  5  6 

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Thu 05 Apr 2012 12:47 AM (UTC)  quote  ]
Message
I don't think so, this thread is about 5 years old and the source is probably 2 PCs back, plus I wouldn't be sure what other changes I made.

But if you download the linked files and do a bit of fiddling around it should be possible to get it working.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Wjmurdick   (13 posts)  [Biography] bio
Date Wed 04 Apr 2012 04:59 PM (UTC)  quote  ]
Message
Thread rezzing here, but I wanted to ask if you had a version of SmaugFuss 1.9 with Lua already integrated?
[Go to top] top

Posted by Orik   USA  (182 posts)  [Biography] bio
Date Sat 19 Jul 2008 07:17 PM (UTC)  quote  ]

Amended on Sat 19 Jul 2008 07:44 PM (UTC) by Orik

Message
ok. I've been having a problem with the undefined references as well. Here is the errors.


make -s smaug
/***/baklua/lib/liblua.a(ldebug.o)(.text+0x92f): In function `luaG_runerror':
: undefined reference to `__stack_chk_fail'
/***/baklua/lib/liblua.a(ldo.o)(.text+0x51d): In function `luaD_callhook':
: undefined reference to `__stack_chk_fail'
/***/baklua/lib/liblua.a(ldump.o)(.text+0x3f0): In function `luaU_dump':
: undefined reference to `__stack_chk_fail'
/***/baklua/lib/liblua.a(lobject.o)(.text+0x68c): In function `luaO_pushvfstring':
: undefined reference to `__stack_chk_fail'
/***/baklua/lib/liblua.a(lundump.o)(.text+0x74d): In function `luaU_undump':
: undefined reference to `__stack_chk_fail'
/***/baklua/lib/liblua.a(lvm.o)(.text+0x82a): more undefined references to `__stack_chk_fail' follow


I have lua local on my server. do I need to change something in ldo.c, ldump.c and so on? or is it something in my actual smaug src files?


******************EDIT*******************
Turns out it was a lua issue so I just reinstalled lua locally and it worked.
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Thu 26 Jun 2008 01:04 AM (UTC)  quote  ]
Message
Glad you like it!

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by 6D STAFF   (1 post)  [Biography] bio
Date Wed 25 Jun 2008 11:05 AM (UTC)  quote  ]
Message
6 Dragons mud is now using Lua Code....

THANKS NICK!!!

http://6dragons.org
[Go to top] top

Posted by Keberus   (31 posts)  [Biography] bio
Date Mon 01 Oct 2007 09:26 AM (UTC)  quote  ]
Message
You were right on the money. Btw regular FotE isn't compiled with C++ but a while back I started using the C++ compiler instead of the C one. Thanks for the help, I looked over the code probably 30 times before posting and couldn't figure it out for the life of me. Never would have thought that the problem was with me using the C++ compiler.

Thanks Again,
KeB
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Mon 01 Oct 2007 04:25 AM (UTC)  quote  ]
Message
Is FotE done in C++ (rather than C?).

If so, that would explain the missing references. You will need to put extern "C" around your .h files. I am not at my usual PC right now, but it will look something like this:


extern "C"  {
#include "lua.h"
// other Lua includes
}


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Keberus   (31 posts)  [Biography] bio
Date Mon 01 Oct 2007 01:59 AM (UTC)  quote  ]
Message
Okay, I am trying to add lua to my FotE based mud. I got all of the regular errors out and get to the end. I think there's a problem linking the lua headers but don't know why. Here are the errors...


lua_scripting.c:732: undefined reference to `lua_isnumber(lua_State*, int)'
lua_scripting.c:739: undefined reference to `lua_createtable(lua_State*, int, int)'
lua_scripting.c:743: undefined reference to `lua_pushstring(lua_State*, char const*)'
lua_scripting.c:743: undefined reference to `lua_setfield(lua_State*, int, char const*)'


Thats not all of them, but a bunch that look like that. I have the -llua in the L_FLAGS of my makefile like I read to do. Also, I downloaded FUSS with lua support added by Nick, and it compiled error free. So can anyone tell me what I am doing wrong. Apparently the lua is working globally for it to work with FUSS w/lua.

Thanks in Advance,
KeB
[Go to top] top

Posted by Orik   USA  (182 posts)  [Biography] bio
Date Fri 17 Aug 2007 08:56 PM (UTC)  quote  ]

Amended on Fri 17 Aug 2007 08:57 PM (UTC) by Orik

Message
I installed it locally and it worked first time.

For future reference, to make locally, you have to do this:

make linux

then

make local

Then point to your liblua.a file in your Makefile:

L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) ~/your/folder/lib/liblua.a -lm
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 17 Aug 2007 09:41 AM (UTC)  quote  ]
Message
What kind of errors are we talking about here?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Orik   USA  (182 posts)  [Biography] bio
Date Fri 17 Aug 2007 06:56 AM (UTC)  quote  ]
Message
Ok, my server has lua 5.1 on it. I put my mud on and tried to compile. It compiles all the way to the very end and them I get a ton of undefined references. I'm not linking correctly or something, I don't know.

here's my makefile:

CC      = g++
#PROF    = -p

#Uncomment to compile in Cygwin
#CYGWIN = -DCYGWIN

#Uncomment the line below if you are getting undefined references to dlsym, dlopen, and dlclose.
#Comment it out if you get errors about ldl not being found.
NEED_DL = -ldl

#Some systems need this for dynamic linking to work.
EXPORT_SYMBOLS = -export-dynamic

# Uncomment the two lines below if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV
#SOLARIS_LINK = -lnsl -lsocket

#IMC2 - Comment out to disable IMC2 support
IMC = 1

W_FLAGS = -Wall -Werror -Wshadow -Wformat-security -Wpointer-arith -Wcast-align -Wredundant-decls -Wconversion

C_FLAGS = -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF) $(EXPORT_SYMBOLS)
L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) ~/old/lua/lib/liblua.a -llua -lm
#D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this.
D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK)

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c ban.c board.c boards.c \
          build.c chess.c clans.c color.c comm.c comments.c const.c db.c deity.c \
          dns.c fight.c handler.c hashstr.c hint.c hotboot.c imm_host.c interp.c \
          liquids.c magic.c makeobjs.c mapout.c mapper.c mccp.c \
          misc.c mpxset.c mud_comm.c mud_prog.c news.c planes.c player.c polymorph.c \
          renumber.c reset.c save.c services.c sha256.c shops.c skills.c special.c tables.c \
          track.c update.c variables.c lua_scripting.c lua_bits.c mt19937ar.c lua_tables.c \
          mem.c


ifdef IMC
   C_FILES := imc.c $(C_FILES)
   C_FLAGS := $(C_FLAGS) -DIMC -DIMCSMAUG
endif

O_FILES := $(patsubst %.c,o/%.o,$(C_FILES))

H_FILES = $(wildcard *.h)

all:
        $(MAKE) -s smaug
        $(MAKE) -s dns

# pull in dependency info for *existing* .o files
-include dependencies.d

ifdef CYGWIN
smaug: $(O_FILES)
        rm -f smaug.exe
        dlltool --export-all --output-def smaug.def $(O_FILES)
        dlltool --dllname smaug.exe --output-exp smaug.exp --def smaug.def
        $(CC) -o smaug.exe $(O_FILES) smaug.exp $(L_FLAGS)
        @echo "Generating dependency file ...";
        @$(CC) -MM $(C_FLAGS) $(C_FILES) > dependencies.d
        @perl -pi -e 's.^([a-z]).o/$$1.g' dependencies.d
        @echo "Done compiling mud.";
        chmod g+w smaug.exe
        chmod a+x smaug
        chmod g+w $(O_FILES)

clean:
        @rm -f o/*.o smaug dependencies.d resolver resolver.o *~
endif

dns: resolver.o
        rm -f resolver
        $(CC) $(D_FLAGS) -o resolver resolver.o
        @echo "Done compiling DNS resolver.";
        chmod g+w resolver
        chmod a+x resolver
        chmod g+w resolver.o

indent:
        indent -ts3 -nut -nsaf -nsai -nsaw -npcs -npsl -ncs -nbc -bls -prs -bap -cbi0 -cli3 -bli0 -l125 -lp -i3 -cdb -c1 -cd1 -sc -pmt $(C_FILES)
        indent -ts3 -nut -nsaf -nsai -nsaw -npcs -npsl -ncs -nbc -bls -prs -bap -cbi0 -cli3 -bli0 -l125 -lp -i3 -cdb -c1 -cd1 -sc -pmt $(H_FILES)

indentclean:
        rm *.c~ *.h~

o/%.o: %.c
        echo "  Compiling $@....";
        $(CC) -c $(C_FLAGS) $< -o $@

.c.o: mud.h
        $(CC) -c $(C_FLAGS) $<
                                                        


I've tried different types of L_FLAGS
This:

L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) ~/old/lua/lib/liblua.a -llua -lm


This:

L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) ~/old/lua/lib/liblua.a -lm


This:

L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) -llua -lm


This:

L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) -lm


and it still errors at the very end.

[Go to top] top

Posted by Darwin   USA  (125 posts)  [Biography] bio
Date Mon 30 Jul 2007 12:24 AM (UTC)  quote  ]
Message
The error message, I think, was something generic about a script error and the premature exiting of the function was due to where I had placed that line. In either case, your suggestion worked and I moved the line to below setting the task complete so even if it did error again, the task would still be marked as completed. The players are loving these things and wanting more. Great job on such a simple and flexible questing system. :)
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Sun 29 Jul 2007 09:26 AM (UTC)  quote  ]
Message
Probably the problem is your use of mud.char_name.

That is a function, see:

http://www.gammon.com.au/forum/?id=8015

That means, to call it you need to supply arguments, even if it is an empty argument string. Try this:


mud.msg_game (string.format("&Y[INFO] %s has completed task: %s", mud.char_name (), task.name))


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Sun 29 Jul 2007 09:24 AM (UTC)  quote  ]
Message
It helps to copy and paste the error message.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Darwin   USA  (125 posts)  [Biography] bio
Date Sun 29 Jul 2007 08:45 AM (UTC)  quote  ]
Message
I've been tinkering with the finish_task function trying to make it use the mud.msg_game function to send a mud-wide [INFO] line informing everyone of a completed task. This is the same kind of line that serves the same function for the other various quests we have. I've tried this with no success:
mud.msg_game (string.format("&Y[INFO] %s has completed task: %s", mud.char_name, task.name))

Basically, I want the line to be in yellow and formatted like:
[INFO] <player> has completed task: <task name>

I'm hoping that is the right function to use. However, it just sends out a script error message and exits the finish_task function prematurely before marking the task complete.

The task module is great and my players are loving it. They also think the whereis command is "awesome" too. :)
[Go to top] 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.


33,779 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]