From 86feaa033668a3a9d9ccf8199e7114143827ce76 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sun, 3 Feb 2013 14:44:03 +0000 Subject: [PATCH] [Add] Lua wrapper calls. --- scripts/ai/API | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 1 + 2 files changed, 79 insertions(+) create mode 100644 scripts/ai/API diff --git a/scripts/ai/API b/scripts/ai/API new file mode 100644 index 0000000..7f0dab2 --- /dev/null +++ b/scripts/ai/API @@ -0,0 +1,78 @@ +// ================ +// TASKS! +// ================ + +pushtask(number pos, string name, int/pointer targer) + -- Pushes a task onto the queue. + -- pos : Place task at the beginning if 0, or end if 1. + -- name : Function name, this is to be defined in the lua file. + -- target : int or pointer containing target info (for example, could be + pilot id or a Vec2). + -- return nil. + +poptask() + -- Pops the current task from the list. + -- return nil + +taskname() + -- Returns the current task name. + -- return string name of the current task. + +// ================ +// CONSULT! +// ================ + +gettarget() + -- Gets the current target. + -- return pointer to the target. + +gettargerid() + -- Gets the current targets id. + -- return number of the current target id. + +getdist(Vec2 vect) + -- Gets the distance from the position of the Vec2 vect. + -- Vect point to calculate the distance from. + -- return nil. + +getpos(number/pilot) + -- Get the pilots position of the current pilots position if no pilot + is specified. + -- pilot ID or poiunter to the pilot to get the position of, if no params are called + it uses the current pilot as target. + -- return Vec2 + +minbrakedist() + -- Returns the minimum required braking distance assuming all goes well. + -- return number distance needed to brake. + +// ================ +// MOVEMENT! +// ================ + +accel(number mod) + -- Accelerates the pilot. + -- mod float that represents acceleration ratio between 0(stopped) and 1(max accel). + -- return nil. + +turn(number mod) + -- Turns the pilot. + -- mod float that represents the turning ratio between -1(max right) and 1(max left). + -- return nil. + +face(number/Vec2 target, number invert) + -- Turn to face the current target. + -- target pilot ID or Vec2 to face. + -- invert face away if 1 + -- return nil + +// ================ +// MISC! +// ================ + +createvect(number x, number y) + -- Create a vector from cartesian coords. + -- x coord of the vector. + -- y coord of the vector. + -- return pointer to the Vec2 + diff --git a/src/main.c b/src/main.c index fa30dd3..fb37a60 100644 --- a/src/main.c +++ b/src/main.c @@ -239,6 +239,7 @@ int main(int argc, char** argv) { // | Text and GUI. // ======================================================== static void update_all(void) { + // dt in us. double dt = (double)(SDL_GetTicks() - time) / 1000.; time = SDL_GetTicks();