Euflorium
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
September 10, 2010, 12:44:16 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
6178
Posts in
740
Topics by
1205
Members
Latest Member:
andermoo
Euflorium
Eufloria
User levels and modifications
Script examples
« previous
next »
Pages:
[
1
]
Author
Topic: Script examples (Read 2144 times)
Alex
Administrator
Old Oak
Posts: 878
Script examples
«
on:
July 29, 2009, 10:43:39 PM »
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()
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()
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
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)
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.
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
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
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
etc
«
Last Edit: March 24, 2010, 03:01:46 PM by Alex
»
Logged
annikk.exe
Achievers
Old Oak
Posts: 535
Re: Script examples
«
Reply #1 on:
January 20, 2010, 02:41:51 PM »
So did you just forget to add the code to your post or something? :>
Logged
Rudolf
Administrator
Arboreal Being
Posts: 414
Re: Script examples
«
Reply #2 on:
January 23, 2010, 10:33:54 AM »
No it is all there under the spoiler buttons.
Does this now work for you?
Logged
annikk.exe
Achievers
Old Oak
Posts: 535
Re: Script examples
«
Reply #3 on:
January 23, 2010, 04:21:05 PM »
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.
Logged
Rudolf
Administrator
Arboreal Being
Posts: 414
Re: Script examples
«
Reply #4 on:
January 23, 2010, 04:31:31 PM »
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..
Logged
annikk.exe
Achievers
Old Oak
Posts: 535
Re: Script examples
«
Reply #5 on:
January 23, 2010, 04:46:52 PM »
Working now ^_^
Logged
Harsha
Seedling
Posts: 27
Re: Script examples
«
Reply #6 on:
March 22, 2010, 01:11:05 PM »
Hey non members will not be able to see the spoiler buttons at all.. Is that okay?
Logged
Eufloria Admin
Administrator
Seedling
Posts: 30
Re: Script examples
«
Reply #7 on:
March 22, 2010, 01:54:57 PM »
Fixed.
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Eufloria
-----------------------------
=> The OT
=> Eufloria discussion
=> User levels and modifications
=> Support / troubleshooting / bug reports
Loading...