Thread

object changing help (Sdk)

object changing help // Sdk

1  |  

swe

Sep 11, 2003, 9:33pm
hey, i need help with changing the action of an object when i already have
the object number. heres the code i have:

aw_int_set (AW_OBJECT_OLD_NUMBER, screenNumber);
aw_string_set(AW_OBJECT_ACTION,newDes);
aw_object_change();

so, can anyone help me? :) i keep on getting an error 204:
RC_CANT_FIND_OLD_ELEMENT, so not sure what im doing wrong, since im pretty
sure the object number is right, i get it when the user clicks the screen.
:)

-SWE

andras

Sep 12, 2003, 5:14am
[View Quote] You need to provide the address of the object too:

Excerpt from the SDK help:

"
The object to be changed is uniquely identified by the attributes AW_OBJECT_OLD_NUMBER, AW_OBJECT_OLD_X, and AW_OBJECT_OLD_Z. These values are typically taken from the attributes AW_OBJECT_NUMBER, AW_OBJECT_X, and AW_OBJECT_Z within the context of either the AW_EVENT_CELL_OBJECT or AW_EVENT_OBJECT_ADD event.

XAMPLE

int rc;

aw_int_set (AW_OBJECT_OLD_NUMBER, 1278643762);
aw_int_set (AW_OBJECT_OLD_X, 0);
aw_int_set (AW_OBJECT_OLD_Z, 0);
aw_int_set (AW_OBJECT_X, -200);
aw_int_set (AW_OBJECT_Y, 0);
aw_int_set (AW_OBJECT_Z, 0);
aw_int_set (AW_OBJECT_YAW, 0);
aw_int_set (AW_OBJECT_TILT, 0);
aw_int_set (AW_OBJECT_ROLL, 0);
aw_int_set (AW_OBJECT_OWNER, my_number);
aw_string_set (AW_OBJECT_MODEL, "street1.rwx");
aw_string_set (AW_OBJECT_DESCRIPTION, "Cornerstone");
aw_string_set (AW_OBJECT_ACTION, "create sound xyz.mid");
if (rc = aw_object_change ())
printf ("Unable to change object (reason %d)\n", rc);
else
puts ("Object changed");


"



--
Andras
"It's MY computer" (tm Steve Gibson)

swe

Sep 12, 2003, 1:04pm
i actually already done that, but it still wouldnt find it odly enough.
thanx for the help though! :)

-SWE

[View Quote]

strike rapier

Sep 12, 2003, 3:33pm
Are you basing it off a query? Only ever deal with 'live' data, thats data
that you know exists....

While the code Andras posted its correct, you have to be absolutly sure that
you have the live data for the objects X and Z coordinate, as well as its
number... then use this...

aw_int_set(AW_OBJECT_OLD_NUMBER, lngObjectNumber);
aw_int_set(AW_OBJECT_OLD_X, lngObjectX);
aw_int_set(AW_OBJECT_OLD_Z, lngObjectZ);

That will fully reference what you are after... coordinate X and Z are
needed for the database to find the object in a relitivly quick time... can
you imagine trying to query 10,000,000 database records every single time
you change an object? There is always a user-based local store but thats
getting too much to elaborate on here.

- Mark

[View Quote]

swe

Sep 12, 2003, 10:13pm
i get the info when the user clicks the object, so im pretty sure its
correct.

-SWE

[View Quote]

milesteg

Sep 12, 2003, 11:04pm
please post a more complete code ,
that would certainly help to see where is the problem :)

Regards,
MilesTeg

"swe" <swe at swe-e.com> a écrit dans le message de
news:3f626141$1 at server1.Activeworlds.com...
> i get the info when the user clicks the object, so im pretty sure its
> correct.
>
> -SWE
>
[View Quote]

swe

Sep 12, 2003, 11:18pm
alright, well heres my complete code! i guess it code also be helpful to
people if they are tring to make like a projector bot or something :), or
just a win 32 console which gets info from a txt file, well, heres the code!
p.s: its not commented, and is very very messy! ^_^: oh, to get it to work,
you will need 2 text files, one called cit.txt and the other called
pictures.txt, check the code to see the infomation needed, quite obvious i
think. but i'll put a sample txt file here anyway.

====================[code]============================

//SWE's projector bot!


#include <iostream>
#include <fstream.h>
#include "aw.h"

void citLogin();
void getUrl();

void chatHandle();
void objectClick();
char Speaker[100];
char urls[256][256];
char uniUrl[256];
int uniPort;

int screenNumber,screenX,screenZ;
int frameNum = 0;

int main(){

citLogin();
std::cout<<"\nBack in main from citLogin\n";
getUrl();
std::cout<<"\nback in main from getUrl\n";




while (!aw_wait (-1))
;


return 0;
}

void citLogin(){

int citnum,NS,EW,Alt,Av,i,rc;
char password[256],world[256],botName[256];
fstream file;
file.open("cit.txt",ios::in);
if (file.is_open()){
std::cout<<"opened";
}

else{
std::cout<<"failed";
}


file >> citnum >> password >> botName >> world >> NS >> EW >> Alt >> Av >>
Speaker >> uniUrl >> uniPort;

if (rc=aw_init(AW_BUILD)){
std::cout << "unable to login, reason :" <<rc;
}
aw_event_set(AW_EVENT_CHAT,chatHandle);

aw_event_set(AW_EVENT_OBJECT_CLICK,objectClick);

std::cout<<"\ncreated\n";

if (rc=aw_create(uniUrl,uniPort,0)){
std::cout << "unable to login, reason :" <<rc;
}

std::cout<<"\nloging in uni\n";

aw_int_set (AW_LOGIN_OWNER, citnum);
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, password);
aw_string_set (AW_LOGIN_APPLICATION, "SWE's projector bot");
aw_string_set (AW_LOGIN_NAME, botName);

if (rc = aw_login ()) {
printf ("Unable to login (reason %d)\n", rc);
exit (1);
}
std::cout<<"logged in";

if (rc = aw_enter (world)) {
printf ("Unable to enter world (reason %d)\n", rc);
exit (1);
}
std::cout<<"\nentered world\n";

/* announce our position in the world */
aw_int_set (AW_MY_X, EW*1000); /* 1W */
aw_int_set (AW_MY_Z, NS*1000); /* 1N */
aw_int_set (AW_MY_YAW, 0); /* face towards GZ */
if (rc = aw_state_change ()) {
printf ("Unable to change state (reason %d)\n", rc);
exit (1);
}
std::cout<<"\nmoved to position\n";
file.close;
/* main event loop */
}

void chatHandle(){
//std::cout <<"\nchat handle\n";
char newAction[256];
char outMessage[256];
int rc;
if(stricmp(aw_string(AW_CHAT_MESSAGE),"next")==0){
//std::cout <<"message is next";
if(stricmp(aw_string(AW_AVATAR_NAME),Speaker)==0){
//std::cout <<"the right speaker"<<"\n";
frameNum++;
sprintf(newAction,"create picture %s",urls[frameNum]);
std::cout<<newAction<<"\n";
sprintf(outMessage,"changing


aw_int_set (AW_OBJECT_OLD_NUMBER, screenNumber);
aw_int_set (AW_OBJECT_OLD_X, screenX);
aw_int_set (AW_OBJECT_OLD_Z, screenZ);
aw_string_set (AW_OBJECT_ACTION, newAction);
if (rc = aw_object_change ())
printf ("Unable to change screen (reason %d)\n", rc);
else {
printf ("screen changed.\n");
screenNumber = aw_int (AW_OBJECT_NUMBER);
}

}
}

}

void objectClick(){
std::cout<<"\nobject clicked\n";
if(stricmp(aw_string(AW_AVATAR_NAME),Speaker)==0){
std::cout<<"object clicked by speaker\n";
if(stricmp(aw_string(AW_OBJECT_DESCRIPTION),"screen")==0){
/*
int
screenNumber,screenX,screenY,screenZ,screenYaw,screenTilt,screenRoll,screenO
wner;
char screenObject[100];*/
screenNumber = aw_int(AW_OBJECT_NUMBER);
screenX = aw_int(AW_OBJECT_Z);
screenZ = aw_int(AW_OBJECT_Z);
std::cout<<"description is screen. object number taken : "<<screenNumber;
aw_say("New projection screen selected!\n");
screenNumber = aw_int(AW_OBJECT_NUMBER);
}
}
}
void getUrl(){

fstream url;
int count,i;
i = 1;

url.open("pictures.txt",ios::in);


url >> count;

while (count >= i){
url >> urls[i];
i++;
}
url.close();
}

/*=====================[cit.txt]===============================
141 password BotName eu-bots 1 1 1 0 SWE auth.activeworlds.com 5702



=====================[pictures.txt]============================
2 www.kkw.com/hhe01.jpg www.kkw.com/hhe02.jpg




thanx for all the help! and your welcome for anyone who this may in someway
help!
-SWE

swe

Sep 12, 2003, 11:28pm
found the problem! in the object click, i put the X coords as the Z coords.
thanx everyone! ^_^

-SWE

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn