mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
let the past begone in cvs land. welcome to igit igit!
This commit is contained in:
commit
4e601cf1c7
509 changed files with 77963 additions and 0 deletions
52
place/allostack.c
Normal file
52
place/allostack.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
// stack implementation donated by psyc://psyced.org/~allo
|
||||
//
|
||||
#include <net.h>
|
||||
#define ON_COMMAND if (mycmd(command, args, source)) return 1;
|
||||
|
||||
#include <place.gen>
|
||||
|
||||
mycmd(a, args, source) {
|
||||
unless (source) source = previous_object(); // really needed???
|
||||
string *stack=allocate(0);
|
||||
if (v("stack")){
|
||||
stack=v("stack");
|
||||
}
|
||||
switch (a){
|
||||
case "push":
|
||||
stack=stack + ({ARGS(1)});
|
||||
vSet("stack", stack);
|
||||
castmsg(ME, "_notice_public_stack_add", "Eintrag #[_num] hinzugefuegt: "+stack[sizeof(stack)-1], (["_nick": "stack", "_num": sizeof(stack)]));
|
||||
break;
|
||||
case "get":
|
||||
if(sizeof(stack)>0){
|
||||
if(sizeof(args)==1){
|
||||
castmsg(ME, "_notice_public_stack", "Eintrag #[_num]: "+stack[sizeof(stack)-1], (["_nick": "stack", "_num": sizeof(stack)]));
|
||||
}else{
|
||||
args[1]=to_int(args[1]);
|
||||
if(sizeof(stack)>=args[1]){
|
||||
castmsg(ME, "_notice_public_stack", "Eintrag #[_num]: "+stack[(args[1])-1], (["_nick": "stack", "_num": args[1]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "pop":
|
||||
if(sizeof(args)==1){
|
||||
if(sizeof(stack)>0){
|
||||
castmsg(ME, "_notice_public_stack_delete", "Eintrag #[_num] entfernt: "+stack[sizeof(stack)-1], (["_nick": "stack", "_num": sizeof(stack)]));
|
||||
stack=stack - ({stack[sizeof(stack)-1]});
|
||||
vSet("stack", stack);
|
||||
}
|
||||
}else{
|
||||
args[1]=to_int(args[1]);
|
||||
if(sizeof(stack)>=to_int(args[1])){
|
||||
castmsg(ME, "_notice_public_stack_delete", "Eintrag #[_num] entfernt: "+stack[(args[1])-1], (["_nick": "stack", "_num": args[1]]));
|
||||
stack=stack - ({stack[args[1]-1]});
|
||||
vSet("stack", stack);
|
||||
}
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue