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

Creating userdata


So far we've been using global data to store information about our agents. As we're going to create decision structures that require information about our agents, we'll create a local userdata table variable that contains our specific agent data as well as the agent controller in order to manage animation handling:

local userData =
{
    alive, -- terminal flag
    agent, -- Sandbox agent
    ammo, -- current ammo
    controller, -- Agent animation controller
    enemy, -- current enemy, can be nil
    health, -- current health
    maxHealth -- max Health
};

Moving forward, we will encapsulate more and more data as a means of isolating our systems from global variables. A userData table is perfect for storing any arbitrary piece of agent data that the agent doesn't already possess and provides a common storage area for data structures to manipulate agent data. So far, the listed data members are some common pieces of information we'll be storing; when we start creating individual...