void Delivery::on_active() { if (_first_run) { set_delivery_items(); } //check for delivery_status and run through delivery routine switch(delivery_status){ case DELIV_PREFLIGHT: _first_run = true; advance_delivery(); break; case DELIV_ENROUTE: to_destination(); break; case DELIV_DROPOFF: activate_gripper(); break; case DELIV_RETURN: return_home(); break; case DELIV_DISARM: shutoff(); break; case DELIV_COMPLETE: default: break; } }
string ask_me(string arg) { object home, here = environment(); switch( arg ) { case "here" : if( base_name(here) == HOME ) return "这里是朝天宫,再上去便是武当金顶。"; else { command("say 这里是"+ here->query("short") +"………咦?我怎麽会在这。"); if( !(home = find_object(HOME)) ) { message("vision", this_object()->name() +"急急忙忙地离开了。\n", environment(), this_object()); move("/d/death/death"); return "……"; } else { return_home(home); message("vision", this_object()->name() +"急急忙忙地走了过来。\n", environment(), this_object()); return "我怎麽跑到"+ here->query("short") +"去了。"; } } break; } }
int heal_up() { if(environment() && !is_fighting() && query("startroom") && file_name(environment()) != query("startroom")) { // command("say ok"); return_home(query("startroom")); return 1; } return ::heal_up() + 1; }
// Default chat function: Let the npc random move to another room. int random_move() { mapping exits; string *dirs; if( !mapp(exits = environment()->query("exits")) ) return 0; if (query("random_move") <= 0) return_home(query("startroom")); add("random_move",-1); dirs = keys(exits); command("go " + dirs[random(sizeof(dirs))]); }
int main(){ sleep(); have_meal(BREAKFAST); go_work(); code(); have_meal(LUNCH); code(); return_home(); have_meal(SUPPER); return 0; }
void main(void) { /* put your own code here */ EnableInterrupts; DDR1AD0 = DDRT = 0xFF; PT1AD0 = PTT = 0x00; set_baud_rate(9600); send(); fct_set(8,2,58); disp_on(1,1,1); entry_mode(1,0); clear_disp(); char val,buf[16] ; #define go 5000 while(1) { memset(buf,0,16); for(int v=0,i =0; i<16 ; i++) { v=0; while( chk_rx() >= 0 ? 0: i==0 ? 1: v++ < go ? 1: 0); if (v >= go){ break; } buf[i]=fetch_char(); } return_home(); clear_disp(); prt_str(buf); } for(;;) { _FEED_COP(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ }
int main(int argc, char **argv) { int check_busy = 0; if (argc < 3) usage(); //init spi oled init_spi_oled(argv[1]); argc-=2; argv+=2; while (argc >= 1) { const char *cmd = argv[0]; int args = 0; if (strcmp(cmd, "-B") == 0) { check_busy = 0; args = 1; check_busy_flag3(atoi(argv[1])); } if (strcmp(cmd, "-b") == 0) check_busy = 1; if (check_busy) check_busy_flag(); if (strcmp(cmd, "-f") == 0) { select_font(atoi(argv[1])); args = 1; } if (strcmp(cmd, "-e") == 0) { entry_mode_set(atoi(argv[1]), atoi(argv[2])); args = 2; } if (strcmp(cmd, "-m") == 0) { display_mode(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); args = 3; } if (strcmp(cmd, "-c") == 0) clear_display(); if (strcmp(cmd, "-g") == 0) { set_ddram_address(atoi(argv[1]) * 0x40 + atoi(argv[2])); args = 2; } if (strcmp(cmd, "-a") == 0) { set_ddram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-A") == 0) { set_cgram_address(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-w") == 0) { write_data(strtoul(argv[1], NULL, 0)); args = 1; } if (strcmp(cmd, "-h") == 0) return_home(); if (strcmp(cmd, "-C") == 0) { shift_cursor(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-S") == 0) { shift_display(*argv[1] == 'r'); args = 1; } if (strcmp(cmd, "-t") == 0) { write_str(argv[1]); args = 1; } if (*cmd != '-') write_str(cmd); check_busy = 1; argc -= 1 + args; argv += 1 + args; } }