Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Using GetThingLVec verb
Using GetThingLVec verb
2002-07-26, 3:03 PM #1
Im using a cog that must replace a template with another...in the exact position as its predecessor. Using GetThingPos Im able to get the thing's x y z vector...but I cant tell if GetThingLvec is working correctly...Because sometimes the new template appears upsidedown.

(This is a major bummer since the templates are themselves spinning...When this upsidedown replacement occurs the spinning is in the wrong dirrection)

(Sorry, dont have the cog with me now to paste it here.)
2002-07-26, 4:38 PM #2
Simple thing. These lines of code will make it appear correctly.
Code:
sector = GetThingSector(thing);
pos = GetThingPos(thing);
Lvec = GetThingLVec(thing);
DestroyThing(thing);
CreateThingAtPos(Thing2, sector, pos, Lvec);
There you go. [http://forums.massassi.net/html/smile.gif] Make sure you add the proper symbols. [http://forums.massassi.net/html/wink.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 26, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-26, 5:04 PM #3
[http://forums.massassi.net/html/confused.gif] Or, you could do it like this, and save a ton of variables....

Code:
Createthingatpos(Thing2, Getthingsector(Thing), Getthingpos(Thing), Getthinglvec(Thing));
Destroything(Thing);



Sometimes I worry about you...

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-07-26, 5:09 PM #4
That is basically what the cog does, (although the sector is already known).

My problem is that the look-vector sometimes gives an upsidedown result. Like a glazed donut with the glaze on the bottom.
2002-07-26, 5:10 PM #5
Its only three variables (yes, I know about what happened to you) and we don't know if he might need those varables later on. Go take a look at your own thread GBK, I'm right sometimes.

I wonder what/who SaberMaster wonders about...

edit - post the origanal cog and let us have a look see.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 26, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-26, 7:18 PM #6
Ok...here'z the cog. Its a mess.

Code:
symbols

sector    sec1

thing     ghost0
thing     ghost1
thing     ghost2
thing     ghost3
thing     walkway
thing     console                   mask=405

template  tesslagood3=tesslagood3   
template  walkwaytemp
template  box

vector    walkwaypos                local
vector    walkwaylvec               local

int       rounds=4                  desc=rounds
int       cur_round=0               local
int       dummy=-1                  local
int       curtemplate=-1            local
int       active=0                  local
int       i                         local
int       x=0                       local

flex      time                      desc=speed
flex      countdown=30.0            
flex      delay=3.0                 desc=delay

message   startup
message   pulse
message   activated
message   timer

end

code
startup:
	dummy = CreateThing(box, walkway);

Return;
activated:
	Print("activated!");
	if(active == 1) Return;
	active = 1;
	SetPulse(countdown);

Return;
pulse:
	if(x == 0)
	{
		WaitForStop(dummy);
		walkwaypos = GetThingPos(dummy);
		walkwaylvec = GetThingLVec(dummy);
		DetachThing(dummy);
		x = 2;
		cur_round = 0;
		while(cur_round < rounds)
		{
			for(i = 0; i <= 5; i = i + 1)
			{
				Print("destroys first or last  walk!");
				DestroyThing(dummy);
				Print("Destroy tube");
				dummy = CreateThingAtPos(tesslagood3, sec1,
				walkwaypos, walkwaylvec);
				Print("create tess");
				curtemplate = ghost0[Rand() * 4];
				AttachThingToThingEx(dummy, curtemplate, 0x8);
				RotatePivot(curtemplate, 0, time);
				WaitForStop(dummy);
			}
			cur_round = cur_round + 1;
		}
		x = 1;
		Return;
	}
	else if(x == 1)
	{
		x = 2;
		WaitForStop(dummy);
		walkwaypos = GetThingPos(dummy);
		walkwaylvec = GetThingLVec(dummy);
		DetachThing(dummy);
		cur_round = 0;
		while(cur_round < rounds)
		{
			for(i = 0; i <= 5; i = i + 1)
			{
				Print("destroys first or last  walk!");
				DestroyThing(dummy);
				Print("Destroy tube");
				dummy = CreateThingAtPos(tesslagood3, sec1,
				walkwaypos, walkwaylvec);
				Print("create tess");
				curtemplate = ghost0[Rand() * 4];
				AttachThingToThingEx(dummy, curtemplate, 0x8);
				RotatePivot(curtemplate, 0, time);
				Sleep(delay);
			}
			cur_round = cur_round + 1;
		}
		x = 0;
		Return;
	}
	else Print("or else");

Return;
timer:
	active = 0;

Return;
end


[This message has been edited by SaberMaster (edited July 27, 2002).]
2002-07-27, 4:05 AM #7
Hard to read, use code tags and edit that post. I see these errors. When you are trying to get the Lvec and pos, the lines
walkwaypos=(GetThingPos(dummy));
walkwaylvec=(GetThingLVec(dummy));
should be
walkwaypos=GetThingPos(dummy);
walkwaylvec=GetThingLVec(dummy);
sec1=GetThingSector(dummy);
That way, you can make the sector local.
  • You need a SetTimer line in activated or pulse else timer won't get called.
  • Since I had a problem with the startup, add the line Sleep(.25); as the first line, right below startup:
  • Make sure the postion in not on an adjoin, can have screwy results.

Now try it.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-27, 6:05 AM #8
Pilot, those aren't really errors there. The extra set of parentheses won't make a difference to the expression's value.

Quote:
<font face="Verdana, Arial" size="2">Since I had a problem with the startup, add the line Sleep(.25); as the first line, right below startup:</font>


It's not a good idea to assume that a sleep at startup will fix everything. But in this case, I think a sleep of a second is needed.

The real problem here may be with the concept of lookvectors. A lookvector is simply a direction. When JK gives a thing a lookvector, it has to make the thing look in that direction as it naturally should. It is JK, and not the lookvector, that makes the thing stand upright as it looks in a direction. This is why you cannot make a thing look upside-down with a lookvector.

So I think your problem, Gel, is that the original thing is upside-down somehow.

As for the cog, I see several problems with it:
  • console is given a mask which should be in hexadecimal, but the '0x' is missing.
  • walkwaytemp isn't being used.
  • The sender of activated: is not checked.
  • x is set to two twice, but is assigned again before that value is used.
  • The returns inside the pulse's if statements are unnecessary.
  • The code that is run depending on whether x is 0 or 1 is the same except for one line.
    This redundancy could be fixed by using an if statement in the for loop such as:
    Code:
    if(x == 0) WaitForStop(dummy);
    else Sleep(delay);


Besides those, I am curious about the system you have of creating a new thing, attaching it, rotating it, and then waiting for a while before beginning again. Does this system work as you intented it to?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-27, 8:19 AM #9
I rewrote the cog. It functions similarly. And it does work except for that same upside-down problem. Thats what the real problem is...How can I give the new template the correct and complete vector so it never puts it upsidedown. See, the template is spinning & rotating. And

symbols

sector sec1
thing ghost0
thing ghost1
thing ghost2
thing ghost3
thing walkway
thing console mask=0x405
thing box
template tesslagood3
template walkwaytemp
vector walkwaypos local
vector walkwaylvec local
int rounds=4 local
int cur_round=0 local
int dummy=-1 local
int curtemplate=-1 local
int active=0 local
int q=0 local
int swap=0 local
int sounddummy
flex time
flex countdown = 30.0
flex consoletime
sound alarm=00alarmloop01.wav
message pulse
message activated
message timer
end
# ============================================================

code

arrived:
JumptoFrame(dummy, 0 ,sec1);
return;

activated:
print("activated!");
if(active == 0) {
DestroyThing(box);
dummy = CreateThing(walkwaytemp, walkway);
SetPulse(countdown);
active = 1;
Return;
}
else if(active == 1){
active = 2;
SetTimer(consoletime);
sounddummy = PlaySoundLocal(alarm, 1.0, 0.0, 0x1);
if(swap==0){
swap=1;
return;}
else {
swap=0;
return;}
}
else Return;

pulse:
if (q==1) Return;

q=1;
WaitForStop(dummy);
walkwaypos=(GetThingPos(dummy));
walkwaylvec=(GetThingLVec(dummy));
PrintVector(walkwaylvec);
DetachThing(dummy);
DestroyThing(dummy);
StopSound(sounddummy, -1);

if ( swap == 0 ) {
dummy = CreateThingAtPos(tesslagood3, sec1, walkwaypos, walkwaylvec);
}

else if ( swap == 1 ) {
dummy = CreateThingAtPos(walkwaytemp, sec1, walkwaypos, walkwaylvec);
}

cur_round = rand()*3;
while(cur_round < rounds)
{
curtemplate=ghost0[rand()*4];
AttachThingtoThingex(dummy, curtemplate, 0x8);
RotatePivot(curtemplate, 0, Time);
WaitForStop(dummy);
cur_round = cur_round + 1;
}
q=0;
return;

timer:
active = 1;
Return;

end
#=============================================================



[This message has been edited by Gelatinous_Drool (edited July 27, 2002).]
2002-07-27, 9:47 AM #10
Forgot the code tags agian, doesn't wholy matter, just easier to read.
  • Arrived is undefined.
  • Make the sec1 local, add sec1 = GetThingSector(dummy); after walkwaypos and walkwayLvec lines
  • You could add SetThingLvec(dummy, '0 0 0'); after the create thing in swap==0 and swap==1 if/then statements in pulse, that should stop the problem, but if you want it to have the same Lvec as the rest you have to use X [X is a flex] = VectorX(walkwayLvec); to get the left/right looking. Use instead SetThingLVec(dummy, 'X 0 0'); (I think [http://forums.massassi.net/html/redface.gif] )
That's my suggestions/errors I see right now.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 27, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-27, 1:25 PM #11
Gel, instead of destroying the dummy and then creating a new one, create the new dummy using CreateThing() and then destroy the old one. So instead of:
Code:
DestroyThing(dummy);
dummy = CreateThingAtPos(tesslagood3, sec1, walkwaypos, walkwaylvec);

use this:
Code:
newDummy = CreateThing(tesslagood3, dummy);
DestroyThing(dummy);
dummy = newDummy;


And that should solve your problem. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-28, 7:30 AM #12
Thank you Dr. SaberMaster. That places the template correctly eachtime, its also neater and simpler.
2002-07-28, 12:10 PM #13
You're welcome. [http://forums.massassi.net/html/wink.gif] Glad I could help.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!