From d0f25723946812b5bfe852d456456d18fec17376 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 9 Dec 2004 02:46:32 +0000 Subject: [PATCH] getfarg SVN revision: 12414 --- legacy/embryo/examples/test.sma | 10 ++++++++-- legacy/embryo/include/default.inc | 2 ++ legacy/embryo/src/lib/embryo_args.c | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/legacy/embryo/examples/test.sma b/legacy/embryo/examples/test.sma index cd07aaed85..5c8df2c757 100644 --- a/legacy/embryo/examples/test.sma +++ b/legacy/embryo/examples/test.sma @@ -98,7 +98,7 @@ main() printf("Done. Return value of testfn() was %i\n", ret); printf("Test varargs...\n"); - vargs(1, 2, "hello", "there", 8, 9); + vargs(1, 2, "hello", "there", 8, 77, 5.0, 7.77); printf("\n\n"); @@ -113,6 +113,7 @@ vargs(a, b, ...) for (new i = 2; i < numargs(); i++) { new val; + new Float:fval; new str[100]; printf(" GET ARG... %i\n", i); @@ -125,11 +126,16 @@ vargs(a, b, ...) } printf(" ARG: %s [max %i]\n", str, sizeof(str)); } - else + else if (i < 6) { val = getarg(i); printf(" ARG: %i\n", val); } + else if (i < 8) + { + fval = getfarg(i); + printf(" FARG: %f\n", fval); + } } printf("ARGS DONE.\n"); } diff --git a/legacy/embryo/include/default.inc b/legacy/embryo/include/default.inc index 411131e044..69521103e7 100644 --- a/legacy/embryo/include/default.inc +++ b/legacy/embryo/include/default.inc @@ -36,8 +36,10 @@ enum Float_Angle_Mode native numargs(); /* varags - get arg no "arg" */ native getarg(arg, index=0); +native Float:getfarg(arg, index=0); /* varags - set arg no "arg" */ native setarg(arg, index=0, value); +native setfarg(arg, index=0, Float:value); /* Convert a string into a floating point value */ native Float:atof(const string[]); diff --git a/legacy/embryo/src/lib/embryo_args.c b/legacy/embryo/src/lib/embryo_args.c index 6b9c0d63d8..b12f60019f 100644 --- a/legacy/embryo/src/lib/embryo_args.c +++ b/legacy/embryo/src/lib/embryo_args.c @@ -59,4 +59,6 @@ _embryo_args_init(Embryo_Program *ep) embryo_program_native_call_add(ep, "numargs", _embryo_args_numargs); embryo_program_native_call_add(ep, "getarg", _embryo_args_getarg); embryo_program_native_call_add(ep, "setarg", _embryo_args_setarg); + embryo_program_native_call_add(ep, "getfarg", _embryo_args_getarg); + embryo_program_native_call_add(ep, "setfarg", _embryo_args_setarg); }