[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]  lua embedded example
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: lua embedded example
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
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)

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 20 Jan 2009 02:48 PM (UTC)  quote  ]
Message
I will have an example of a fairly deep embedding published "soon" (I still need to clean some things up). I haven't yet started with mudprogs, with I have a lot of the infrastructure ready to do that conversion.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Lasher   USA  (21 posts)  [Biography] bio   Moderator
Date Wed 07 Jan 2009 11:40 AM (UTC)  quote  ]
Message
Hi Folks,

Nick asked me to comment on this briefly.

The two years isn't quite correct for just the Lua conversion part, but it did take a *lot* of time and thankfully, due to the size of Aardwolf, we had a lot of players to help us redo the mobprogs in Lua - so one player would convert an area using some guidelines we published and another group would test it. I probably did about 30% of the areas myself and it took about about 2-3 months altogether. At this point, no new value was added to the game, this was to get the minimum functionality that the progs already had into the new code base. Since the first conversion we've been going back to areas and making them work the way we always wanted them to, and the two years is probably dead on here - it started last Summer and I doubt we'll finish this year.

We really had no choice as we were unable to use existing mobprog code. I don't know how many mobprogs Smaug has or how complex they they are, but as awesome as Lua is for scripting, if what you're trying to do is just replicate the existing progs but in Lua, it probably isn't worth it.

If you want to use Lua for newer and more elaborate progs then I'd definitely recommend that. If you're running Smaug anyway then your time is probably better spent on new scripts that actually add something new to the game.

If your question was really "How do I make this work for mobprogs?" more than "How do I convert all mobprogs", I'll have to refer you back to Nick on that on as we're not using the same codebase or implementation of Lua.

Good luck with it! Converting to Lua is one of the best things we ever did, but converting the existing mobprogs would absolutely not have been worth if it hadn't been something we had no choice but to do.
[Go to top] top

Posted by Nick Gammon   Australia  (19,368 posts)  [Biography] bio   Forum Administrator
Date Wed 07 Jan 2009 04:09 AM (UTC)  quote  ]
Message
You want to convert all Smaug mobprogs to be Lua? This isn't a trivial task. The head coder at Aardwold (Lasher) did that, and I think that used up about two years of his life.

It isn't so much that Lua is hard to code for, but you need to have access to mob data in the mobprog (eg. hit points, level, class etc.) so this has to be made available to the Lua scripts. Then for each action a mobprog can take (eg. speech, movement, doing things in general) you would need to write a Lua handler. Individually each one is easy, but to convert everything is a whole lot (like hundreds) of easy things.

Don't get me wrong, I think it is a great idea. But when I considered doing it, I thought the time it would take didn't warrant it. Maybe contact Lasher and ask how much work it took him?

- Nick Gammon

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

Posted by Llarn   (19 posts)  [Biography] bio
Date Wed 07 Jan 2009 03:29 AM (UTC)  quote  ]
Message
Well I read your lua scripting posts, and I guess I just still don't understand how to convert mobprogs to use lua.
I assume are regular editor for mobprogs still would be fine, and calls for lua must be in every mobprog. Not sure beyond doing that what would be next.

Llarn
[Go to top] top

Posted by Nick Gammon   Australia  (19,368 posts)  [Biography] bio   Forum Administrator
Date Tue 06 Jan 2009 07:10 PM (UTC)  quote  ]
Message
I'm not totally clear what you want to do here. First, he is a link to where I show how to call Lua code, from C, in general:

http://www.gammon.com.au/forum/bbshowpost.php?id=6400



  • Do you want to call Lua code from the C part of the server; or

  • Do you want to call some C code from the Lua scripting?


Perhaps an example would help. It's all pretty easy, but I don't want to answer the wrong question.

- Nick Gammon

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

Posted by Llarn   (19 posts)  [Biography] bio
Date Tue 06 Jan 2009 07:22 AM (UTC)  quote  ]
Message
Nick,

Can you post an example of how to embedd progs?

I saw the one example you have where inside the
prog you add something like...
call_lua( actor, "speech", txt );

I guess that would call speech, where would we go about
putting a check to see what the speech is when it is
called, and if it is the txt desired, the do the action
of the script.

Is it a matter of adding something like this in lua_scripting.c?
static int L_speech( lua_State * L )
{

CHAR_DATA *ch = L_find_character( L ); /* get character pointer */

lua_pushboolean( L, ch != NULL );

return 1;
}

I'm very confused on how to do it, and really getting scripting to work with progs is all I want with lua. I could really use help with an example to go by.

Thanks,

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


5,485 views.

[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]