[Add] Lua wrapper calls.
This commit is contained in:
parent
2619277baf
commit
86feaa0336
78
scripts/ai/API
Normal file
78
scripts/ai/API
Normal file
@ -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
|
||||||
|
|
@ -239,6 +239,7 @@ int main(int argc, char** argv) {
|
|||||||
// | Text and GUI.
|
// | Text and GUI.
|
||||||
// ========================================================
|
// ========================================================
|
||||||
static void update_all(void) {
|
static void update_all(void) {
|
||||||
|
// dt in us.
|
||||||
double dt = (double)(SDL_GetTicks() - time) / 1000.;
|
double dt = (double)(SDL_GetTicks() - time) / 1000.;
|
||||||
time = SDL_GetTicks();
|
time = SDL_GetTicks();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user