User Tools

Site Tools


scripting:samples:simpletask

Example using the Task system

The 'Task' system is used to block the player for a period of time while they're occupied with some task. For example, you may want the player to have to wait for 30 seconds while they are crafting an item before it is added to their inventory. Here is a simple example demonstrating this system, that is triggered when the player uses the 'Flour' item:

Event("UseItem", "Flour" )
{
    *dotask %PLAYER% MakeBread Baking Bread
}

Event( "TaskStart", "MakeBread" )
{
    // Specify that the task will take 30 seconds to complete..
    PlayerTaskStartSetTime( 30 )
}

Event( "TaskComplete", "MakeBread" )
{
    *grantitem %PLAYER% 1 Bread
}

A slightly different variant example shows how using a taskcode rather than a text callback would trigger slightly different events:

Event("UseItem", "Flour" )
{
    *dotask %PLAYER% 40 Baking Bread
}

Event( "TaskStart", "1" )    // Type = 1 means all *dotask events without a callback trigger this
{
    // Specify that the task will take 30 seconds to complete..
    PlayerTaskStartSetTime( 30 )
}

Event( "CustomTaskComplete", "40" )  
{
    *grantitem %PLAYER% 1 Bread
}
scripting/samples/simpletask.txt · Last modified: 2023/07/12 16:02 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki