lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Aug 4, 2005, at 11:57 PM, Jose Marin wrote:

Good idea, Russell.

I think that, in this case, I must design the scripts
to act as a state machine.

Well they will likely be a FSM in any case. The world including the actors presumably have state information, but other than that they are free from state since they have issued a plan to carry out some goal. When they get called again their first task could be to figure out what state they are in now (since they don't know what has happened in the world).

Sort of like:

function Hurt(self)
    return world:GetHealth(self) < .3
end

function NextActionPlan(self)
    if self:Hurt() then
        ...
    end
    if self:Hungry() then
        ...
    end
end

Russ