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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Lua
. . -> [Subject]  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] Refresh page


Pages: 1  2 3  4  5  6  

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Wed 04 Jul 2007 02:58 AM (UTC)
Message
Well I did say *not* one per mob. :-)

My current system seems to work OK for most situations I have seen in stock SMAUG mud progs.

I have been adding in "give", "act" and "bribe" hooks.

In terms of adding functionality (like a quest system) it is probably fine as it is. If you are trying to do fine-grained stuff like handling thousands of mobs doing very specific things, then it might need tweaking for efficiency.

I'll try a quest system and see how I go.


- Nick Gammon

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

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #16 on Wed 04 Jul 2007 03:07 AM (UTC)
Message
Part of my plan is to not do just what SMAUG mudprogs do. Part of the whole problem is that mudprog is very limited, and so, as a result, what you can do with them is very limited.

I'd like mudprogs that can do things as complicated as you could do in C(++).

Consider something like the following, written in skrypt, the home-brew language I wrote several years ago (so take it with the appropriate grain(s) of salt). It is a script attached to a room. The functions are events, trigger hooks if you will.


initRoom ()
{
	// Create a repeating timer of 5000 ms.
	eventTimerCreate(me, "timerHeal", 5000, -1);
}

enter(mobile ch)
{
	/*echoToRoom(me, "Hey, " + name(ch) + "! The people already in this room are:");
	forEach (mobile person, getRoomPeopleList(me) )
	{
		if ( person != ch )
			echoToRoom(me, name(person));
	}*/
	echoToRoom(me, "Enjoy your stay.");
}

timerHeal ()
{
	forEach ( mobile person, getRoomPeopleList(me) )
	{
		if ( getPosition(person) == "sleeping" )
		{
			affectHP(person, 4);
			//echoToRoom(me, "Healing " + name(person) + " for 4 HP.");
		}
		else if ( getPosition(person) == "resting" )
		{
			affectHP(person, 1);
			//echoToRoom(me, "Healing " + name(person) + " for 1 HP.");
		}
		//echoToRoom(me, name(person) + " is in this room, and is " + getPosition(person) + ".");
	}
}


timerKickOut()
{
	// Kick everybody out of the room
	forEach ( mobile person, getRoomPeopleList(me) )
	{
		transfer( person, "" );
	}
}


It should be pretty obvious what the syntax means.

This is impossible in mudprog. But this is just the very beginning of what I'd like to do.

Would your system be able to handle this? I'm not saying it can't, just that I would only be satisfied if it did. :-P

About the quest system:
What stumps me on the quest system is not that I don't know how to code it, but that I'm unsure what exactly I want to code. I think there's a little more work to do with designing the quest system. I mentioned some of those in a recent email; I'm still thinking about a hybrid system of some kind.

I'm starting to think of it in two concepts: quests vs. tasks. A quest is one that has steps and all that stuff, in which players move through steps via script events. A task is one in which the kinds of tasks are pre-defined, and would be things like "kill so-many monsters", "bring this so-many of this item to that npc", etc.

But anyhow -- one thing at a time. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Reply #17 on Mon 09 Jul 2007 03:27 AM (UTC)

Amended on Mon 09 Jul 2007 03:33 AM (UTC) by Gatewaysysop2

Message
Nick,

First off, thanks a heap for providing this. I think a lot of interest is out there, but the initial work that you've done here to get Smaug and Lua communicating is the bulk of what kept people from taking a deeper look at this. It's a huge effort and I for one am very appreciative that you've done all this for the community at large.

I did want to chime in with one thing I'm running up against though:


  Compiling o/lua_bits.o....
lua_bits.c:14: warning: ISO C90 does not support `long long'
lua_bits.c:15: warning: ISO C90 does not support `long long'
lua_bits.c: In function `bit_tonumber':
lua_bits.c:65: warning: pointer targets in initialization differ in signedness
lua_bits.c:76: warning: integer constant is too large for "long" type
make[1]: *** [o/lua_bits.o] Error 1


Any ideas on how to get around this one? There's apparently a compiler flag to avoid the long long warning, but the other warnings of course persist.

If you have any suggestions, I'd definitely appreciate it. Other than that, I've not had any issues so far.

Again, thanks a million for sharing 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
[Go to top] top

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #18 on Mon 09 Jul 2007 06:26 AM (UTC)
Message
I think they are all related, and it is strange you are getting them. I compiled using gcc under Linux.

Anyway, the bits file is not really required yet - I didn't use it for the initial stuff, and so far have only used it in one place to "and" a room flag.

I would remove it from the makefile for now, and remove the reference to it in the lua_scripting.c file.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #19 on Mon 09 Jul 2007 06:30 AM (UTC)
Message
Quote:

Again, thanks a million for sharing this!


My pleasure, and you will be pleased to know the new task system is coming along nicely. One thing that is good is that SMAUG simply doesn't crash when I am playing with it. Sure, I get the odd script error, but that is neatly reported and logged. You just fix the script, log out and back again, and you are off again.

- Nick Gammon

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

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #20 on Mon 09 Jul 2007 09:28 PM (UTC)
Message
Nick, have you decided to stick with the system of one state per player? How are you dealing with scripts that need to run on rooms or mobs independently of the player being there? Or are you considering that separately?

(Here's another example: on my game, some passages open or close depending on whether it's night-time or day-time. That needs to happen whether or not a player is there at the instant of time change.)

One advantage, though, is that it should be very easy to move a lot of your work to a system that has a global Lua state. That's another really nifty feature about Lua. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #21 on Mon 09 Jul 2007 10:10 PM (UTC)
Message
So far I have one state per player.

As I continue to work on the task system, that seems adequate. The overhead of having 50 states (for 50 players) is a lot less than 10,000 states (for 10,000 mobs).

You could probably add an additional state to the overall game for stuff like periodically opening gates. This could be called from a heartbeat function (eg. every minute).

- Nick Gammon

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

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #22 on Mon 09 Jul 2007 11:23 PM (UTC)
Message
Where are you storing the database of available tasks? Is that a separate Lua file somewhere that every player state loads in?

I'm still fairly uneasy about using one state per player; although it does give certain advantages (like you don't need handles to characters to send things to them) it seems like it makes a lot of other things more complex.

I'll have to play around with this and see what happens...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #23 on Tue 10 Jul 2007 12:46 AM (UTC)
Message
Yes, every player gets it. It is handy for debugging, although I agree there is a potential for memory usage to creep up if you have lots of tasks, and lots of players on at once.

One technique could be to "require" subsets of all tasks, based on player level. For example, a level 40 player probably doesn't need in memory all the newbie tasks.

There is a potential problem with that if players hang onto level 1 tasks, when they are still level 50. I think in practice they won't because, they will want to free up the task list. However I think you could warn them that tasks which are well under their level will be discarded. I don't have an exact mechanism for showing that right now, but something like "recommended level" could be used to grade tasks.

- Nick Gammon

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

Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Reply #24 on Tue 10 Jul 2007 01:35 AM (UTC)
Message
Hmm.

Getting this now:

make -s -j2 smaug
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find
-llua


Lua gave no errors during installation. What is going on here?

"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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #25 on Tue 10 Jul 2007 01:38 AM (UTC)
Message
Some distros install Lua as lua51 or lua50, depending on the version. You can check /usr/lib/ in Cygwin to see what it is.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Nick Gammon   Australia  (23,017 posts)  [Biography] bio   Forum Administrator
Date Reply #26 on Tue 10 Jul 2007 01:46 AM (UTC)
Message
I have:


/usr/local/lib/liblua.a


However you could make the lua library local I imagine, if you tweak the Makefile.

- Nick Gammon

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

Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Reply #27 on Tue 10 Jul 2007 01:51 AM (UTC)
Message
Hrmmm.

It appears you have to use "make install INSTALL_TOP=/usr" for this to work properly, at least on my install of Cygwin. Goofy, but it works now.

Thanks for pointing me in the right direction!

Any insight on that 'long long' issue I brought up above?


"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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #28 on Tue 10 Jul 2007 01:56 AM (UTC)
Message
You can use -Wno-long-long to remove that warning.

The Lua install probably went into /usr/local/lib, which means that you need to add the -L/usr/local/lib flag to the makefile linker flags. But going into /usr itself is ok, too.

I think that Cygwin itself has a package for Lua, which you might want to use, too. (It probably doesn't make any difference, though.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Reply #29 on Tue 10 Jul 2007 02:00 AM (UTC)
Message
I tried that flag and that did quiet the warning, but it still gives me the other error I pasted from the output. :-/


"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
[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.


231,399 views.

This is page 2, 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] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]