0.82.7.1 to spring-83.0, something changed with AttachUnit?

0.82.7.1 to spring-83.0, something changed with AttachUnit?

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

Moderator: Moderators

Post Reply
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

0.82.7.1 to spring-83.0, something changed with AttachUnit?

Post by knorke »

I think something changed with Spring.UnitScript.AttachUnit and/or transport between spring 0.82.7.1 and spring-83.0
Anyone got an idea?
steps to reproduce:

download
http://springfiles.com/spring/games/spring-tanks
(version rc5.2) or rapid: springtanks:latest

start the mod on any map
press ESC to hide menu or disable the widget
do
/cheat
/give tplegocar
/give tpflag 1

drive to the flag with the car.

What happens in 0.82.7.1:

As you get near, the flag will attach itself on top of the car like this:
Image

This is because
gadgets\tp_gamelogic.lua

Code: Select all

blabla if unit is near flag then
env = Spring.UnitScript.GetScriptEnv(nearunitid)
if (env) then Spring.UnitScript.CallAsUnit(nearunitid,env.script.TransportPickup,flagid) end
scripts\tplegocar.lua

Code: Select all

function script.TransportPickup (passengerID)
...
		Spring.UnitScript.AttachUnit (flagattachpoint, passengerID)
...
end
What happens in 83.0 and later:
The flag does not get attached to the car.
If you put an Echo before the AttachUnit() one can see everything else works until there.

In newer spring versions, the units spawned by mod do not run their unitscripts because of wrong layer in gadget. There are also some wrong/too many lua base files. Not sure if that matters since units spawned with /give work, but in case there is svn with fixed version:
https://code.google.com/p/springtanks/


Was AttachUnit() made to check stricter what can load what?
These units should be able to load the flag though, wrt mass, size.
(AttachUnit should be able to attach anything to anything!)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by jK »

your flag is a building for those cantBeTransported is default true.

edit: the bold one
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by knorke »

thanks :)
If AttachUnit() could bypass those checks, that would be useful if one wants untransportable units that should still sometimes attach to other units. For example carrying a "weapon" or melee units picking up each like in wrestling.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by CarRepairer »

knorke wrote:If AttachUnit() could bypass those checks, that would be useful if one wants untransportable units that should still sometimes attach to other units. For example carrying a "weapon" or melee units picking up each like in wrestling.
Instead of a bypass (which would be a hidden behavior), better to have a finer control over which unit can transport which. Similarly I had hopes of that kind of control of which unit can repair which, based on category, but it doesn't seem likely to happen. http://springrts.com/phpbb/viewtopic.php?f=21&t=23397
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by smoth »

+1 Knorke's suggestion is legitimate
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by knorke »

Why is it hidden behaviour?
For units that the engine deems untransportable, the script.TransportPickup etc callins in LUS would never be called. (like now)

But if a gadget wants to attach one unit to another, it should be able to do so.
Similiar to how a unit with maxVelocity=0 can not move by engine, but gadget can still make it move with MoveCtrl functions.

But maybe Spring.UnitScript.AttachUnit is the wrong place for such attach function. Since it only takes one unitID as parameter, gadgets can not use it anyway.
Would it be better to have a Spring.AttachUnit (passengerID, transporterID, pieceNr) for gadgets?
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Post by CarRepairer »

Oh, I see what you mean now.
Post Reply

Return to “Lua Scripts”