|
Problem with making entities exclusive...
#167220
11/14/07 00:28
11/14/07 00:28
|
Joined: Mar 2005
Posts: 84 The Sacred Silence and Sleep
Spectre
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2005
Posts: 84
The Sacred Silence and Sleep
|
What I'm trying to do is create an entity with some text above it and then create another with different text and so on and so forth. Everything works accordingly except all the entities show the same text. For example, I create ent1 and the text says 'Testing1', then I create ent2 and the text says 'Testing2'...however the text above ent1 also says 'Testing2' and obviously I need it to stay as it was. Any ideas? Here is the quick and dirty example code: Code:
var EntLoc[3]=-1536,-896,50; //the firstloc of the entity var StrIndex = 1;
entity* TestEnt;
string Warlock = <warlock.mdl>;
string TestString1 (Testing1); string TestString2 (Testing2); string TestString3 (Testing3); string TestString4 (Testing4); string TestString5 (Testing5); string TestString6 (Testing6); string TestString7 (Testing7); string TestString8 (Testing8);
TEXT TestStr { strings = 8; string = TestString1,TestString2,TestString3,TestString4,TestString5,TestString6,TestString7,TestString8; }
function CreateEntTest(); function DrawText();
function DrawText() { var TextPos; //where the text should appear TestEnt = my; while(1) { vec_set(TextPos,vector(my.x,my.y,my.z+55)); //sets the 'text' above the model.Play with the + values vec_set(temp,TextPos); vec_to_screen(temp,camera); if (c_trace(TextPos,camera.x,IGNORE_ME|IGNORE_PASSABLE)==0&&temp!=0) { draw_text(TestStr.string[StrIndex],temp.x,temp.y,vector(255,50,50)); } wait(1); } }
function CreateEntTest() { ent_create(Warlock,EntLoc,DrawText); EntLoc.x+=256; StrIndex +=1; }
on_a=CreateEntTest();
|
|
|
Re: Problem with making entities exclusive...
[Re: Spectre]
#167221
11/14/07 13:25
11/14/07 13:25
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
maby this work i didnt test it Code:
function DrawText() { var TextPos; //where the text should appear var stri; stri = strindex; TestEnt = my; while(1) { vec_set(TextPos,vector(my.x,my.y,my.z+55)); //sets the 'text' above the model.Play with the + values vec_set(temp,TextPos); vec_to_screen(temp,camera); if (c_trace(TextPos,camera.x,IGNORE_ME|IGNORE_PASSABLE)==0&&temp!=0) { stri.x = strindex; strindex = stri; draw_text(TestStr.string[StrIndex],temp.x,temp.y,vector(255,50,50)); strindex = stri.x; } wait(1); } }
"empty"
|
|
|
Re: Problem with making entities exclusive...
[Re: flits]
#167222
11/14/07 14:51
11/14/07 14:51
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
Expert
|
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
Both are wrong.... Do it like that and it works: Code:
function DrawText() { var TextPos; //where the text should appear var stri; stri = strindex; TestEnt = my; while(1) { vec_set(TextPos,vector(my.x,my.y,my.z+55)); vec_set(temp,TextPos); vec_to_screen(temp,camera); if (c_trace(TextPos,camera.x,IGNORE_ME|IGNORE_PASSABLE)==0&&temp!=0) { draw_text(TestStr.string[stri],temp.x,temp.y,vector(255,50,50)); } wait(1); } }
|
|
|
Re: Problem with making entities exclusive...
[Re: Puppeteer]
#167223
11/14/07 14:57
11/14/07 14:57
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
yah your right but i dont use storage much but what was wrong the much scripting?
"empty"
|
|
|
Re: Problem with making entities exclusive...
[Re: flits]
#167224
11/14/07 15:27
11/14/07 15:27
|
Joined: Mar 2005
Posts: 84 The Sacred Silence and Sleep
Spectre
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2005
Posts: 84
The Sacred Silence and Sleep
|
@ flits: Thanks for the attempt! @ DerOmega: I <3 you! it works! Thanks for the help  [edit] actually, would anyone mind telling me WHY that works and the way I did doesn't? I seem to make that kind of mistake often but not clear on how it works...
Last edited by Spectre; 11/14/07 15:29.
|
|
|
Re: Problem with making entities exclusive...
[Re: Spectre]
#167225
11/14/07 15:40
11/14/07 15:40
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
Expert
|
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
I is pretty easy your drawtext function runs all the time and it always uses strindex but strindex changes and so the drawtext function will use another value, which means all entitys will use the last string. @ flits: your code was nearly right you just did the mistake to change strindex into stri and the other way. You just have to set stri once  P.s. If you love me rate me 
|
|
|
Re: Problem with making entities exclusive...
[Re: Spectre]
#167227
11/14/07 16:10
11/14/07 16:10
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
thank you both
i see i was busy white my code that i was scrpiting and i did get a litle bit confused by it
"empty"
|
|
|
Problem with making entities exclusive...
[Re: flits]
#167228
11/14/07 18:03
11/14/07 18:03
|
Joined: Sep 2006
Posts: 188 Latvia
MDI
Member
|
Member
Joined: Sep 2006
Posts: 188
Latvia
|
Vau! Im quite often lost days with similiar problem to this! Thanks to all about this good post.
Latvija rullē
|
|
|
|