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
| Darwin
USA (125 posts) Bio
|
Date
| Reply #60 on Sat 28 Jul 2007 06:10 AM (UTC) |
Message
| Thanks for all your help.
Now on to adding the tasks. | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #61 on Sat 28 Jul 2007 10:14 AM (UTC) |
Message
| Well, so much for that. After setting up the resets, editing the tasks and setting locations for whereis, I find that the lua call for the reset crashes the mud. Comment that out since it's not really needed. Recompile, start it up log in, the task and whereis commands display no output
The mud registers that the commands are being used but it seems as though the call_lua function isn't returning anything or processing any data given to it.
I've been at this all day so it's probably something minor that I overlooked. I'll try again tomorrow. | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #62 on Sat 28 Jul 2007 09:12 PM (UTC) |
Message
| I added some debugging stuff in the call_lua function to confirm that the function was being called. It is indeed being called and with the right arguments. It appears that the find_lua_function err.. function isn't finding the uh.. function.
This is the output I get from the debugging I added:
task
Inside call_lua function.
ch = Darwin, fname = task, argument =
Did not find lua function: task
whereis
Inside call_lua function.
ch = Darwin, fname = whereis, argument =
Did not find lua function: whereis
The call_lua function gets called in the other events and also prints out the debugging info as well:
Inside call_lua function.
ch = Darwin, fname = looking, argument = (null)
Inside call_lua function.
ch = Darwin, fname = entered_game, argument = Darwin
So I know those, at least, are working.
Ideas on what broke this? | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #63 on Sat 28 Jul 2007 09:41 PM (UTC) |
Message
| Look at the MUD output log (ie. for bug messages). It won't find those functions if there was an error loading the Lua startup script. For example, if I deliberately introduce an error into it, and connect, I see stuff like this:
Sun Jul 29 07:35:12 2007 :: Admin (10.0.0.4) has connected.
Sun Jul 29 07:35:12 2007 :: [*****] BUG: Error loading Lua startup file ../lua/startup.lua:
../lua/startup.lua:2: '=' expected near 'afd'
Sun Jul 29 07:35:12 2007 :: [*****] BUG: Warning: Lua script function 'reconnected' does not exist
The startup.lua file implements those commands by "requiring" (loading in) extra files, like this:
-- install other stuff here (like task system)
task = require ("tasks").task -- module - provides 'task' command handler
whereis = require ("whereis").whereis -- module - provides 'whereis' command handler
If that isn't it, take a look at the start of find_lua_function:
static lua_State * find_lua_function (CHAR_DATA * ch, const char * fname)
{
lua_State *L = ch->L;
if (!L || !fname)
return NULL; /* can't do it */
The first thing it checks is that you have a Lua state set up (ie. not a NULL pointer). If the state wasn't initialized on a reconnect that would be it. It was working yesterday.
Have you done a hotboot? We found you needed to set up the Lua state after doing that. You need a call to open the Lua state when the hotboot finishes. This is the code I had there:
char_to_room( d->character, d->character->in_room );
act( AT_MAGIC, "A puff of ethereal smoke dissipates around you!", d->character, NULL, NULL, TO_CHAR );
act( AT_MAGIC, "$n appears in a puff of ethereal smoke!", d->character, NULL, NULL, TO_ROOM );
d->connected = CON_PLAYING;
open_lua (d->character); /* fire up Lua state */
call_lua (d->character, "reconnected", d->character->name);
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #64 on Sat 28 Jul 2007 10:19 PM (UTC) |
Message
| Ah, as usual, it was my tweaking that lead to my own downfall. I mistakenly left out a double quote from a task function I added. After fixing that, it all works as it should.
Thanks a ton. This will certainly help to add a lot of variety to the game. | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #65 on Sun 29 Jul 2007 07:45 AM (UTC) |
Message
| Thanks, Nick. This is really nice having this scripting available for added functionality to the mud code. I'm actually having fun adding tasks and stuff. The flexibility of this code is really nice. There's so many possibilities with it. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #66 on Sun 29 Jul 2007 07:54 AM (UTC) |
Message
| Glad it is working for you.
There is a lot of scope here for MUDs to make quests (tasks) that are fun, and also help advance players along (eg. to find new towns).
For higher level players, you can give them quests which reward them with gold, experience, and equipment for doing the quests.
Another interesting add-on would be a reputation system, but I might leave that for a while. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #67 on Sun 29 Jul 2007 08:45 AM (UTC) |
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. :) | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #68 on Sun 29 Jul 2007 09:24 AM (UTC) |
Message
| It helps to copy and paste the error message. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #69 on Sun 29 Jul 2007 09:26 AM (UTC) |
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 | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #70 on Mon 30 Jul 2007 12:24 AM (UTC) |
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. :) | Top |
|
Posted by
| Orik
USA (182 posts) Bio
|
Date
| Reply #71 on Fri 17 Aug 2007 06:56 AM (UTC) |
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.
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #72 on Fri 17 Aug 2007 09:41 AM (UTC) |
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 | Top |
|
Posted by
| Orik
USA (182 posts) Bio
|
Date
| Reply #73 on Fri 17 Aug 2007 08:56 PM (UTC) 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:
then
Then point to your liblua.a file in your Makefile:
L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) ~/your/folder/lib/liblua.a -lm
| Top |
|
Posted by
| Keberus
(31 posts) Bio
|
Date
| Reply #74 on Mon 01 Oct 2007 01:59 AM (UTC) |
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 | 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.
245,799 views.
This is page 5, subject is 6 pages long:
1
2
3
4
5 6
It is now over 60 days since the last post. This thread is closed.
Refresh page
top