GADGET REQUEST: Unit morphing/replacement

GADGET REQUEST: Unit morphing/replacement

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

Moderator: Moderators

Post Reply
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

Can someone post a simple replacement script? This is all i need, all modifications like cost and paralyzing the unit afterward i can implement myself.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

or teach me how in the world to get the overly complicated unit_morph script working and what version to use...
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: GADGET REQUEST: Unit morphing/replacement

Post by Google_Frog »

Did you use the morph_defs config file?
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

Yes. All i got were a bunch of errors. I debugged it, then the gadget did nothing.

I tried xta's version and ca's version, both of which work in their respective games....
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Re: GADGET REQUEST: Unit morphing/replacement

Post by Neddie »

You might try the 1944 one, but I think there is a dependency on another lua gadget...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: GADGET REQUEST: Unit morphing/replacement

Post by FLOZi »

1944 one is the CA one with relatively minor changes to suit our needs.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

Im still getting this error spammed every frame:

Code: Select all

[    325] LuaRules::RunCallIn: error = 2, Update, [string "LuaRules/Gadgets/unit_morph.lua"]:1044: bad argument #1 to 'snext' (table expected, got nil)
here is my luarules/Config/morph_defs.lua

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local devolution = false


local morphDefs = {
    ant = {
		[1] = {into = 'mantis', time = 10,},
	},
    mantis = {
		[1] = {into = 'ant', time = 10,},
	},
}

--
-- Here's an example of why active configuration
-- scripts are better then static TDF files...
--

--
-- devolution, babe  (useful for testing)
--
if (devolution) then
  local devoDefs = {}
  for src,data in pairs(morphDefs) do
    devoDefs[data.into] = { into = src, time = 10, metal = 1, energy = 1 }
  end
  for src,data in pairs(devoDefs) do
    morphDefs[src] = data
  end
end


return morphDefs

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: GADGET REQUEST: Unit morphing/replacement

Post by yuritch »

Try this:

Code: Select all

local devolution = false

local morphDefs = {
    ant = {into = 'mantis', time = 10,},
    mantis = {into = 'ant', time = 10,},
}

--
-- Here's an example of why active configuration
-- scripts are better then static TDF files...
--

--
-- devolution, babe  (useful for testing)
--
if (devolution) then
  local devoDefs = {}
  for src,data in pairs(morphDefs) do
    devoDefs[data.into] = { into = src, time = 10, metal = 1, energy = 1 }
  end
  for src,data in pairs(devoDefs) do
    morphDefs[src] = data
  end
end

return morphDefs
There's only 1 morph destination per unit, you do not need to set it as a table of tables (ie the part with [1] was not needed and probably caused those errors).
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

Didn't help...

WHAT IS "snext" ??????????????
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: GADGET REQUEST: Unit morphing/replacement

Post by KDR_11k »

Probably the iterator function for spairs.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: GADGET REQUEST: Unit morphing/replacement

Post by Tribulex »

Why is my morphdefs null?

So frustrating.... :evil: :evil: :evil: :evil: :evil: :evil: :evil:
Attachments
unit_morph.lua
(35.31 KiB) Downloaded 116 times
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: GADGET REQUEST: Unit morphing/replacement

Post by Forboding Angel »

db, use this one. It's simple, straight forward, and it just so happens to work.
(edit the config of course)
Attachments
LuaRules.zip
(9.37 KiB) Downloaded 26 times
Post Reply

Return to “Lua Scripts”