Register forum user name Search FAQ

Gammon Forum

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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Lua ➜ Lua task system - example session

Lua task system - example session

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Mon 09 Jul 2007 11:59 PM (UTC)
Message
This post describes a new task system I have developed for Smaug FUSS.

It uses the techniques described in this post:

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

An important point is that this system does not require a single change to either player files or area files. Any additional information needed (available tasks, current tasks) are all stored in Lua files, which are additional to existing files.

Thus, it can be added into any SMAUG-like MUD (using C or C++), regardless of the exact format of their player or area files.

It relies upon a Lua "script state" for each player, plus some "hook" functions added into the SMAUG C code, so that the Lua script knows stuff like, if you obtained an item, or entered a room. There are also additional functions written to be called from Lua, so the scripts can find things out (eg. what is in your inventory), or make things happen (eg. display a message, put an item in your inventory).

I will create a new level 1 character and walk around looking at and doing the various tasks. The tasks are in a separate file, it is designed to be easy to add new ones, or modify existing ones.

There is also a "hint" system that displays once-off hints to encourage players to use the task system. Each type of hint is shown once at the appropriate moment, and then a flag is set so they don't see it again.

Additional messages to the player (from the task or hint system) are shown below in bold.


(login screen ... blah blah)

SMAUG 1.7 FUSS changes by Samson. Other bugfixes and changes provided by
various members of the SMAUG community. Their contributions are greatly
appreciated.

Enter your character's name, or type new: 
new

Please choose a name for your character: 
Kedaeder
Did I get that right, Kedaeder (Y/N)? 
y

Make sure to use a password that won't be easily guessed by someone else.
Pick a good password for Kedaeder: 
xxxxxxx
Please retype the password to confirm: 
xxxxxxx

What is your sex (M/F/N)? 
m
Select a class, or type help [class] to learn more about that class.
[Mage Cleric Thief Warrior Vampire Druid Ranger Augurer Paladin]
: 
ranger

You may choose from the following races, or type help [race] to learn more:
[Human Elf Dwarf Halfling Pixie Half-Elf Lizardman]
: 
human

Would you like RIP, ANSI or no graphic/color support, (R/A/N)? 
ansi

(various messages here)

Darkhaven Academy
You stand inside the Darkhaven Academy, an establishment designed to teach
the basics of play inside this game.  Each room has a specific purpose and
contains information on the various commands to maneuver around and interact 
with the players.  We recommend you explore the Academy in full, taking the 
time to read the instructions in each room.
 
Type N to move north to the next room in the Academy.  If you have already
completed the rigors of the Academy and wish to test your combat mettle in
the battlegrounds, type OPEN S or OPEN DOOR, then S to enter the arena.
Exits: north up.
A large marble fountain gushes forth here.
You see a dragonskin water container here.
The illustrious Darkhaven Academy Headmistress stands here to greet you.
Mistress Tsythia is shrouded in flowing shadow and light.
There are 3 tasks available here. Type 'task available' to see them.

Mistress Tsythia tells you:
-------------------------------------------------------------------------------
Greetings, Kedaeder. I am a task-giver (or should that be task-master?). 
When you looked around you noticed a message about 'tasks available here'.
Completing tasks can earn you gold, experience, items, and glory!
You may consider some tasks too humble for a noble ranger such as you. 
However, when you complete (and hand in) a task, that can unlock further 
tasks in a chain. Each one can lead to further rewards, and experience.
To see what you can do with tasks, type 'task' to see a list of commands.
You can see a list of available tasks by typing 'task available'.
Noble human, I look forwards to your accepting my task, and having
fun completing it.
-------------------------------------------------------------------------------
Mistress Tsythia smiles at you.

<Type HELP START>
Well done, Kedaeder!
You have passed the Spectral Gates, and have entered the game.
Your accomplishment has earned you level two...
You feel more powerful!
You raise a level!!  Your gain is: 14/34 hp, 3/103 mana, 10/110 mv 2/2 prac.
Hungrily, a hollow voice asks 'What soul passes the gateway into this dominion?'
A rasping voice answers 'Kedaeder, an intrepid Ranger ...'
... Please leave north to experience the Darkhaven Academy.
... You may now "save" to make your character permanent.

help start

(help stuff here)

<20hp 100m 100mv> 



So far we have seen two important things:


  • Mistress Tsythia has 3 tasks for us - this is shown every time we are in a room with available tasks, when you do "look".

  • First time only - we get the hint from the task-giver that there are tasks available, and to type "task available" to see what they are.


Now as we sit here reading, the character update which fires every minute triggers another hint, about the new "whereis" command:


<34hp 103m 110mv> 

Mistress Tsythia whispers:
-------------------------------------------------------------------------------
Hello, Kedaeder. Are you feeling lost? Not sure where everything is yet?
While you are in Darkhaven you can find important locations by typing
'whereis'. This will give you a list of places you might care to visit.
You can find the exact directions to walk by specifying the place you want
to go, for example 'whereis repairs'.
-------------------------------------------------------------------------------

<34hp 103m 110mv> 
whereis
    Destination : Room name
-------------------------------------------------------
        Academy : Entrance to the Academy
      Alchemist : The Alchemist's
          Baker : The Darkhaven Bakery
   Battleground : Battle Grounds
        Butcher : The Butcher's Shop
Cathedral altar : The Cathedral Altar
       Clothing : Annir's Clothing
          Dairy : The Dairy Tent
      East gate : Inside the Eastern Gate
       Fountain : Darkhaven Academy
   Headmistress : Darkhaven Academy
         Healer : The Academy Healer
            Inn : The Darkhaven Inn
      Languages : Abbigayle's Language Lessons
          Magic : The Wizard's Tent
     North gate : Inside the Northern Gate
        Repairs : The Blacksmith's Tent
        Scrolls : The Scribe's Tent
         Skills : The Laboratory of Skills and Spells
     South gate : Inside the Southern Gate
         Square : Darkhaven Square
         Tailor : Annir's Clothing
         Tavern : The Tavern
        Weapons : Weaponry Shop
      West gate : Inside the Western Gate

Type 'whereis [place]' to get a suggested route (eg. 'whereis academy').




Straight away our player is given the tools to find their way around.

Time to press on with finding available tasks, and accepting some:



<34hp 103m 110mv> 
task

task list           --> list current tasks
task available      --> list available tasks
task show [id]      --> show details about a task (current or available)
task accept [id]    --> accept a task (agree to do it)
task finish [id]    --> finish a task (hand it in) 
task abandon [id]   --> abandon a task
task history        --> show all finished tasks

<34hp 103m 110mv> 
task available
------------------------------ Available tasks ------------------------------
[academy5  ] Find some food
[academy1  ] Find teacher Domick
[academy6  ] Bring me bread

Type: 'task show   [id]' to show task details (eg. 'task show academy5')
Type: 'task accept [id]' to accept a task (eg. 'task accept academy5')


<34hp 103m 110mv> 
task show academy1
------------------------------- Task academy1 -------------------------------

Find teacher Domick
Mistress Tsythia wants you to visit Domick in The Laboratory of Skills 
and Spells.

Please give him this note ('give note domick').

To find Domick, go North from Mistress Tsythia and then East.

If you have become lost, type 'whereis skills' to get directions to him.

You will be rewarded with some armour, and 100 gold coins.


Type: 'task accept [id]' to accept a task (eg. 'task accept academy1')




Each task has a unique identifier (academy1, academy2 and so on). By showing a task I can see what is involved. If I want to accept the task I can type "task accept (id)", like this:


task accept academy5
Accepted task: Find some food

Mistress Tsythia tells you:
-------------------------------------------------------------------------------
Thank you, Kedaeder. You have accepted my task. You can now type 'task list' 
to see a list of your current tasks (you can have more than one task 
outstanding at once). To remind yourself of the task objectives, 
type 'task show academy5'. Once all of the objectives are complete (you 
will know because you will see see "(Complete)" next to them), you can hand 
that task in for the task rewards, and possibly further tasks in that chain.
-------------------------------------------------------------------------------
Mistress Tsythia bows before you.



This triggers off another hint - the "you have just accepted a task" hint. This lets the player know that they can type "task show" to see the status of current tasks, and "task list" to see a list of them.

I'll accept the other two available ones first:


<34hp 103m 110mv> 
task accept academy1
You receive item: a note
Accepted task: Find teacher Domick

<34hp 103m 110mv> 
task accept academy6
Accepted task: Bring me bread



Now let's list them and show them:


<34hp 103m 110mv> 
task list
------------------------------- Current tasks -------------------------------
[academy1  ] Find teacher Domick
[academy5  ] Find some food
[academy6  ] Bring me bread

Type: 'task show    [id]' to show task details (eg. 'task show academy1')

<34hp 103m 110mv> 
task show academy1
------------------------------- Task academy1 -------------------------------

Find teacher Domick
Mistress Tsythia wants you to visit Domick in The Laboratory of Skills 
and Spells.

Please give him this note ('give note domick').

To find Domick, go North from Mistress Tsythia and then East.

If you have become lost, type 'whereis skills' to get directions to him.

You will be rewarded with some armour, and 100 gold coins.


  Give note to Domick: 0/1

Task giver: Mistress Tsythia in Darkhaven Academy
Hand in to: Domick in The Laboratory of Skills and Spells



The task list shows 3 current tasks - and looking at "academy1" shows the long description. For a newbie task the description also includes relevant commands. Near the bottom is the completion status: "Give note to Domick: 0/1" - we have one subtask, and that is not yet completed.

As suggested in the task description, I can use "whereis" to find where to go. This is useful if I have wandered away before attempting the task:


whereis skills
To get to The Laboratory of Skills and Spells walk: n e

<34hp 103m 110mv> 
n
A Stone Corridor
To the west is the language lessons room. Lady Abbigalye is there
to assist you in learning the languages of the land.  To the east
is where Domick will assist you in practicing your weapons, skills
and spells.  When you are finished with your lessons, come back
here and continue north through the Academy.
Exits: north east south west.

<34hp 103m 109mv> 
e
The Laboratory of Skills and Spells
This is where you will practice your arsenal of weapons, spells and skills.
(blah blah)

Exits: west.
Domick, Lord of Knowledge, sits here reading, waiting for students.
Domick glows with an aura of divine radiance.
There is a task available here. Type 'task available' to see it.
Domick tells you 'Are you ready for your lessons?'
Hand in to: Domick in The Laboratory of Skills and Spells



Domick also has a task for us, as we can see. We haven't yet completed the earlier task, because we haven't handed him the note. Let's do that now:


<34hp 103m 110mv> 
give note domick
You give a note to Domick.

Task: Find teacher Domick --> Give note to Domick: 1/1

Task: Find teacher Domick -> Give note to Domick. (Objective complete)

<34hp 103m 110mv> 
task list
------------------------------- Current tasks -------------------------------
[academy1  ] Find teacher Domick (Completed) *
[academy5  ] Find some food
[academy6  ] Bring me bread
             * = can finish this task here

Type: 'task show    [id]' to show task details (eg. 'task show academy1')
Type: 'task finish  [id]' to finish a task (eg. 'task finish academy1')



Handing in the note triggers a subtask message (gave 1/1 notes) and an "objective complete" message, as we reached the number required. Later on (eg. a task to kill 5 mobs) the subtask message will gradually count up until it is complete.

The task list shows the completed task, asterisked to indicate it can be completed right here.

Completing a task also triggers another hint message:


<34hp 103m 110mv> 

Domick whispers:
-------------------------------------------------------------------------------
Hello, Kedaeder. I notice you have completed one of your tasks.
In order to get your reward you need to find me, and finish this task 
by typing 'task finish academy1'. When you do this I will reward you
with the appropriate rewards for this task. 
I look forwards to seeing you, Kedaeder.
-------------------------------------------------------------------------------



This is to remind the player that it is not enough to simply meet the task objectives, they also have to find the task receiver and "finish" the task.

Let's finish it now:


task finish academy1
You gain 20 xp!
You receive item: a plate of armour
You receive 100 gold!
Domick tells you:

-------------------------------------------------------------------------------
To see what is in your inventory: inven
  (or just type 'i')
To see how much gold you have:    gold
You can now wear this armour:     wear armour
You can see what you are wearing: equip
If you want to remove it:         remove armour

-------------------------------------------------------------------------------
Finished task: Find teacher Domick




In this case the "task finish" function arranges to give the player experience, an item, gold, and display a helpful message.

Remembering that Domick also had a task for us, we will accept that, and see what is required:


task available
------------------------------ Available tasks ------------------------------
[academy2  ] Visit the headmistress

Type: 'task show   [id]' to show task details (eg. 'task show academy2')
Type: 'task accept [id]' to accept a task (eg. 'task accept academy2')

<34hp 103m 110mv> 
task accept academy2
Accepted task: Visit the headmistress

<34hp 103m 110mv> 
task show academy2
------------------------------- Task academy2 -------------------------------

Visit the headmistress
Domick would like you to return to Mistress Tsythia. She will have
a task for you to test your fighting skills. As a reward you will
receive a weapon suitable for starting a fight.


 (There is nothing to do except hand this task in)

Task giver: Domick in The Laboratory of Skills and Spells
Hand in to: Mistress Tsythia in Darkhaven Academy

<34hp 103m 110mv> 
task list
------------------------------- Current tasks -------------------------------
[academy2  ] Visit the headmistress (Completed)
[academy5  ] Find some food
[academy6  ] Bring me bread

Type: 'task show    [id]' to show task details (eg. 'task show academy2')

whereis Headmistress
To get to Darkhaven Academy walk: w s




This next task has no subtasks, so it is already completed. However to get the task reward we have to visit the person who we are going to hand in to. The task reminds us who that is. This sort of task is useful to move the player on from one location to another.



<34hp 103m 110mv> 
w
A Stone Corridor
(description omitted)
Exits: north east south west.

<34hp 103m 109mv> 
s
Ok.
Darkhaven Academy
(description omitted)
Exits: north up.
A large marble fountain gushes forth here.
You see a dragonskin water container here.
The illustrious Darkhaven Academy Headmistress stands here to greet you.
Mistress Tsythia is shrouded in flowing shadow and light.
You can finish a task here. Type 'task list' to see it.

Mistress Tsythia tells you:
-------------------------------------------------------------------------------
Greetings, Kedaeder. I notice you have completed one of your tasks.
In order to get your reward you must finish (hand in) this task by 
typing 'task finish academy2'. When you do this I will reward you
for handing in this task. 
Thanks for completing the task, Kedaeder.
Once you have finished the task, try typing 'task available', to see
if further tasks have become available (as part of a chain of tasks).
-------------------------------------------------------------------------------
Mistress Tsythia thanks you heartily.
Mistress Tsythia says 'Hello, Kedaeder.  How was the Academy?'
Please take the time to visit the note room to the east.
When done here, leave up to explore Darkhaven.

<34hp 103m 110mv> 
task finish academy2
You gain 20 xp!
You receive item: a finely honed sword
You receive 100 gold!
Mistress Tsythia tells you: 'Don't forget to wear your new item'

Mistress Tsythia tells you: 'Once you have done that, I have another task for you.'

Finished task: Visit the headmistress

<34hp 103m 110mv> 
task available
------------------------------ Available tasks ------------------------------
[academy3  ] The Chadoyn must die!

Type: 'task show   [id]' to show task details (eg. 'task show academy3')
Type: 'task accept [id]' to accept a task (eg. 'task accept academy3')


<34hp 103m 110mv> 
task show academy5
------------------------------- Task academy5 -------------------------------

Find some food
Mistress Tsythia would like you to go up and east to buy some
meat to eat for sustenance during your adventures.

You will be rewarded with a dragonskin - useful for holding water.

  Meat purchased: 0/1

Task giver: Mistress Tsythia in Darkhaven Academy
Hand in to: The storekeeper in The Young Adventurer's Necessities

i
You are carrying:
     a plate of armour
     a finely honed sword

<34hp 103m 110mv> 
wear armour
You fit a plate of armour on your body.

<34hp 103m 110mv> 
wear sword
You wield a finely honed sword.

task available
------------------------------ Available tasks ------------------------------
[academy3  ] The Chadoyn must die!

Type: 'task show   [id]' to show task details (eg. 'task show academy3')
Type: 'task accept [id]' to accept a task (eg. 'task accept academy3')

<34hp 103m 110mv> 
task accept academy3
Accepted task: The Chadoyn must die!

<34hp 103m 110mv> 
task show academy3
------------------------------- Task academy3 -------------------------------

The Chadoyn must die!
Mistress Tsythia would like you to head north, and find the Chadoyn
to kill. Return once it is slain.


  Chadoyn slain: 0/1

Task giver: Mistress Tsythia in Darkhaven Academy





I have worn the quest rewards I received, and accepted another quest again. Also by checking the quest "Find some food" I see a suggestion that some food might be useful. I think I'll get that next. This is a "buy" task - the task is completed when I have purchased the required item.


The Young Adventurer's Necessities
Water skins, rations and torches hang from the walls:  all necessary to 
survival when adventuring.  A stack of books which have been designed to
help the young adventurer lie stacked in the rear of the shop.  To the
west is the entrance to the Darkhaven Academy.
Exits: west.
A large man stands here, selling equipment for adventurers.

<34hp 103m 107mv> 
list
[Lv Price] Item
[ 0    27] A dragonskin.
[ 0    18] A torch.
[ 0    36] Dried rabbit meat.

<33hp 103m 110mv> 
buy meat
You buy dried rabbit meat.

Task: Find some food --> Meat purchased: 1/1

Task: Find some food -> Meat purchased. (Objective complete)

<33hp 103m 110mv> 
task finish academy5
You gain 2000 xp!
You receive item: a dragonskin
You receive 200 gold!
Finished task: Find some food



I head north and eventually find the Chadoyn. Time to kill it:


(lengthy fight here)

<18hp 103m 100mv> 
Your slash _cleaves_ the chadoyn!
The chadoyn is DEAD!!
You receive 123 experience points.

Task: The Chadoyn must die! --> Chadoyn slain: 1/1

Task: The Chadoyn must die! -> Chadoyn slain. (Objective complete)
The chadoyn's arm is sliced from its dead body.
You get 100 gold coins from the corpse of the chadoyn
The corpse of the chadoyn holds:
     the chadoyn's bindings



I run back to the headmistress and hand in that quest:


<20hp 103m 102mv> 
task finish academy3
You gain 20 xp!
You receive item: an eye of enlightenment
You receive 500 gold!
Finished task: The Chadoyn must die!

<20hp 103m 102mv> 
task history
------------------------------- Finished tasks -------------------------------
[academy1  ] Find teacher Domick
[academy2  ] Visit the headmistress
[academy5  ] Find some food
[academy3  ] The Chadoyn must die!



The "task history" command shows how much I have achieved (and in what order).

Time to get into a lengthier "kill" quest:


<24hp 103m 110mv> 
task av
------------------------------ Available tasks ------------------------------
[academy4  ] Getting your hands dirty

Type: 'task show   [id]' to show task details (eg. 'task show academy4')
Type: 'task accept [id]' to accept a task (eg. 'task accept academy4')

<24hp 103m 110mv> 
task accept academy4
Accepted task: Getting your hands dirty

<24hp 103m 110mv> 
task show academy4
------------------------------- Task academy4 -------------------------------

Getting your hands dirty
Mistress Tsythia would like you to head for the battlegrounds, and
kill 4 wolves, 3 naga and 2 carrion crawlers.

Your reward for doing this is 1000 gold.


  Naga slain: 0/3
  Wolf slain: 0/4
  Carrior crawler slain: 0/2

Task giver: Mistress Tsythia in Darkhaven Academy

<26hp 103m 110mv> 
whereis battleground
To get to Battle Grounds walk: s 3e 3s



This quest has 3 subtasks (objectives). Killing various wolves, naga and carrion crawlers.

We head for the battle grounds, and start killing stuff. As we kill things we gradually meet our quest objectives:


<45hp 107m 116mv> 
Your slash _devastates_ a carrion crawler!
A carrion crawler is DEAD!!
You receive 355 experience points.

Task: Getting your hands dirty --> Carrior crawler slain: 1/2

task show academy4
------------------------------- Task academy4 -------------------------------

Getting your hands dirty
Mistress Tsythia would like you to head for the battlegrounds, and
kill 4 wolves, 3 naga and 2 carrion crawlers.

Your reward for doing this is 1000 gold.


  Wolf slain: 1/4
  Naga slain: 1/3
  Carrior crawler slain: 1/2

Task giver: Mistress Tsythia in Darkhaven Academy



Well, that is probably a long enough posting. I hope I have give you the general flavour of the task system. It is pretty flexible, and should encourage some interesting tasks for players in your MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 10 Jul 2007 01:37 AM (UTC)

Amended on Tue 10 Jul 2007 01:38 AM (UTC) by Nick Gammon

Message
The Lua scripting, task system, and "whereis" system is now released in this file (1.48 Mb):

http://www.gammon.com.au/files/smaug/smaug17fuss_lua.tgz

md5sum is 0fed6ac4729be011f0a738bb8f6fd664

Basically it is Smaug FUSS version 1.7 with the extra Lua stuff added in, ready to compile. There is an extra "lua" directory with the Lua code in it. The commands.dat file has the "task" and "whereis" commands added.

There is an example set of tasks (as shown above). Descriptions of how to amend them to suit yourself are here:

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Orik   USA  (182 posts)  Bio
Date Reply #2 on Wed 18 Jul 2007 04:24 AM (UTC)

Amended on Wed 18 Jul 2007 04:55 AM (UTC) by Orik

Message
So I'm making a test task, how do I get it to be available to them all the time even though they have already completed it? or can we have repeatable tasks?


 all_tasks.academy7 = {

   --Name of task
    name = "Continue the Slaughter",
    description = [[
Continue on with killing the nagas and wolves. &GLeave the Crawlers
to me!&w  
]],
    giver = 10399,
    min_level = 1,
    max_level = 5,
    time_limit = 5,
    accept = function ()
    end,
    abandon = function ()
    end,
    complete = function ()
      task_xp = (5000)
	task_gold = (2000)
    end,
	subtasks = {
		{
			description = "Kill Naga",
			type = "killmob",
			vnums = { 10302 },
			count = 3,
		},
		{
			description = "Kill Wolves",
			type = "killmob",
			vnums = { 10300 },
			count = 3,
		},
	  },
	}


I've tried this without the:

available = function ()
end,


and with

available = function ()
end,


Either way, it's not a repeatable task. After I finish it I can't do it again.

***EDIT***

Another thing I noticed is that on Nick's premade tasks, when I turn them in, it says "you receive 20xp" or whatever it is I'm receiving. On my new task, it doesn't say anything when I finish it. I've made two new tasks and neither of them say "You receive 30 xp".
Top

Posted by Orik   USA  (182 posts)  Bio
Date Reply #3 on Wed 18 Jul 2007 05:02 AM (UTC)

Amended on Wed 18 Jul 2007 05:08 AM (UTC) by Orik

Message
Here are my two tests:


 all_tasks.academy7 = {

   --Name of task
    name = "Continue the Slaughter",
    description = [[
Continue on with killing the nagas and wolves. &GLeave the Crawlers
to me!&w  
]],
    giver = 10399,
    min_level = 1,
    max_level = 5,
    time_limit = 5,
    accept = function ()
    end,
    abandon = function ()
    end,
    complete = function ()
      task_xp = (5000)
	task_gold = (2000)
    end,
	subtasks = {
		{
			description = "Kill Naga",
			type = "killmob",
			vnums = { 10302 },
			count = 3,
		},
		{
			description = "Kill Wolves",
			type = "killmob",
			vnums = { 10300 },
			count = 3,
		},
	  },
	}

all_tasks.academy8 = {
 name = "Kill the slugs!",
 description = [[
So now that we've got that out of the way, let's go kill some slugs!
]],
 giver = 10399,
 min_level = 2,
 max_level = 6,
 time_limit = 10,
 accept = function ()
 end,
 abandon = function ()
 end,
 complete = function ()
   task_xp = (3000)
   task_gold = (5000) 
 end,

 subtasks = {
   {
     description = "Kill the slugs",
     type = "killmob",
     vnums = {10301},
     count = 5,
   },
  },
}


it's not giving me the xp or gold at all.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 18 Jul 2007 06:16 AM (UTC)
Message
You haven't called the completion functions, you have assigned to them. That is a lot different.

This is my example:


 -- do stuff for completing (like task rewards)
  complete = function ()
      task_xp (20)
      task_item (10311)  -- an eye of enlightenment
      task_gold (500)
      end, -- complete function


You have done:


task_xp = (5000)
task_gold = (2000)


What that is doing is assigning the number 5000 to the variable task_xp, replacing the function with a number.

You need:


task_xp (5000)
task_gold (2000)


Quote:

So I'm making a test task, how do I get it to be available to them all the time even though they have already completed it? or can we have repeatable tasks?


I have specifically disallowed repeatable tasks for now, on the grounds that you could rapidly accumulate a lot of gold and xp by scripting something to mindlessly do the task 1000 times while you watched the TV.

However you can make it do whatever you want. You might add a "repeatable" flag into the tasks table, and in the function finish_task (near the end), change:


  current_tasks [id] = nil  -- not a current task now
  completed_tasks [id] = os.time ()  -- note completed time


to:


  current_tasks [id] = nil  -- not a current task now
  if not task.repeatable then
   completed_tasks [id] = os.time ()  -- note completed time
  end -- if not repeatable


By not entering it into the completed_tasks table, effectively it forgets you have ever done it, and you could do it again. You might want to bear in mind my warning about bots, and maybe make an entry into a "repeated_tasks" table instead, with a counter, and stop them after x repeats.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Orik   USA  (182 posts)  Bio
Date Reply #5 on Wed 18 Jul 2007 02:16 PM (UTC)
Message
I see your point on this. I probably won't mess with repeatable tasks.
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.


22,878 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

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