Eufloria > Eufloria Classic Mods

Script examples

(1/3) > >>

Alex:
Setup script examples

Adding a tree with a starting level of 2 (need to level up once to plant the root)
(click to show/hide)
--- Code: --- a = AddAsteroidWithAttribs(4600,-4600, 0.3,0.6,0.6)
a.Owner = 1
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()
--- End code ---

Add a tree with a flower or mine
(click to show/hide)
--- Code: --- a = AddAsteroidWithAttribs(4600,-4600, 0.3,0.6,0.6)
a.Owner = 1
-- add a flower on a dyson tree
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()
flower = s:AddFlower()
flower:GrowToMax()
-- add a mine on a defense tree
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()
s:LevelUp()
flower = s:AddFlower()
flower:GrowToMax()

--- End code ---

Add a superseedling tree
(click to show/hide)
--- Code: --- a = AddAsteroidWithAttribs(4600,-4600, 0.3,0.6,0.6)
a.Owner = 1
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()
s.Enhanced = true

--- End code ---

Have an asteroid with superseedlings on it at the start
(click to show/hide)
--- Code: --- a = AddAsteroidWithAttribs(4600,-4600, 0.3,0.6,0.6)
a.Owner = 1
a:AddSuperSeedlings(50)

--- End code ---



Level logic examples


Adding a scripted section of a fixed duration:
(click to show/hide)
--- Code: --- timeNow = GetGameTime()

while GetGameTime() < timeNow + 10 do

coroutine.yield()

end

-- This script runs for ten seconds.

--- End code ---
Of course, you can also check the time any other point e.g.
(click to show/hide)
--- Code: ---winGame = false
timedSeedlingRelease = GetGameTime()
asteroid = GetAsteroid(1) -- assume we know for sure asteroid 1 exists

while not wingame do

if GetGameTime() > timedSeedlingRelease + 5 then
asteroid:AddSeedlings(1)
timedSeedlingRelease = GetGameTime()
end

coroutine.yield()

end

-- releases a seedling every five seconds to asteroid 1

--- End code ---


Drawing examples

Here's a code block that shows some stuff being drawn in the level draw routine, including drawing stuff at a fixed size on screen, checking to see if something is on the screen and levels of detail:
(click to show/hide)
--- Code: ---
function LevelDraw()

DrawLine(0,0,1000,1200,0,0,1,1,0,1,0,1,3)

l = 0
while l < 2*math.pi do

DrawTexLine(2, 0,0,math.sin(l)*100,math.cos(l)*100, 1,0.5,0,1,0.7,0.1,0,1, 1)

l = l + math.pi/5
end

if IsOnScreen(0,0,500) then
a = GetLODAlpha(2)
if a > 0 then

DrawSprite(5, -500,0, 0.7,0.1,0,a*0.98, 100)

end
a = GetLODAlpha(1)
if a > 0 then

DrawSprite(5, -500,0, 0.1,0.7,0,a*0.98, 500)

end
a = GetLODAlpha(0)
if a > 0 then

DrawSprite(5, -500,0, 0.1,0.0,0.7,a*0.98, 50/GetCameraScale())

end
end
end
--- End code ---

callback examples

oneshot asteroid taken script example
(click to show/hide)
--- Code: ---enemyActivated = false

--Activates the enemy if still dormant, once th eplayer gets close enough.
function OnAsteroidTaken(id, owner)
if (id == 10 or id == 11) and enemyActivated then
GetAsteroid(7): SetGraceTime(1)
GetAsteroid(8): SetGraceTime(1)
GetAsteroid(9): SetGraceTime(1)
GetAsteroid(12): SetGraceTime(1)
enemyActivated = true
end
end
--- End code ---

etc

annikk.exe:
So did you just forget to add the code to your post or something?  :>

Rudolf:
No it is all there under the spoiler buttons.
Does this now work for you?

annikk.exe:
Not seeing any spoiler buttons...
I don't think this is merely a graphical bug because when I quote the OP, there is still no code in there.

I administer an SMF-based forum for the band Angelspit.  If you have access to the admin panel, check the member rank permissions - maybe I am erroneously not allowed to see spoiler'd stuff or something? :>

I'll go update my browser and flash and java and so on in the mean time, in case it's that.  Win XP, Firefox, incidentally.

Rudolf:
Hmm I think you may have been right...
Which would explain why so few user levels have been made.... :-(

Try again.. see if that is better..

Navigation

[0] Message Index

[#] Next page

Go to full version