hkzorman / advanced_npc

Advanced NPC for Minetest, using mobs_redo API
Other
17 stars 5 forks source link

Action and task programs #39

Open BrunoMine opened 6 years ago

BrunoMine commented 6 years ago

I am already working on updating the documentation with the new tasks and actions that will work in program format. I would like to use this issue for explanations on some programs. Can you explain more details about the IDLE ("advanced_npc:idle") program? To better understand ways it can be used.

hkzorman commented 6 years ago

The "advanced_npc:idle" program is a program meant to be run when NPC are doing nothing and standing idle. It has two main features (as-of the moment, more planned):

Both features above are disabable. Idle program doesn't loops, it is meant to be executed as a state program (which is scheduled continously as long as the process queue is empty)

BrunoMine commented 6 years ago

About "advanced_npc:node_query" program, can this be used like any program?

Is this documentation completely correct?

#### `NODE QUERY` (advanced_npc:node_query)
Check and run a program with nodes found near.

    {
        range = 2, -- Range of checked area in blocks.

        count = 20, -- How many checks will be performed.

        random_execution_times = true, --[[
            ^ Randomizes the number of checks that will be performed.
            ^ min_count and max_count is required ]]

        min_count = 20, -- minimum of checks
        max_count = 25, -- maximum of checks

        nodes = {"itemstring1", "itemstring2"}, --[[ 
            ^ Nodes to be found for the actions.
            ^ When a node is found, it is add in the npc place map 
              with the place name "schedule_target_pos"

        prefer_last_acted_upon_node = true, -- If prefer to act on nodes already acted upon

        walkable_nodes = {"itemstring1", "itemstring2"}, -- Walkable nodes

        on_found_executables = { --[[
            ^ Table where index is a itemstring of the node to be found, 
              and value is an array of programs to be performed 
              when found the node. ]]

            ["itemstring1"] = {            
               [1] = <program>,
               [2] = <program>,
               [3] = <program>
            },
            ["itemstring2"] = {            
               [1] = <program>,
               [2] = <program>
            }
        },

        on_not_found_executables = { --[[ 
            ^ An array of programs to be performed when not found any node.

            [1] = <program>,
            [2] = <program>
        },

        state_program_on_finished = <program> --[[ 
            ^ [OPTIONAL] 
            ^ A state program performed after ending all check counts ]]

    }

EDIT: state_program_on_finished included