Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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
➜ Version 2 of the Lua interface released
Version 2 of the Lua interface released
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #15 on Wed 18 Jul 2007 06:03 AM (UTC) |
Message
| Well, the tasks are something I wouldn't edit as a text file were I to edit them online. Well, it depends on what exactly you're doing and how hard the syntax is. Either way, in-MUD, it is not feasible to edit the whole file when you have more than, say, ~50 quests.
Since it's all Lua code, you can easily set up includes like you do in C, using 'require'. So you could have a master list that is just a list of includes, and you could create one file per area or something like that. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nick Gammon
Australia (23,061 posts) Bio
Forum Administrator |
Date
| Reply #16 on Wed 18 Jul 2007 06:06 AM (UTC) |
Message
| For development, I have been editing the various Lua files using Crimson Editor (under Windows), using its "get from remote" and "save to remote" options (these invoke an inbuilt ftp client).
Thus you just hit "save" and it saves to the remote site.
Quote:
This tasklist file will be REALLY big once you start putting more tasks into it. Is that just how it goes or will there be better ways on down the line?
You can split it into subfiles. For example, in alltasks.lua, you could simply require the additional files like this:
all_tasks = {}
my_loader "darkhaven_tasks"
my_loader "grove_tasks"
my_loader "academy_tasks"
Then you can give each area to a builder to edit. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #17 on Thu 02 Aug 2007 04:02 PM (UTC) |
Message
| I've noticed something about the tasks which require you to "give" an item to a mob. The problem is that the item isn't purged from the mob. After a while, a mob's inventory may fill up and cause the player to not be able to finish the task. Also, since the items don't get purged, a player may end up killing the mob to obtain all the task items, but then would have to wait until the mob repopped in order to finish the task. | Top |
|
Posted by
| Nick Gammon
Australia (23,061 posts) Bio
Forum Administrator |
Date
| Reply #18 on Thu 02 Aug 2007 05:17 PM (UTC) |
Message
| You are right. Probably the thing to do is add a "complete" function to the subtask, to immediately purge the item. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Darwin
USA (125 posts) Bio
|
Date
| Reply #19 on Mon 06 Aug 2007 05:26 AM (UTC) |
Message
| I'm not sure how to work that. How do I track that item from the player to the mob and then have it purged from the mob's inventory? | Top |
|
Posted by
| Nick Gammon
Australia (23,061 posts) Bio
Forum Administrator |
Date
| Reply #20 on Mon 06 Aug 2007 07:37 AM (UTC) |
Message
| It turned out to be a bit more complicated than I thought because I hadn't allowed for purging from someone else's inventory. Here is what I had in mind for the subtask:
{ -- subtask 1
description = "Bread obtained",
type = "give",
item = 21021,
count = 1,
vnums = { 10399 },
complete = function ()
mud.destroy_item (10399, 10300, 21021) -- get rid of the bread
end -- complete function
}, -- end subtask
Note that on completion (ie. I gave mob 10399 in room 10300 item 21021) I immediately destroy that item.
However to make that work I had to amend the function destroy_item like this:
/* remove an item from the character's top-level inventory */
static int L_destroy_item (lua_State *L)
{
CHAR_DATA * ch = L_find_character (L); /* get character pointer */
int iItem = 2;
if (!ch)
luaL_error (L, "Cannot find character/mob to destroy an item for.");
/* if character was (vnum, boolean) then item is 3rd argument */
if ((lua_type (L, 1) == LUA_TNUMBER || lua_type (L, 1) == LUA_TLIGHTUSERDATA)
&& (lua_type (L, 2) == LUA_TBOOLEAN || lua_type (L, 2) == LUA_TNUMBER))
iItem++;
OBJ_DATA * obj;
int vnum = luaL_checkint (L, iItem);
if ( vnum < 1 || vnum > MAX_VNUM )
luaL_error (L, "Vnum %d is out of range 1 to %d", vnum, MAX_VNUM);
int count = luaL_optint (L, iItem + 1, 1);
// rest is the same
This lets you specify the mob/room as well as the item number. You should probably make a different function, I think it will get confusing with all those vnums there (like, mob_destroy_item or something).
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Orik
USA (182 posts) Bio
|
Date
| Reply #21 on Mon 10 Mar 2008 03:02 AM (UTC) Amended on Mon 10 Mar 2008 03:04 AM (UTC) by Orik
|
Message
| How exactly does this work?
Quote: You can split it into subfiles. For example, in alltasks.lua, you could simply require the additional files like this:
all_tasks = {}
my_loader "darkhaven_tasks"
my_loader "grove_tasks"
my_loader "academy_tasks"
Do I create a new grove.lua file and then just put grove_tasks = {} in it? Or do I need to make a grove_tasks file? OR is this all in one big tasklist file?
Quote:
Since it's all Lua code, you can easily set up includes like you do in C, using 'require'. So you could have a master list that is just a list of includes, and you could create one file per area or something like that.
Where would I start with this? I'd like to have one lua file per area, but if that isn't the case then that's fine as well. | Top |
|
Posted by
| Nick Gammon
Australia (23,061 posts) Bio
Forum Administrator |
Date
| Reply #22 on Mon 10 Mar 2008 04:59 AM (UTC) Amended on Mon 10 Mar 2008 05:00 AM (UTC) by Nick Gammon
|
Message
| What I meant was, your main tasklist.lua file would just look like this:
all_tasks = {}
my_loader "academy_tasks"
my_loader "grove_tasks"
my_loader "academy_tasks"
Then you make a file "academy_tasks.lua" and put inside that all the rest of the existing tasklist.lua file. That is, like this:
all_tasks.academy1 = {
-- task definition here
} -- end academy1 task
all_tasks.academy2 = {
-- task definition here
} -- end academy2 task
all_tasks.academy3 = {
-- task definition here
} -- end academy3 task
all_tasks.academy4 = {
-- task definition here
} -- end academy4 task
-- and so on
Then you could make another file "grove_tasks.lua" and put all the tasks for that area in it.
For example, it might look like this:
all_tasks.grove1 = {
-- task definition here
} -- end grove1 task
all_tasks.grove2 = {
-- task definition here
} -- end academy2 task
all_tasks.grove3 = {
-- task definition here
} -- end grove3 task
all_tasks.grove4 = {
-- task definition here
} -- end grove4 task
-- and so on
The tasks still go into the all_tasks table so you don't make a different table per area. However you must name each task uniquely (eg. grove1, grove2 etc.)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
69,270 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top