Okay, here's the revised version, I followed the style guide the best I could.
flip.src
Code:
/*
* @AUTHOR Steven Jimenez [SMJ]
* @DATE October 29, 2006
*
* @NAME flip.src
* @VERSION 2.0
*
* @PARAM[me] Can contain a character reference, or an array
* holding a character reference and the object to
* be flipped.
*
* @RETURN 1 on completion.
* 0 on failure.
*/
use cfgfile;
use os;
use uo;
CONST FLIP_CONFIG_FILE := ("::flip");
program textcmd_flip (me)
var flip_config := ReadConfigFile(FLIP_CONFIG_FILE);
var object;
var who;
var flip_graphic;
if(!flip_config)
SysLog("Error: "+FLIP_CONFIG_FILE+" does not exist!");
return 0;
endif
if( TypeOf(me) == TypeOf( array{} ) )
object := me[2];
who := me[1];
else
who := me;
SendSysMessage(who,"Flip what?");
object := Target(who);
endif
if( !object )
SendSysMessage(who,"Cancelled.");
return 0;
endif
if( !(object.isA(POLCLASS_ITEM)) )
SendSysMessage(who,"You cannot flip that!");
return 0;
endif
if( object.movable == 0 )
SendSysMessage(who,"That is locked down.");
return 0;
endif
var object_graphic := object.graphic;
var new_obj_graphic;
var graphic_array := {};
var i := 1;
while( (i < 100) && (object_graphic != new_obj_graphic) )
if(!new_obj_graphic)
new_obj_graphic := object_graphic;
endif
new_obj_graphic := flip_config[CInt(new_obj_graphic)].ChangeTo;
if(new_obj_graphic != object_graphic)
graphic_array[i] := new_obj_graphic;
i := i+1;
endif
endwhile
var flip_menu := CreateMenu("Select a new orientation:");
var j;
for(j:=1;j<i;j:=j+1)
AddMenuItem(flip_menu,CInt(graphic_array[j]),object.name);
endfor
var selection := SelectMenuItem2(who,flip_menu);
if(!selection)
SendSysMessage(who,"Canceled.");
return 0;
endif
flip_graphic := CInt(selection.graphic);
object.graphic := flip_graphic;
return 1;
endprogram
And if you needed to make your own flip.cfg file, here's the source to a little program I wrote to loop large groups of objects together:
fliploop.cpp (This one requires a C++ Compiler.)
Code:
/**
* @AUTHOR Steven Jimenez [SMJ]
* @DATE October 21, 2006
*
* @FILE file.cpp
* @VERSION 1.0
*/
#include <fstream>
#include <iostream>
#include <string>
#include <algorithm>
/**
* std::string toHex(int integer)
*
* @PARAM Integer to convert to hex value.
* @RETURN String of hex equivalent of parameter "integer".
*/
std::string toHex(int integer) {
std::string ret;
char num;
do {
switch(integer%16) {
case 15:
num = 'F';
break;
case 14:
num = 'E';
break;
case 13:
num = 'D';
break;
case 12:
num = 'C';
break;
case 11:
num = 'B';
break;
case 10:
num = 'A';
break;
case 9:
num = '9';
break;
case 8:
num = '8';
break;
case 7:
num = '7';
break;
case 6:
num = '6';
break;
case 5:
num = '5';
break;
case 4:
num = '4';
break;
case 3:
num = '3';
break;
case 2:
num = '2';
break;
case 1:
num = '1';
break;
default:
num = '0';
break;
}
ret += num;
integer /= 16;
} while (integer);
reverse(ret.begin(), ret.end());
return ret;
}
/**
* int main(VOID)
*
* @RETURN 0 on completion.
*/
int main() {
int start, end, temp;
std::string filename;
std::string output;
while(1) {
system("CLS");
std::cout << "Start: ";
std::cin >> start;
std::cout << "End: ";
std::cin >> end;
end++;
if(start < end) {
temp = end;
end = start;
start = temp;
}
else if(start == end) {
return 1;
}
filename = "items["+toHex(start)+"-"+toHex(end)+"].txt";
std::fstream file_op(filename.c_str(),std::ios::out);
output = "";
for(int i=start; i<end; i++) {
output+= "FLIP 0x"+toHex(i)+"\n";
output+= "{\n";
if(i==end-1)
output+= "\tChangeTo 0x"+toHex(start)+"\n";
else
output+= "\tChangeTo 0x"+toHex(i+1)+"\n";
output+="}\n";
}
std::cout << (end-start) << " entries printed.\n";
file_op << output << "###########\n";
file_op.close();
system("PAUSE");
}
return 0;
}
I've attatched my flip.cfg (Goes in /pol/config), but it's huge (Thus why I wrote a program to help out.)