Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TedMar, AndrewAMD), 1,067 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
skills and local variables treated as global #204174
04/27/08 14:20
04/27/08 14:20
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
sorry for double posting(I origionaly posted this in a thred dedicated to something else)
I'm having another pointer issue.
__________________________________
4 entitys share the same action.

In a separate function I set one to speaker(pointer) and the rest to non_speaker(again, pointer)by testing their vec_dist to the player.

if I set speaker.skill1 to any number, all the ents with the same action get the same value for skill1...regardless of their pointer
___________________________________

Is this a bug or am I doing something wrong here, have pointers changed(how)...under lite-c?
skill1 is being treated like a global variable here, I noticed it states something like this in the manual. Does anyone know a workaround/method?


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204178
04/27/08 15:42
04/27/08 15:42
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Sounds like your pointers are just pointing to the same thing (even though you may think they're not). Could you post your code?

Re: skills and local variables treated as global [Re: Excessus] #204180
04/27/08 16:02
04/27/08 16:02
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
it almost literaly looks like this..

ENTITY* speaker;
ENTITY* non_speaker;

function dialogue_pointer()
{
if(vec_dist(player.x,my.x) < 100)
{
speaker = me;
{
else
{
non_speaker = me;
}
}

action actor()
{
while(player != NULL)
{
dialogue_pointer();
if((my.skill1 == 1) && (speaker == me))//no need to test dist already tested
{
init_dialogue();
my.skill1 = 0;//this however sets all "actors" skill1 to 0.
}
wait(1);
}
}

sorry for the stripped down version, but no one likes to sift through a thousnd lines of unrelated code. this is the only place where skill1 is even looked at or modified...very basic stuff, probably the reason it is killing me.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204181
04/27/08 16:03
04/27/08 16:03
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
should I be using...

set(me,speaker);

I also use a material(just ambient change) change here and it works???

Last edited by Nowherebrain; 04/27/08 16:04.

Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204215
04/27/08 21:54
04/27/08 21:54
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Yes, you should, if you really want to mess it up... ;\) Honestly, set is a macro designed for easily setting flags of an entity. Don't use it on pointers.

One thing caught my eye: You said there were three entities non-speakers and on speaker. Your code doesn't represent this. You just check the distance and assign a pointer corresponding to the distance. As you only defined two pointers only the last two entites checked will be pointed to anyways. If you're lucky and the distance of one is > 100 and the other ones is < 100 then you will have to pointers, one pointing to an entity farer away, the other one pointing to the nearer one. If you're not so lucky the distance will be < 100 or < 100 for all entites and only one pointer will get assigned at all.

Keep in mind a pointer can only point to one certain address and will not be able to point to a group of entities.


Always learn from history, to be sure you make the same mistakes again...
Re: skills and local variables treated as global [Re: Uhrwerk] #204224
04/28/08 00:17
04/28/08 00:17
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
ahh, ok...maybe just assigning speaker will do the trick. Thanks for the advice I will test it soon...switched over to the art side for a bit..seeing as I was stuck.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204271
04/28/08 12:08
04/28/08 12:08
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
yep...sorta, I had to set up a switch sorta, bool, but it works efficiently..thanks.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204390
04/29/08 00:57
04/29/08 00:57
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
OK, I was wrong...dead wrong.
if you are setting my.skillx, it sets them all..
instead use pointerstring.skill1, this will only affect the pointer...Doh!
This is not the place, but maybe this should be added to "beginners mistakes" in the manual. ???

Last edited by Nowherebrain; 04/29/08 00:58.

Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: skills and local variables treated as global [Re: Nowherebrain] #204492
04/29/08 16:19
04/29/08 16:19
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
 Originally Posted By: Nowherebrain
if you are setting my.skillx, it sets them all..
instead use pointerstring.skill1, this will only affect the pointer.

That's not the whole truth. my.skillx = y will only set one entities skillx to y. But you have to keep in mind, that there may be multiple instances of a function running, with their me pointers pointing to different entities.


Always learn from history, to be sure you make the same mistakes again...
Re: skills and local variables treated as global [Re: Uhrwerk] #204576
04/30/08 01:30
04/30/08 01:30
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
but there is always the possibility if you have many ents with the same action....but c_move is a perfect example of you philosophy, in that instance I use the typical "my" with no issues...


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1