.flip (Replacement for 096)
Posted: Mon Oct 23, 2006 2:32 pm
I was putting together a custom flip.cfg, and I noticed that the 096 .flip command had a lousy system for large flipping "cycles" (I have some items that can flip in excess of 20 times, that would take forever!) so I ended up writing a gump-based replacement.

Questions? Comments? Fixes?

Code: Select all
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// name: flip.src - Player Textcommand
// version: 2.0
// author: SMJ
//
// Purpose: Changes the orientation of a piece of furniture
//
////////////////////////////////////////////////////////////////////////////////////////////////////
use uo;
use cfgfile;
program flip (me)
var flipConfig := ReadConfigFile("::flip");
var furniture;
var flipGraphic;
if( TypeOf(me) == "Array" )
furniture := me[2];
me := me[1];
endif
if(furniture)
flipGraphic := flipConfig[CInt(furniture.graphic)].ChangeTo;
else
SendSysMessage(me, "Flip what?");
furniture := Target(me);
if(!furniture)
SendSysMessage(me, "Cancelled.");
return 0;
endif
if(!furniture.isA(POLCLASS_ITEM))
SendSysMessage(me, "You cannot flip that!");
return 0;
endif
if(furniture.movable == 0)
SendSysMessage(me,"That is locked down.");
return 0;
endif
var myGraphic := furniture.graphic;
var newGraphic;
var graphicArray := {};
var i := 1;
if(flipConfig)
while( (i < 100) && (myGraphic != newGraphic) )
if(!newGraphic)
newGraphic := myGraphic;
endif
newGraphic := flipConfig[CInt(newGraphic)].ChangeTo;
if(newGraphic != myGraphic)
graphicArray[i] := newGraphic;
i := i+1;
endif
endwhile
endif
var flipmenu := CreateMenu("Select a new orientation:");
var j;
for(j:=1;j<i;j:=j+1)
AddMenuItem(flipmenu,CInt(graphicArray[j]),furniture.name);
endfor
var selection := SelectMenuItem2(me,flipmenu);
if(!selection)
SendSysMessage(me,"Canceled.");
return 0;
endif
flipGraphic := CInt(selection.graphic);
endif
furniture.graphic := flipGraphic;
endprogram