101.0 Lua Breaking Changes

101.0 Lua Breaking Changes

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

101.0 Lua Breaking Changes

Post by hokomoko »

The following callins will now have 1-based weapon index arguments:
  • DrawShield,
  • ShieldPreDamaged,
  • AllowWeaponTargetCheck,
  • AllowWeaponTarget,
  • AllowWeaponInterceptTarget,
  • StockpileChanged
{Set,Get}UnitPieceCollisionVolumeData will now receive 1-based piece index argument (was 0-based until 100.0)
Kloot wrote: units are no longer automatically zombified on death, this is now Lua territory
Last edited by hokomoko on 08 Feb 2016, 14:06, edited 5 times in total.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by PicassoCT »

Generic Rant how fixed bugs break everything in my game.
User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by jamerlan »

hokomoko wrote:{Set,Get}UnitPieceCollisionVolumeData will now receive 1-based piece index argument (was 0-based until 100.0)
Do you mean that in spring 100 it is already 1-based? should we fix script for 100 engine too?

http://imolarpg.dyndns.org/trac/balates ... e.lua#L120
Is it enough to change this:
"spSetPieceCollisionData(unitID, pieceIndex, true, p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8])"
to
"spSetPieceCollisionData(unitID, pieceIndex + 1, true, p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8])"
to fix this?
Super Mario
Posts: 823
Joined: 21 Oct 2008, 02:54

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by Super Mario »

hokomoko wrote:{Set,Get}UnitPieceCollisionVolumeData will now receive 1-based piece index argument (was 0-based until 100.0)
I will ask this question: What are the reasoning and motivation behind this change?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by Silentwings »

jamerlan wrote:should we fix script for 100 engine too?
Didn't read closely but it looks the dyn col vol gadget is getting its pieceIDs from a Get* call, and then using them in the Set* call. So since the same change affects both calls, I suspect no change is needed there.
What are the reasoning and motivation behind this change?
In lua, arrays (and everything else, including Springs own conventions, except a few rogue examples such as this one) start counting at 1.
User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by jamerlan »

Silentwings wrote:Didn't read closely but it looks the dyn col vol gadget is getting its pieceIDs from a Get* call, and then using them in the Set* call. So since the same change affects both calls, I suspect no change is needed there.
get method is not used, only localized http://imolarpg.dyndns.org/trac/balates ... me.lua#L18
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by Silentwings »

http://imolarpg.dyndns.org/trac/balates ... e.lua#L117, http://imolarpg.dyndns.org/trac/balates ... e.lua#L131, etc.

Hopefully looking at those lines makes it clear what change will need to be applied.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by Kloot »

should we fix script for 100 engine too?
No, only for >= 101.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: 101.0 {Set,Get}UnitPieceCollisionVolumeData change

Post by Kloot »

Recycling this thread for another announcement.

There are two more (semi-breaking) changes in Spring 101.0 to be aware of:

1) units are no longer automatically zombified on death, this is now Lua territory
2) UnitDestroyed receives a new (7th) argument 'preEvent' and is called twice**

This addresses viewtopic.php?t=29936 and viewtopic.php?t=31226.

For a few extra details please review the changelog.

HH.

** if you use the base handlers, you can keep the old behavior (as far as Lua is concerned) by uncommenting https://github.com/spring/spring/blob/d ... .lua#L1281 and/or https://github.com/spring/spring/blob/d ... .lua#L1731
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: 101.0 Lua Breaking Changes

Post by smoth »

I am rather curious as to who is using a hard coded piecenumber
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: 101.0 Lua Breaking Changes

Post by hokomoko »

smoth wrote:I am rather curious as to who is using a hard coded piecenumber
You don't have to use a hardcoded pieceNumber.
Even you got it from local p = piece("pieceName") you had to pass (p-1) to the function earlier.
8611z
Posts: 169
Joined: 08 Jul 2015, 20:20

Re: 101.0 Lua Breaking Changes

Post by 8611z »

for example loops as posted earlier.
Silentwings wrote:http://imolarpg.dyndns.org/trac/balates ... e.lua#L117, http://imolarpg.dyndns.org/trac/balates ... e.lua#L131, etc.

Hopefully looking at those lines makes it clear what change will need to be applied.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: 101.0 Lua Breaking Changes

Post by smoth »

oh, I see
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: 101.0 Lua Breaking Changes

Post by hokomoko »

1st post updated.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: 101.0 Lua Breaking Changes

Post by Jools »

function widgetHandler:UnitDestroyed(unitID, unitDefID, unitTeam, _, _, _, preEvent)
-- uncomment to maintain backward compatibility
-- if (not preEvent) then return end
I have a question about this: wouldn't it be easier too just use:

Code: Select all

  -- if (preEvent) then return end
That would be compatible with all spring versions. What's the downside?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: 101.0 Lua Breaking Changes

Post by PicassoCT »

BeastyBoy wrote:Commit makin', commit commit makin'
Super lua, lua breakin'
Commit makin', commit commit makin'
Super lua, lua breakin'
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: 101.0 Lua Breaking Changes

Post by Kloot »

What's the downside?
Any code that assumes id's are still valid for some time after UnitDestroyed might break.
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: 101.0 Lua Breaking Changes

Post by hokomoko »

Kloot wrote:
What's the downside?
Any code that assumes id's are still valid for some time after UnitDestroyed might break.
That's not what he meant I think.

Changing the preEvent argument to postEvent (and flipping its value) will allow the same handler code to work on earlier engine versions as well.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: 101.0 Lua Breaking Changes

Post by Jools »

I meant both :)

If the game uses a handler it's easy to fix there, but if it doesn't, it means editing a bunch or widgets or gadgets. But maybe now just because of this it might be useful to use custom handler.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: 101.0 Lua Breaking Changes

Post by gajop »

Be sure to check the changelog for other minor breaking changes.
Post Reply

Return to “Engine”