PenUltima Online

It is currently Thu Sep 04, 2008 11:17 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: When demolishing a house
PostPosted: Mon Jul 07, 2008 11:15 pm 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
I made a little code so that when someone has a certain item in their house, and they demolish their house, it *should* destroy the item and create the deed used to make the item where that item was. but it doesn't.

Any ideas what is wrong?

I added this code

Code:
if(GetObjProperty(thing, "objtype") == 0x10)
DestroyItem(thing);
var watt :=  CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1);
endif


in this section

Code:
function demolish(house)

  var lists := GetObjProperty(house, "footage");
  var itemlist := {};
  foreach entry in lists
    foreach thing in ListObjectsInBox(entry[1], entry[2], entry[3], entry[4], entry[5],entry[6])
      itemlist.append(thing);
    endforeach
  endforeach
  var chk;
  var builtdeed := GetObjProperty(house, "builtdeed");
  if(builtdeed)
    if(!DestroyItem(SystemFindObjectBySerial(builtdeed)))
      DestroyItem(SystemFindObjectBySerial(builtdeed, 1));
    endif
  endif
  foreach thing in itemlist
if(GetObjProperty(thing, "objtype") == 0x10)
DestroyItem(thing);
var watt :=  CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1);
endif
    if(GetObjProperty(thing, "houseserial") == house.serial)
      if ((GetObjProperty(thing, "secure") == 1) && (thing.movable == 0))
        EraseObjProperty(thing, "secure");
        if(GetObjProperty(thing, "houseserial" ) == house.serial)
          var oldscript := GetObjProperty(thing, "oldscript");
          if (oldscript == error)
            oldscript := "";
          endif
          thing.usescript := oldscript;
          thing.movable := 1;
          EraseObjProperty(thing, "houseserial" );
          EraseObjProperty(thing, "oldscript" );
        endif
      elseif ((GetObjProperty(thing, "lockeddown" ) == 1) && (thing.movable == 0))
        thing.movable := 1;
        EraseObjProperty(thing, "houseserial");
        EraseObjProperty(thing, "lockeddown");
      elseif (thing.movable == 0)
        if(thing.objtype == 0xa390)
           MoveItemToLocation(thing, thing.x, thing.y, (thing.z - 7), MOVEITEM_FORCELOCATION);
        else
          DestroyItem(thing);
        endif
      endif
    endif
  endforeach
  DestroyMulti(house );
  return;
endfunction


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 1:09 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
Well, after you destroy the thing there's no longer going to be usable x, y and z members.

Try creating the new item before and destroying the thing after.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 9:14 am 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
Hmm, that doesn't seem to be the problem as ingame when tested, either way(destroy before or after) they both leave the original item in a non-locked down form(movable) and no deed =/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 11:07 am 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 747
Location: Chicago, IL USA
is it possible that its because you're doing GetObjProperty(thing, "objtype") == 0x10 instead of thing.objtype == 0x10 ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 8:37 pm 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
Ill try at our next shard restart, thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 11:29 pm 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
Still didn't work =/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 11:34 am 
Offline

Joined: Thu Feb 02, 2006 8:33 am
Posts: 276
A very simple way to find self made errors in your own script is to put in some kind of output of especially the variables. I do this normally on my test server with the simple broadcast command. Sure there are other ways :D

I just make a suggestion what i would do with your script, because we all don't know what e.g. the cprop "footage" look like.
Perhaps you find the error that way or could at least give us the results:


Code:
function demolish(house)

  var lists := GetObjProperty(house, "footage");
broadcast("footage: " + lists);
  var itemlist := {};
  foreach entry in lists
    foreach thing in ListObjectsInBox(entry[1], entry[2], entry[3], entry[4], entry[5],entry[6])
      itemlist.append(thing);
    endforeach
  endforeach
broadcast("itemlist size: " + itemlist.size());
  var chk;
  var builtdeed := GetObjProperty(house, "builtdeed");
  if(builtdeed)
    if(!DestroyItem(SystemFindObjectBySerial(builtdeed)))
      DestroyItem(SystemFindObjectBySerial(builtdeed, 1));
    endif
  endif
  foreach thing in itemlist
broadcast("Test 1");
if(GetObjProperty(thing, "objtype") == 0x10)
broadcast("Test 2");
DestroyItem(thing);
var watt :=  CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1);
endif
    if(GetObjProperty(thing, "houseserial") == house.serial)
      if ((GetObjProperty(thing, "secure") == 1) && (thing.movable == 0))
        EraseObjProperty(thing, "secure");
        if(GetObjProperty(thing, "houseserial" ) == house.serial)
          var oldscript := GetObjProperty(thing, "oldscript");
          if (oldscript == error)
            oldscript := "";
          endif
          thing.usescript := oldscript;
          thing.movable := 1;
          EraseObjProperty(thing, "houseserial" );
          EraseObjProperty(thing, "oldscript" );
        endif
      elseif ((GetObjProperty(thing, "lockeddown" ) == 1) && (thing.movable == 0))
        thing.movable := 1;
        EraseObjProperty(thing, "houseserial");
        EraseObjProperty(thing, "lockeddown");
      elseif (thing.movable == 0)
        if(thing.objtype == 0xa390)
           MoveItemToLocation(thing, thing.x, thing.y, (thing.z - 7), MOVEITEM_FORCELOCATION);
        else
          DestroyItem(thing);
        endif
      endif
    endif
  endforeach
  DestroyMulti(house );
  return;
endfunction


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl