Page 1 of 1

GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 10:40
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.

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 10:41
by Tribulex
or teach me how in the world to get the overly complicated unit_morph script working and what version to use...

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 10:56
by Google_Frog
Did you use the morph_defs config file?

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 11:14
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....

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 11:34
by Neddie
You might try the 1944 one, but I think there is a dependency on another lua gadget...

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 18:08
by FLOZi
1944 one is the CA one with relatively minor changes to suit our needs.

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 20:29
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

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

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 20:52
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).

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 22:40
by Tribulex
Didn't help...

WHAT IS "snext" ??????????????

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 22:47
by KDR_11k
Probably the iterator function for spairs.

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 16 Oct 2009, 22:55
by Tribulex
Why is my morphdefs null?

So frustrating.... :evil: :evil: :evil: :evil: :evil: :evil: :evil:

Re: GADGET REQUEST: Unit morphing/replacement

Posted: 17 Oct 2009, 11:38
by Forboding Angel
db, use this one. It's simple, straight forward, and it just so happens to work.
(edit the config of course)