Eufloria > Eufloria Classic Mods

【Need Help!】How to get a certain seedling?

<< < (2/3) > >>

sillytuna:
Ah I don't know anything about the Classic source code I'm afraid!

Breakord:

--- Quote from: Aino on January 31, 2013, 05:12:42 AM ---
--- Quote from: Pilchard123 on January 31, 2013, 02:44:28 AM ---I think you can, but I can't remember how...

--- End quote ---
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: ---GetAsteroid(ID):Seedlings(2)[Number]
--- End code ---
A way to scan an asteroid would be:

--- Code: ---seedlings = {}
for i = 0, GetAsteroid(ID):GetNumSeedlings()-1 do
seedlings.link = GetAsteroid(ID):Seedling(2)[i];
end
--- End code ---
Using this simple code we might be able to extend it:

--- Code: ---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
--- End code ---
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 :)

--- End quote ---

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:

--- Quote from: Breakord on January 31, 2013, 11:32:07 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.

--- End quote ---

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:

--- Quote from: Aino on February 01, 2013, 12:50:24 AM ---
--- Quote from: Breakord on January 31, 2013, 11:32:07 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.

--- End quote ---
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?

--- End quote ---
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:

--- Quote from: Breakord on February 01, 2013, 09:46: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)?

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version