Пример #1
0
TRIGGER( use )(obj user)
{
  if(isAtHome(this))
  {
    systemMessage(user, "That ore belongs to someone else.");
    return(0x00);
  }
  if(hasObjVar(this, "inUse"))
  {
    systemMessage(user, "Someone is using that ore.");
    return(0x00);
  }
  else
  {
    setObjVar(this, "inUse", 0x01);
    attachscript(this, "removeinuse");
    callback(this, 0x1E, 0x1B);
  }
  int Q4Q1;
  int Q4YO;
  Q4Q1 = getResource(Q4YO, this, "metal", 0x03, 0x02);
  if(Q4YO > 0x04)
  {
    systemMessage(user, "Select the forge on which to smelt the ore, or another pile of ore with which to combine it.");
  }
  else
  {
    systemMessage(user, "Select another pile of ore with which to combine this.");
  }
  targetObj(user, this);
  return(0x00);
}
Пример #2
0
static boolean menusetscriptverb (hdltreenode hparam1, tyvaluerecord *v) {
	
	/*
	menu/op globals are set.  attach the script to the menubar cursor 
	
	12/22/91 dmb: get previous values in refcon before setting up new script
	*/
	
	register hdlmenurecord hm = menudata;
	hdlhashtable htable;
	bigstring bsname;
	tyvaluerecord scriptval;
	hdloutlinerecord hcopy;
	hdlheadrecord hcursor;
	hdlhashnode hnode;
	
	flnextparamislast = true;
	
	if (!getvarvalue (hparam1, 1, &htable, bsname, &scriptval, &hnode))
		return (false);
	
	if (!opvaltoscript (scriptval, &hcopy)) /*not a fatal error*/
		return (true);
	
	if (!opcopyoutlinerecord (hcopy, &hcopy))
		return (false);
	
	hcursor = (**outlinedata).hbarcursor;
	
	detachscript (hm, hcursor);
	
	attachscript (hm, hcursor, hcopy);
	
	/*
	megetmenuiteminfo (hcursor, &item); /%gets prior cmd key, or clears bytes%/
	
	mereleaserefconroutine (hcursor, true);
	
	(**hcopy).fldirty = true; /%force save on this guy's script%/
	
	item.linkedscript.houtline = hcopy;
	
	item.linkedscript.adrlink = nildbaddress; /%hasn't been allocated yet%/
	
	mesetmenuiteminfo (hcursor, &item);
	
	if ((**hm).scriptwindow != nil)
		mesmashscriptwindow ();
	*/
	
	(*v).data.flvalue = true;
	
	return (true);
	} /*menusetscriptverb*/
Пример #3
0
static boolean addmenucommandverb (hdltreenode hparam1, boolean flsubmenu, tyvaluerecord *v) {
	
	/*
	menu/op globals are _not_ set.  add a new menu item or submenu to a menubar, 
	or replace the script of any existing item, depending on the parameters 
	specified.
	
	9/11/92 dmb: when adding a submenu, delete existing item with same name
	
	9/28/92 dmb: move to the newly-deposited node
	
	2.1b4 dmb: set outlinesignature of newly-created scripts to 'LAND'
	*/
	
	register hdltreenode hp1 = hparam1;
	register hdloutlinerecord ho;
	register hdlmenurecord hm;
	hdlheadrecord hnode;
	hdlheadrecord hdelete = nil;
	hdlmenurecord hmenurecord;
	bigstring bsmenu;
	bigstring bsitem;
	bigstring bsscript;
	tydirection dir;
	hdlwindowinfo hinfo;
	boolean fl;
	hdlheadrecord hsubmenu;
	boolean flmainmenu = false;
	tyfindinfo findinfo;
	
	fl = false; /*default return*/
	
	if (!getmenuparaminmemory (hp1, &hmenurecord)) /*the menu to be changed*/
		return (false);
	
	if (!getstringvalue (hp1, 2, bsmenu)) /*the title of the menu to add to*/
		return (false);
	
	if (flsubmenu) {
		
		flnextparamislast = true;
		
		if (!getsubmenuvalue (hp1, 3, &hsubmenu)) /*the submenu to be inserted*/
			return (false);
		
		flmainmenu = isemptystring (bsmenu); /*caller wants this to be a main menu*/
		
		if (flmainmenu)
			opgetheadstring (hsubmenu, bsmenu);
		else
			opgetheadstring (hsubmenu, bsitem);
		}
	else {
		
		if (!getstringvalue (hp1, 3, bsitem)) /*the item in the menu to add, or replace*/
			return (false);
		
		flnextparamislast = true;
		
		if (!getstringvalue (hp1, 4, bsscript)) /*the text of the script to be set*/
			return (false);
		}
	
	/*
	set up globals
	*/
	
	hm = hmenurecord;
	
	ho = (**hm).menuoutline;
	
	if (shellfinddatawindow ((Handle) hm, &hinfo)) {
		
		shellpushglobals ((**hinfo).macwindow);
		
		pushundoaction (0); /*no undo*/
		}
	else
		mepushmenudata (hm);
	
	/*
	move headline to menu headline, creating it if necessary
	*/
	
	findinfo.pfind = bsmenu;
	
	hnode = (**ho).hsummit;
	
	dir = down;
	
	if (!opsiblingvisiter (hnode, false, &findheadlinevisit, &findinfo)) { /*found the menu*/
		
		hnode = findinfo.hfound;
		
		if (flmainmenu) { /*delete it so it can be replaced*/
			
			hdelete = hnode;
			
			goto gotposition;
			}
		}
	else {
		
		hnode = oprepeatedbump (down, longinfinity, hnode, false);
		
		if (flmainmenu)
			goto gotposition;
		
		if (!opaddheadline (hnode, down, bsmenu, &hnode))
			goto exit;
		}
	
	/*
	move headline to item headline, creating it if necessary
	*/
	
	findinfo.pfind = bsitem;
	
	if (!oprecursivelyvisit (hnode, 1, &findheadlinevisit, &findinfo)) { /*found the item*/
		
		hnode = findinfo.hfound;
		
		if (flsubmenu) /*delete it so it can be replaced*/
			hdelete = hnode;
		}
	else {
		
		if (ophassubheads (hnode)) {
			
			hnode = oprepeatedbump (down, longinfinity, (**hnode).headlinkright, false);
			
			dir = down;
			}
		else
			dir = right;
		
		if (flsubmenu)
			goto gotposition;
		
		if (!opaddheadline (hnode, dir, bsitem, &hnode))
			goto exit;
		}
	
	gotposition:
	
	if (flsubmenu) {
		/*
		insert the submenu
		*/
		
		opdeposit (hnode, dir, hsubmenu);
		
		opresetlevels (hsubmenu);
		
		opfastcollapse (hsubmenu);
		
		if (hdelete != nil) /*delete old item*/
			deletemenunode (hdelete);
		
		opexpandto (hsubmenu);
		}
	else { 
		/*
		set up the script
		*/
	
		if (isemptystring (bsscript))
			ho = nil;
		
		else {
			hdloutlinerecord houtline;
			hdlheadrecord hsummit;
			Handle hscript;
			
			if (!newtexthandle (bsscript, &hscript))
				goto exit;
			
			if (!newoutlinerecord (&houtline)) {
				
				disposehandle (hscript);
				
				goto exit;
				}
			
			ho = houtline; /*copy script outline into register*/
			
			if (!opnewstructure (hscript, &hsummit)) {
				
				opdisposeoutline (ho, false);
				
				goto exit;
				}
			
			(**ho).outlinesignature = 'LAND';
			
			(**ho).fontnum = (**hm).defaultscriptfontnum;
			
			(**ho).fontsize = (**hm).defaultscriptfontsize;
			
			opsetsummit (ho, hsummit);
			
			oppushoutline (ho);
			
			opsetdisplaydefaults (ho);
			
			oppopoutline ();
			}
		
		/*
		connect it
		*/
		
		detachscript (hm, hnode);
		
		attachscript (hm, hnode, ho);
		
		opexpandto (hnode);
		}
	
	oprefreshdisplay ();
	
	// now done by oprefreshdisplay - opsetctexpanded (outlinedata); /*re-compute in case we deposited to expanded node*/
	
	opdirtyoutline (); /*dirty the menubar outline*/
	
	langexternalsetdirty ((hdlexternalvariable) rootvariable, true); /*make sure changes are flagged*/
	
	/*
	if (htable == menubartable)
		langsymbolchanged (htable, bs, true);
	*/
	
	fl = true;
	
	exit:
	
	if (hinfo != nil)
		shellpopglobals ();
	else
		mepopmenudata ();
	
	(*v).data.flvalue = fl;
	
	return (fl);
	} /*addmenucommandverb*/
Пример #4
0
FUNCTION int Q659(obj user)
{
  int Q62A = getObjType(this);
  if(hasObjVar(this, "fuel"))
  {
    int fuel = getObjVar(this, "fuel");
  }
  switch(Q62A)
  {
  case 0x0A26:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1A);
    break;
  case 0x0A27:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1D);
    break;
  case 0x0A29:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B26);
    break;
  case 0x1853:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1854);
    break;
  case 0x1857:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1858);
    break;
  case 0x1849:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184A);
    break;
  case 0x184D:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184E);
    break;
  case 0x0A28:
    int Q527;
    obj Q47F = getBackpack(user);
    obj Q5BO = requestCreateObjectAt(0x0A0F, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5BO, "burning", 0x01);
    attachscript(Q5BO, "torch");
    callback(Q5BO, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5BO, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit candles into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit candles at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the candle, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5BO, user, 0x02);
        systemMessage(user, "You put the candle in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0F64:
  case 0x0F6B:
    Q47F = getBackpack(user);
    obj Q5CB = requestCreateObjectAt(0x0A12, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5CB, "burning", 0x01);
    attachscript(Q5CB, "torch");
    callback(Q5CB, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5CB, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit torches into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit torches at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the torch, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5CB, user, 0x02);
        systemMessage(user, "You put the torch in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0A18:
  case 0x0A1D:
  case 0x0A25:
    if(fuel > 0x00)
    {
      setObjVar(this, "burning", 0x01);
      callback(this, 0x1E, 0x39);
      setType(this, Q62A - 0x03);
    }
    else
    {
      systemMessage(user, "The lantern is out of fuel.");
    }
    break;
  default:
    return(0x00);
    break;
  }
  sfx(getLocation(this), 0x47, 0x00);
  return(0x01);
}