Author Topic: Plant function ain't working...  (Read 4338 times)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Plant function ain't working...
« on: February 05, 2011, 04:30:35 AM »
I'm making my map, I use some the shorten asteroids function of mine, but when I am going to plant a flower it wont allow me because of:
Quote
attempt to call method 'Plant' (a string value)

Why won't it work, I checked the Lua scripting in Eufloria - reference and it says Plant(Structure tree) which says to me I should use the variable the tree is(or am I wrong??), usually used as s = a:AddDysonTree() or something...
« Last Edit: February 05, 2011, 04:53:13 AM by Aino »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Plant function ain't working...
« Reply #1 on: February 05, 2011, 10:26:38 AM »
Can you post the code you're using?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Plant function ain't working...
« Reply #2 on: February 05, 2011, 10:42:14 AM »
I think I figured it out, but here's the code:
Code: [Select]
function AddTree(roidnumber, treetype, treelevel)

if roidnumber == -1 then
roidnumber = roidnumb-1
end

if treetype == "dys" or treetype == "dyson" then
temptree = roid[roidnumber]:AddDysonTree()
elseif treetype == "def" or treetype == "defense" then
temptree = roid[roidnumber]:AddDefenseTree()
end
if treelevel > 0 and treelevel < 5 then
for treelevel = 1, treelevel do
temptree:LevelUp()
end
elseif treelevel == 5 then
for treelevel = 1, 4 do
temptree:LevelUp()
end
tempflower = temptree:AddFlower()
tempflower:GrowToMax()
tempflower:Pluck()
tempflower:Plant(temptree)
end

end

I was doing it to a defense tree, that may solve it?
So I might do something like this:
Code: [Select]
elseif treelevel == 5 then
for treelevel = 1, 4 do
temptree:LevelUp()
end
tempflower = temptree:AddFlower()
tempflower:GrowToMax()
tempflower:Pluck()
if treetype == "dys" or treetype == "dyson" then
tempflower:Plant(temptree)
end
end
??

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Plant function ain't working...
« Reply #3 on: February 05, 2011, 10:08:35 PM »
I ran into similar problems when building IAIv2, and had to ask Alex for help.  It's not obvious!


Code: [Select]
tree = nil
flower = nil

-- flower check !
tree = checkedroid:GetRandomDysonTree()

if tree ~= nil then
flower = tree:GetSuperSeedling()
end

if checkedroid.owner > 1 and flower ~= nil then
flower:Pluck()
end

flower = checkedroid:GetFlower(checkedroid.owner)

if checkedroid.owner > 1 and flower ~= nil then
flower:PlantOnRandomDysonTree()
end

"GetSuperSeedling" actually returns a flower.  :P

Also the "Plant" command is "Plant on random dyson tree"