Author Topic: 【Need Help!】How to get a certain seedling?  (Read 20143 times)

Breakord

  • Sapling
  • **
  • Thank You
  • -Given: 14
  • -Receive: 7
  • Posts: 57
  • Eufloria: Yes
【Need Help!】How to get a certain seedling?
« on: January 30, 2013, 03:59:34 PM »
How to get a certain seedling(as an object or something),and its attributes(posx, posy, en, st, sp)?
I've been struglling for several days and found nothing...

Thanks for any help!

sillytuna

  • Eufloria lacky
  • Administrator
  • Arboreal Being
  • *****
  • Thank You
  • -Given: 58
  • -Receive: 71
  • Posts: 441
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #1 on: January 30, 2013, 04:33:04 PM »
This classic or HD? Can't on HD, don't know if you can on classic...

Breakord

  • Sapling
  • **
  • Thank You
  • -Given: 14
  • -Receive: 7
  • Posts: 57
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #2 on: January 30, 2013, 05:20:32 PM »
sorry..classic 2.07 for PC

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #3 on: January 31, 2013, 02:44:28 AM »
I think you can, but I can't remember how...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Guide to simple seedling tracking
« Reply #4 on: January 31, 2013, 05:12:42 AM »
I think you can, but I can't remember how...

You can, it has been done. I just don't remember where the topic is.
We'll just need to wait until either Alex comes along and wants to answer, or sillytuna finds the energy to open up the source and find the piece of codes.

EDIT:

Here: http://www.euflorium.com/index.php?topic=1395.msg10045#msg10045
Mihhaelo actually managed to use the system, but I think you'll have to experiement around for yourself, 'cause I don't think many others know how to fiddle around with the seedlings.

Good Luck :)

EDIT 2:

I'd guess this piece is responsible for finding the seedling:
Code: [Select]
GetAsteroid(ID):Seedlings(2)[Number]
A way to scan an asteroid would be:
Code: [Select]
seedlings = {}
for i = 0, GetAsteroid(ID):GetNumSeedlings()-1 do
seedlings.link = GetAsteroid(ID):Seedling(2)[i];
end

Using this simple code we might be able to extend it:

Code: [Select]
function LevelSetup()

--Adding seedlings and doing globals and stuff...

--This array is the seedling array, each individual seedling is stored on this from 1 to 4000.
Seedlings = {};
NumberofAsteroids = [INSERT INT HERE, AND REMOVE THE BRACKETS];

end

function LevelLogic()

--A tick is a displayed frame, because of the VSync it's capped to 60 on most frames.

--Could use gameTime for this, but I felt like using ticks, probably a nice idea to use ticks to prevent heavy lags. Less ticks means longer time before it is executed.
gameTime = GetGameTime();
lastUpdate = 0;

while GameRunning() do

--Check that the game is not paused.
if (gameTime < GetGameTime()) then
gameTime = GetGameTime();
lastUpdate = lastUpdate + 1;

--Check if 60 ticks have passed
if (lastUpdate > 60) then
lastUpdate = 0;

--If 60 ticks have passed run a for loop through all the asteroids and do as following:
for roid = 0, NumberofAsteroids do
--Run another for loop through all the seedlings on the asteroid.
for i = 0, GetAsteroid(roid):GetNumSeedlings()-1 do
--Register the seedling, most important part
local Seed = GetAsteroid(roid):Seedling(2)[i];

--Set up while loop vars.
local count = 0;
local valid = true;

--Execute a while loop, becaus ewe got no idea how many seedlings are in the list currently. Could have kept a track, but I want to use some new methods than boring for loops :)
while Seedlings[count] ~= nil and valid do

--Here we check the seedling we scanned
if (Seedlings[count] == Seed) then
--If it's already on the list, set valid to false.
valid = false;
--This will stop the while loop and make it junp to the next seedling, or asteroid.
end

--Add another to the var Count, making it compare the scanned seedling with a new one.
count = count + 1;

--Notice how the while loop has no coroutine, this is because it's got a fair end. It won't take up much time and freeze the game because the game has no posibility to do other things (which is what an "endless" while loop normally does).
end

--Check if valid is still true
if valid then
--Still valid, which means this seedling doesn't exist on the list
Seedlings.link = Seed;
end
end

end
end
end
coroutine.yield();
end
end

For the first time, I introduce you to my very first comments! I hope they help you use this :)

This code will check each second(if the game keeps up) for any new seedling across the board. If any new seedling is found it will be added. I think you'll need to find a way to remove them yourself, and then this code might not work anymore. I haven't tested this code either, but it will be a good framework for your project I hope :)
« Last Edit: January 31, 2013, 05:52:19 AM by Aino »

sillytuna

  • Eufloria lacky
  • Administrator
  • Arboreal Being
  • *****
  • Thank You
  • -Given: 58
  • -Receive: 71
  • Posts: 441
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #5 on: January 31, 2013, 08:05:14 AM »
Ah I don't know anything about the Classic source code I'm afraid!

Breakord

  • Sapling
  • **
  • Thank You
  • -Given: 14
  • -Receive: 7
  • Posts: 57
  • Eufloria: Yes
Re: Guide to simple seedling tracking
« Reply #6 on: January 31, 2013, 11:32:07 AM »
I think you can, but I can't remember how...
You can, it has been done. I just don't remember where the topic is.
We'll just need to wait until either Alex comes along and wants to answer, or sillytuna finds the energy to open up the source and find the piece of codes.
EDIT:
Here: http://www.euflorium.com/index.php?topic=1395.msg10045#msg10045
Mihhaelo actually managed to use the system, but I think you'll have to experiement around for yourself, 'cause I don't think many others know how to fiddle around with the seedlings.
Good Luck :)
EDIT 2:
I'd guess this piece is responsible for finding the seedling:
Code: [Select]
GetAsteroid(ID):Seedlings(2)[Number]A way to scan an asteroid would be:
Code: [Select]
seedlings = {}
for i = 0, GetAsteroid(ID):GetNumSeedlings()-1 do
seedlings.link = GetAsteroid(ID):Seedling(2)[i];
end
Using this simple code we might be able to extend it:
Code: [Select]
function LevelSetup()

--Adding seedlings and doing globals and stuff...

--This array is the seedling array, each individual seedling is stored on this from 1 to 4000.
Seedlings = {};
NumberofAsteroids = [INSERT INT HERE, AND REMOVE THE BRACKETS];

end
function LevelLogic()

--A tick is a displayed frame, because of the VSync it's capped to 60 on most frames.

--Could use gameTime for this, but I felt like using ticks, probably a nice idea to use ticks to prevent heavy lags. Less ticks means longer time before it is executed.
gameTime = GetGameTime();
lastUpdate = 0;

while GameRunning() do

--Check that the game is not paused.
if (gameTime < GetGameTime()) then
gameTime = GetGameTime();
lastUpdate = lastUpdate + 1;

--Check if 60 ticks have passed
if (lastUpdate > 60) then
lastUpdate = 0;

--If 60 ticks have passed run a for loop through all the asteroids and do as following:
for roid = 0, NumberofAsteroids do
--Run another for loop through all the seedlings on the asteroid.
for i = 0, GetAsteroid(roid):GetNumSeedlings()-1 do
--Register the seedling, most important part
local Seed = GetAsteroid(roid):Seedling(2)[i];

--Set up while loop vars.
local count = 0;
local valid = true;

--Execute a while loop, becaus ewe got no idea how many seedlings are in the list currently. Could have kept a track, but I want to use some new methods than boring for loops :)
while Seedlings[count] ~= nil and valid do

--Here we check the seedling we scanned
if (Seedlings[count] == Seed) then
--If it's already on the list, set valid to false.
valid = false;
--This will stop the while loop and make it junp to the next seedling, or asteroid.
end

--Add another to the var Count, making it compare the scanned seedling with a new one.
count = count + 1;

--Notice how the while loop has no coroutine, this is because it's got a fair end. It won't take up much time and freeze the game because the game has no posibility to do other things (which is what an "endless" while loop normally does).
end

--Check if valid is still true
if valid then
--Still valid, which means this seedling doesn't exist on the list
Seedlings.link = Seed;
end
end

end
end
end
coroutine.yield();
end
end
For the first time, I introduce you to my very first comments! I hope they help you use this :)
This code will check each second(if the game keeps up) for any new seedling across the board. If any new seedling is found it will be added. I think you'll need to find a way to remove them yourself, and then this code might not work anymore. I haven't tested this code either, but it will be a good framework for your project I hope :)

God! Cannot express my gratitude to you too much!
Thanks a lot!
By the way, you are really a know-all!
I think these guides are pretty enough, at the very least, I have a diretion to try.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #7 on: February 01, 2013, 12:50:24 AM »
God! Cannot express my gratitude to you too much!
Thanks a lot!
By the way, you are really a know-all!
I think these guides are pretty enough, at the very least, I have a diretion to try.

Always fun to help! :)

I'm not so sure about the know-it-all thing though, I still have some things I have no clue about in coding and other things. It's just about practice, and as far as I can remember I've been practicing coding for several years.

I wonder though, does the code I provided work?

Breakord

  • Sapling
  • **
  • Thank You
  • -Given: 14
  • -Receive: 7
  • Posts: 57
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #8 on: February 01, 2013, 09:46:37 AM »
God! Cannot express my gratitude to you too much!
Thanks a lot!
By the way, you are really a know-all!
I think these guides are pretty enough, at the very least, I have a diretion to try.
Always fun to help! :)
I'm not so sure about the know-it-all thing though, I still have some things I have no clue about in coding and other things. It's just about practice, and as far as I can remember I've been practicing coding for several years.
I wonder though, does the code I provided work?
Ah, yes,  it works well.
Actually it works like this:
GetAsteroid(int id):Seedlings(int Fation)
This returns a group of seedlings  belong to the faction you passed in(must be on the asteroid you passed in).


To get a certain one, that is:
GetAsteroid(int id):Seedlings(int Faction)[int index]

for example,
there are several seedlings belongs to faction 2 on asteroid 0,
now let's get a seedling and some of its attributes:
--------------------
s=GetAsteroid(0):Seedlings(2)[0]
print(s.Attribs.Energy)
print(s.Postion.X)
print(s.Damage)
print(s.Owner)
print(s.CurrentEnergy)
--------------
Some attributes can be set, like Attribs(though somehow the seedling with Attribs that you passed in still "looks" like the same as its brothers) .
Others like Position, CurrentEnergy, Damage can not(I think..).

So there are new questions..
Is there any way to set attributes like Position, CurrentEnergy or Damage?
Or can I simulate the progress that a tree or seeding being attaked (to die)?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #9 on: February 02, 2013, 02:59:37 AM »
So there are new questions..
Is there any way to set attributes like Position, CurrentEnergy or Damage?
Or can I simulate the progress that a tree or seeding being attaked (to die)?

You can't use Position.X = x or Position.Y = y? That would be weird, 'cause all entities in the game share all the stats and it should be possible to change them regardless of the entity type.

Breakord

  • Sapling
  • **
  • Thank You
  • -Given: 14
  • -Receive: 7
  • Posts: 57
  • Eufloria: Yes
Re: 【Need Help!】How to get a certain seedling?
« Reply #10 on: February 03, 2013, 09:59:33 PM »
You can't use Position.X = x or Position.Y = y? That would be weird, 'cause all entities in the game share all the stats and it should be possible to change them regardless of the entity type.
Not only Position, some variables seem to be read-only...
No errors occur when you simply pass values  to them through equations,but actually  their values dont change and nothing happens.