Author Topic: cant make this code work  (Read 1393 times)

Offline mordain

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
cant make this code work
« on: April 22, 2015, 02:14:08 AM »
hi, im messing around with the DS lib after long absence, I'm using 3.8.6. Anyway this simple code wont work (the object wont move after clone), was hoping i could get tips on where i am going wrong. BTW im using the "make" command in my workroom.

thanks for any advice

Code: [Select]
#include <lib.h>
inherit LIB_ITEM;

void create(){
    ::create();
    SetKeyName("stick");
    SetShort("a small stick");
    SetLong("Whats brown and sticky?  A stick.");
    SetMass(1);
}

void init(){
    ::init();

    add_action("doMake","make");
}

int doMake() {
object ob;
object dest;

ob = new("/domains/town/npc/cod.c");
if ( !ob ) {
message("system", "%^RED%^!%^RESET%^Failed to clone", this_player());
        return;
    }

dest = living(ob) ? environment(this_player()) : this_player();
    if ( !(ob->eventMove(dest)) ) {
message("system", "%^RED%^!%^RESET%^A| Failed to properly move "+ob->GetShort()+" to "+dest->GetShort(), this_player());
if ( !(ob->eventMove(environment(this_player()))) ) {
message("system", "%^RED%^!%^RESET%^B| Failed to properly move the object to "+environment(this_player())->GetShort(), this_player());
if ( !(ob->eventMoveLiving(environment(this_player()))) ) {
    message("system", "%^RED%^!%^RESET%^C| Failed to properly move the object.", this_player());
                return;
}
}
}
}



Offline mordain

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
Re: cant make this code work
« Reply #1 on: April 22, 2015, 12:21:09 PM »
Further to this issue, when my test creator is groupmod -a SECURE I can successfully perform
Quote
eval return new("/domains/town/obj/cigar")->eventMove(this_player());
but not if i am only ASSIST. This doesn't affect the stick object however. Seems strange to me.

Offline mordain

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
Re: cant make this code work
« Reply #2 on: April 24, 2015, 02:33:53 AM »
ok this appears to be some kind of recently introduced bug/feature whereby an object cant clone stuff outside its own file tree/domain/realm.

eg.
The default workroom references /realm/user/area/obj/chest.c. This chest references various objects in /domains/default/obj/ and /secure/obj/. Cloning this chest produces an empty chest, however, cloning  /domains/default/obj/chest produces a chest full of the expected items.