Book Image

Learning Game AI Programming with Lua

By : David Young
Book Image

Learning Game AI Programming with Lua

By: David Young

Overview of this book

Table of Contents (16 chapters)
Learning Game AI Programming with Lua
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with AI Sandbox
Index

Actions


The first node type is a basic action. We can create a wrapper function that will instantiate an action node and set the internal action accordingly. Actions are only designed to execute behaviors on an agent and shouldn't be assigned any children. They should be considered leaves in a behavior tree:

SoldierLogic.lua:

local function CreateAction(name, action)
    local node = BehaviorTreeNode.new(
        name, BehaviorTreeNode.Type.ACTION);
    node:SetAction(action);
    return node;
end