Some help with LUA script Transport

Some help with LUA script Transport

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Some help with LUA script Transport

Post by bobthedinosaur »

I haven't found any examples out there
I can do most of it but the old ATAN XZ and then Y system confuses me since LUA uses a X Y Z

So how would this translate into LUA's system:

Code: Select all


TransportPickup(id)
	{
	if(units_inside>=8 || dead == 1)
		{
		return;
		}
	
	if(get XZ_HYPOT(get PIECE_XZ(base) - get UNIT_XZ(id))<=MAX_LOAD_RADIUS)
		{
		set BUSY to 1;
		turn lsho to y-axis get XZ_ATAN(get PIECE_XZ(lsho) - get UNIT_XZ(id)) now;
		move larm to z-axis get XZ_HYPOT(get PIECE_XZ(lsho) - get UNIT_XZ(id)) now;
		move larm to y-axis get UNIT_Y(id) - get PIECE_Y(lsho) now;
		
		attach-unit id to larm;
		move larm to z-axis 0 speed ((get XZ_HYPOT(get PIECE_XZ(lsho) - get UNIT_XZ(id)))/(LOAD_TIME))*1000;
		move larm to y-axis get PIECE_Y(base) - get PIECE_Y(lsho) speed ((get PIECE_Y(base) - get UNIT_Y(id))/(LOAD_TIME))*1000;
		sleep LOAD_TIME;		
		attach-unit id to 0 - 1;
		units_inside = units_inside +1;	
		set BUSY to 0;
		}
	}

TransportDrop(id,xz)
	{
	if(get XZ_HYPOT(get PIECE_XZ(base) - get UNIT_XZ(id))<=MAX_UNLOAD_RADIUS)
		{
		set BUSY to 1;
		call-script opendoor();
		if (dead == 0)
			{
                        UNLOAD_TIME = 1;
                        }

		turn usho to y-axis get XZ_ATAN(get PIECE_XZ(usho) - xz) now;
		move uarm to z-axis 0 now;
		move uarm to y-axis get PIECE_Y(base) - get PIECE_Y(usho) now;
		attach-unit id to uarm;
		
		move uarm to z-axis get XZ_HYPOT(get PIECE_XZ(usho) - xz) speed ((get XZ_HYPOT(get PIECE_XZ(usho) - xz))/(UNLOAD_TIME))*1000;
		move uarm to y-axis get GROUND_HEIGHT(xz) - get PIECE_Y(usho) speed ((get PIECE_Y(base) - get GROUND_HEIGHT(xz))/(UNLOAD_TIME))*1000;
		sleep UNLOAD_TIME;

		drop-unit id;
		units_inside = units_inside - 1;
		
		
		set BUSY to 0;
		
		}
	
	}
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Some help with LUA script Transport

Post by bobthedinosaur »

okay just a simple no animation land or sea pick up and drop would help a lot.

edit:

Thanks to car I have a a simple transport attach with out animation, btu it attaches to a peice:

Code: Select all

function script.TransportPickup ( passengerID )
		UnitScript.AttachUnit ( trans, passengerID )  --"trans" is name of part attached to
end

function script.TransportDrop ( passengerID, x, y, z )
	UnitScript.DropUnit ( passengerID, x, y, z )	
end
How do you attach-unit id to 0 - 1; (make it invisible) like in cob?

would that be UnitScript.AttachUnit ( 0, passengerID ) ?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Some help with LUA script Transport

Post by FLOZi »

Think about what 0 - 1 is. :P

Code: Select all

UnitScript.AttachUnit ( -1, passengerID )
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Some help with LUA script Transport

Post by bobthedinosaur »

ill try it
Post Reply

Return to “Lua Scripts”