Author Topic: Level design/ Code questions from a beginner  (Read 79721 times)

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #100 on: July 16, 2010, 05:12:30 AM »
Wooooot that working :o

I think anything I had read but I suspect that I'm reading it wrong
That you can add leaf's on the asteroid, but I think I've had an exchange with flower
but flower and leafs are not the same xD
But is there a opportunity that you only can add leafs on the astgeroids?

Adding Edit xD ( or some thing ) xD :
oh yes, before I forget there is a possibility as a dead asteroids him back to life?
« Last Edit: July 16, 2010, 05:16:27 AM by w4tc »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #101 on: July 16, 2010, 04:19:53 PM »
Leaf?  I'm not aware of any leaves...

If you kill an asteroid with Die() then I think it's not possible to ressurect it.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #102 on: July 16, 2010, 05:39:06 PM »
Perhaps you mean the grass, w4tc? In which case, no, that needs to come with a tree.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #103 on: July 16, 2010, 06:04:56 PM »
Glad to hear you got it sorted, by the way :>  Always exciting when you get a new mechanic working for the first time!

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #104 on: July 16, 2010, 11:15:37 PM »
Perhaps you mean the grass, w4tc? In which case, no, that needs to come with a tree.

Hmm, yes, thit will be cool xD if there also exists a code :D
it is for my level map... little spoilers it about sickness....


Glad to hear you got it sorted, by the way :>  Always exciting when you get a new mechanic working for the first time!
did that about me or Alex? and what do you mean with that xD?


But the next question
If i discover a new asteroid, there must be appear a textbox

is that like this example?
Code: [Select]
function OnAsteroidRevealed(id, owner)
       if id == 1 then MessageBox("Asteroid "..id.." was discovered by faction "..owner..".") end
end

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #105 on: July 16, 2010, 11:45:23 PM »
YEp.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #106 on: July 17, 2010, 12:25:20 AM »
Glad to hear you got it sorted, by the way :>  Always exciting when you get a new mechanic working for the first time!
did that about me or Alex? and what do you mean with that xD?

That was in response to you.  :>

"Glad to hear you got it sorted"  ->  I am glad that you managed to get it working.
"Always exciting when you get a new mechanic working for the first time!" -> Parts of a level that "do something" are called "mechanics".  The word "mechanic" is used in the same way as the likes of "quantum mechanics".  I am saying that it is exciting when you get a new bit to work properly.  :>


w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #107 on: July 17, 2010, 05:00:28 AM »
Whoee ;D Thx annike

Sniped50

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 97
Re: Level design/ Code questions from a beginner
« Reply #108 on: July 18, 2010, 12:13:58 AM »
Hey guys...
I'm currently working on a small, highly experimental level which uses gravity in nearly all of it's asteroids. But I'm having a few problems with the AI. I'm trying to keep it from attempting to send seedlings to the central asteroid (where all the seedlings instantly die), but it's refusing to do so. At the moment I'm stumped, and this should be a very simple procedure. Plus I'd like to make it a little more aggressive without having to resort to something as complex as annikk's Infected AI. A little help please?

Mihhaelo

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 67
Re: Level design/ Code questions from a beginner
« Reply #109 on: July 18, 2010, 01:23:11 AM »
Quote
Hey guys...
I'm currently working on a small, highly experimental level which uses gravity in nearly all of it's asteroids. But I'm having a few problems with the AI. I'm trying to keep it from attempting to send seedlings to the central asteroid (where all the seedlings instantly die), but it's refusing to do so. At the moment I'm stumped, and this should be a very simple procedure. Plus I'd like to make it a little more aggressive without having to resort to something as complex as annikk's Infected AI. A little help please?

Put the following code at the start of your map. It will make the AI more aggressive and expansive.

(click to show/hide)

I don't think it's possible to prevent the AI from going to an asteroid if they can physically reach the asteroid, you'll probably have to think of a workaround. You could code it, so AI seedlings lost to the center are respawned elsewhere. You can also manually tell the AI to move seedlings away, once an asteroid gets within a certain range.

Sniped50

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 97
Re: Level design/ Code questions from a beginner
« Reply #110 on: July 18, 2010, 07:31:33 AM »
Hmm... Thanks Mihhaelo. That code definitely works. It will need a bit of tweaking so the AI doesn't use up all it's seedlings and leave it's asteroids vulnerable to attack, but it's an improvement from the extremely lazy empire (read: can't even be bothered to get seedlings to other roids before I've conquered half the system) I had before.

As for the other issue...
Quote
I don't think it's possible to prevent the AI from going to an asteroid if they can physically reach the asteroid, you'll probably have to think of a workaround.

A pity. I probably might make it so that any seedlings sent there are respawned on the home planet, but that just seems like a really ugly way to work around it, and if I told the AI to move away if the central asteroid was within their send distance, then the entire inner orbit would remain utterly deserted, save for my empire. That doesn't particularly help fix the difficulty issues I had prior to upgrading my globals. :P

Plus, I also worked out that Eufloria doesn't like killing lots of seedlings at once, and will crash if this is the case. Basically, send too many seedlings to the central roid at once, they all die, and Eufloria dies. Presumably from a broken heart...  :'(

I upgraded to v2.05 like, literally hours ago. Maybe that has something to do with it, because I never saw Eufloria crash like that on this map...

Mihhaelo

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 67
Re: Level design/ Code questions from a beginner
« Reply #111 on: July 18, 2010, 09:10:12 AM »
Quote
Plus, I also worked out that Eufloria doesn't like killing lots of seedlings at once, and will crash if this is the case. Basically, send too many seedlings to the central roid at once, they all die, and Eufloria dies.

I once had an issue with deleting seedlings as well. My code basically said "Are there 10 seedlings on this planet? If yes delete them". I found by adding a 1 second delay between scans fixed the crashes.

I can only assume that deleting seedlings is not instant and there is a slight delay when the seedlings are told to die, and that on occasion they will still be around when your code takes another pass. So your code ends up trying to delete them when they are not there.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #112 on: July 18, 2010, 08:39:48 PM »

I was just asked about these days about this code:

Code: [Select]
function OnAsteroidRevealed(id, owner)
       if id == 1 then MessageBox("Asteroid "..id.." was discovered by faction "..owner..".") end
end

but that's not really mean thing I want
it is similar, if you explore every aseroid than any other text on it, but with this, the text is always the same ones
but I do not see how I can change than  ???

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #113 on: July 18, 2010, 08:42:25 PM »
If you mean that the box tells you which asteroid was discovered, and by who, then use

Code: [Select]
function OnAsteroidRevealed(id, owner)
     MessageBox("Asteroid "..id.." was discovered by faction "..owner..".")
end

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #114 on: July 19, 2010, 02:57:44 AM »
no, that not what i mean
what i mean is you if you discovered asteroid 1 then tells the box ( example ) : "Oohh cool a fresh asteroid but something is gone wrong here"
and you discover a new asteroid 3 " now we see there is a full FlowerDefense but why? "

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #115 on: July 19, 2010, 03:56:57 AM »
something I do not understand

i have this code
that the Owner 1 and 2 there are not in the right position ???

(click to show/hide)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #116 on: July 19, 2010, 06:51:34 AM »
no, that not what i mean
what i mean is you if you discovered asteroid 1 then tells the box ( example ) : "Oohh cool a fresh asteroid but something is gone wrong here"
and you discover a new asteroid 3 " now we see there is a full FlowerDefense but why? "



Code: [Select]
function OnAsteroidRevealed(id, owner)

if id == 3 then
MessageBox("Asteroid "..id.." was discovered, and belongs to empire "..owner..".")
elseif id == 4 then
MessageBox("Asteroid "..id.." was discovered, and this asteroid belongs to empire "..owner..".")
elseif id == 5 then
MessageBox("Asteroid "..id.." was discovered, and this super-fluffy-happy asteroid belongs to lucky empire number "..owner..".")
else
MessageBox("Asteroid "..id.." was discovered, and this miscellaneous asteroid belongs to empire "..owner..".")
end

end

Something like this, perhaps?
Remember, in an OnAsteroidRevealed function, owner is the person who owns the asteroid that was discovered, NOT the person who discovered it.
[edit - I might be wrong about that...]
« Last Edit: July 19, 2010, 06:57:43 AM by annikk.exe »

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #117 on: July 19, 2010, 07:32:17 AM »
something I do not understand

i have this code
that the Owner 1 and 2 there are not in the right position ???

(click to show/hide)

I can not understand well what is wrong
but if I level game, then are the players are not in the right place ???


PS : Thx alote annikk :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #118 on: July 19, 2010, 04:08:31 PM »
Remember the grid isn't how you would naturally imagine it, it looks like this:




Check your coords against this map and you should be able to see where everything will be.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #119 on: July 20, 2010, 01:50:42 AM »
sorry anikk but i dont see noting wrong in the coords, that it has nothing to do with the asteroids?
but it is the players place..
so i tried and i add now Moveable = False ect
now it player 1 that oke, but not player 2 ....

img 1 : it wath i see on the game level
img 2 : is my drawing, how the asteroids should be standing

(click to show/hide)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #120 on: July 20, 2010, 03:45:58 AM »
OK, you need to set asteroid 0 owner to 0. Then you have it right - the only problem is the camera, which is broken at the moment and I have just fixed it so that will come in the next update. In the meantime change your first two asteroids around.

(click to show/hide)

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #121 on: July 20, 2010, 06:35:56 AM »
help me plz, I am now at almost appropriate to speak to give  :'( :'(
i have change my test level for to make it easy

so i make this :  
(click to show/hide)

and he always gives an error code but I want a coord or More Than 10 000 or 5000..
its come from a another test and that works, but what I do is just change the coordinates and and have alwhy a rerror???

Edit : or must i also set asteroid 0 owner to 0?
« Last Edit: July 20, 2010, 06:47:11 AM by w4tc »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #122 on: July 20, 2010, 06:49:35 AM »
At the moment that crashes because the game is trying to find a path between those asteroids and it can't because they're so far apart and there are no other asteroids to make a path between them. Add some more asteroids - or you can start the asteroids closer to gether and move them apart in the first part of the level logic.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #123 on: July 20, 2010, 04:14:48 PM »
Add the following Globals:


Code: [Select]
Globals.G.MaxAsteroidNeighbourDist=80000
Globals.Asteroids.MinSendDistance=80000
Globals.Asteroids.MaxSendDistance=80000


Then, if you set Send Distances for your asteroids, do it in function LevelLogic like this:

GetAsteroid(0).SendDistance = type a number
GetAsteroid(1).SendDistance = type a number
GetAsteroid(2).SendDistance = type a number
GetAsteroid(3).SendDistance = type a number
GetAsteroid(4).SendDistance = type a number



DO NOT set these send distances in function LevelSetup.  Do it in function LevelLogic.


This should fix your issue.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #124 on: July 21, 2010, 09:27:22 PM »
thx annikk
but in the past that was not?
strange

now I do a calculation for set point of Core Health
the volume is equal to the Core Health
but it is told that I have an error on the line 31 but it is blank
only on line 32 is this: "getasteroid (0): = Radius SetRadius"

edit on the post i have see that i forgot to put the "()' from the CoreHealth
so now it haves a error on the line 32
a unexpected symbol or something, but i dont see it what it is

(click to show/hide)
« Last Edit: July 21, 2010, 09:32:06 PM by w4tc »

Eufloria Admin

  • Global Moderator
  • Seedling
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
Re: Level design/ Code questions from a beginner
« Reply #125 on: July 21, 2010, 09:38:10 PM »
Code: [Select]
a.Moveable = false
end

getasteroid(0):SetRadius() = Straal

There's your problem.
You tried to reference asteroid ID 0, but you did it OUTSIDE the function levelsetup.

You need to move the command to either function LevelSetup or function LevelLogic.  You can't have it hanging in between them.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #126 on: July 21, 2010, 10:08:24 PM »
so i have put it in the LevelLogic
and change
Code: [Select]
getasteroid(0):SetRadius()= Straal to 
Code: [Select]
getasteroid(0):SetRadius(): Straalnow i get a new error :"Resours/maps/nieuw.lua:36: function arguments expected near 'if' "

Code: [Select]
function LevelLogic()
getasteroid(0):SetRadius(): Straal

if Straal > 200 == then
V = ( 4 * 3 ) * 3,14159265 * ( straal * straal * straal )
V = GetAsteroid(0):SetCoreHealth()
end

end

Eufloria Admin

  • Global Moderator
  • Seedling
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
Re: Level design/ Code questions from a beginner
« Reply #127 on: July 21, 2010, 10:13:36 PM »
Uh, yea... your syntax is wrong, too.

Code: [Select]
getasteroid(0):SetRadius() = Straal
Should be:

Code: [Select]
GetAsteroid(0):SetRadius(Straal)

Eufloria Admin

  • Global Moderator
  • Seedling
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
Re: Level design/ Code questions from a beginner
« Reply #128 on: July 21, 2010, 10:19:30 PM »
Unless you were trying to read the radius and record it into the variable Straal, which, actually, is what it looks like you were trying to do.


In that case, you would do it this way.


Find this code:
Code: [Select]
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(-2000,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 1
a:SetRadius(250)
a.SendDistance = 2500
a:AddSeedlings(90)
a.Moveable = false


Replace with:
Code: [Select]
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(-2000,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 1
Straal = 250
a:SetRadius(Straal)
a.SendDistance = 2500
a:AddSeedlings(90)
a.Moveable = false





Then do this:


Find code:
Code: [Select]
end

getasteroid(0):SetRadius() = Straal

function LevelLogic()


if Straal > 200 == than
V = ( 4 * 3 ) * 3,14159265 * ( straal * straal * straal )
V = GetAsteroid(0):SetCoreHealth()
end

end



Replace with:
Code: [Select]
end

function LevelLogic()


if Straal > 200 == then
V = ( 4 * 3 ) * 3.14159265 * ( Straal * Straal * Straal )
GetAsteroid(0).CoreHealth(V)
end

end


Note that in this level as it is right now, your IF statement will always return true.

Eufloria Admin

  • Global Moderator
  • Seedling
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
Re: Level design/ Code questions from a beginner
« Reply #129 on: July 21, 2010, 10:23:27 PM »
Also, because it always returns True, it is going to try to set Asteroid 0's core health to 589,048,621

Not quite sure where you're going with this.. :>  What are you hoping to create?

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #130 on: July 21, 2010, 10:45:08 PM »
Also, because it always returns True, it is going to try to set Asteroid 0's core health to 589,048,621

Not quite sure where you're going with this.. :>  What are you hoping to create?

I trying want to determine/ setting Core Health whit calculation of the volume of it and later whit the Perimeter
and combine so that the "correct value" following the size and volume

Code: [Select]
core health to 589,048,621whooeeeeps xD i must 4/3 xD


it have now a error of unexpected symbol near 'then' "
on the line of
Code: [Select]
if Straal > 200 == then false
Code: [Select]
function LevelLogic()


if Straal > 200 == then false
V = ( 4 / 3 ) * 3.14159265 * ( Straal * Straal * Straal )
GetAsteroid(0).CoreHealth(V)
end

end

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #131 on: July 21, 2010, 11:40:07 PM »
What is that "false" doing after the "then"?

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #132 on: July 21, 2010, 11:44:22 PM »
What is that "false" doing after the "then"?

oeps sorry, its fixed
but it gaves the same error

(click to show/hide)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #133 on: July 22, 2010, 02:20:31 AM »
CoreHealth is a field, so you need to assign values directly to it rather than calling it like a function - for this you use the dot and equals:

GetAsteroid(0).CoreHealth = V

If it were a function, you would have to use the colon and brackets. Here is an example:

GetAsteroid(0):GetFlower(1) -- returns a Flower belonging to faction 1 (the player) or nil if no such flower exists.

Look up whether members are fields or functions in the reference.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #134 on: July 22, 2010, 03:51:36 AM »
i tried but he the same error on the line of this :

if GetAsteroid(0):GetRadius() > 200 == then

but i tried also
if GetAsteroid(0):Radius() > 200 == then
if GetAsteroid(0):GetRadius() > 200 == then
if GetAsteroid(0):SetRadius() > 200 == then
hmmmm if GetAsteroid(0).SetRadius() > 200 == then

Code: [Select]
function LevelLogic()

if GetAsteroid(0):SetRadius() > 200 == then
V = ( 4 / 3 ) * 3.14159265 * ( Straal * Straal * Straal )
GetAsteroid(0).CoreHealth = V
end

end

Edit : but there was a thing that i have change on that line if .....than
and the loading of hte game take a little longer than normale but the same error....

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #135 on: July 22, 2010, 04:18:52 AM »
Ah, use

Code: [Select]
function LevelLogic()

[b]if GetAsteroid(0).Radius > 200  then[/b]
V = ( 4 / 3 ) * 3.14159265 * ( Straal * Straal * Straal )
GetAsteroid(0).CoreHealth = V
end

end

Radius is an attribute (?...annikk?), not a function, so you use a period, not a colon. Also, you had '==' after your test, which you should never do, because it will cause an error.

You do realise that code will only run once don't you?

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #136 on: July 22, 2010, 05:12:14 AM »
annikke.exe!  That use of the sin function gave me a great idea for a level, but I'm not nearly skilled enough to put it into effect.  What if you used a sin function to create a level with seasons, it would put an interesting twist on the level!  During the winter phase, I was thinking the trees could die off, then in the spring they can be plated again and in the summer they produce at a fast rate (maybe add lines to level the trees up to full instantly once it hits summer).  Along with the seasons, the background color could change with it to represent the changing seasons.  I don't know if it's possible to do this, but I think it would make for a challenging level!

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #137 on: July 22, 2010, 06:30:05 AM »
Amazing ideas, Terrial. There have already been user-created maps with day/night lighting and increasing/reduced send distances.

But please, folks, whenever you create maps w/ changing background colours, please make them so that the seedlings always stand out, contrast-wise or something like that. I've seen levels where it was impossible to see whether there were seedlings around an asteroid when zoomed out.

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #138 on: July 22, 2010, 06:35:01 AM »
Haha thanks, I just love this game so much and it has so much potential.  I also just really enjoy the fact the the whole game is based on plants. (If I weren't going to be an engineer and it were a practical thing for me to do I would love to become a Horticulturist)

Also ideas just pop into my head all the time, I've had more like this but I've forgotten them, I'll have to start writting them down if you guys like them.

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #139 on: July 22, 2010, 06:50:08 AM »
Terrial, I think ideas are ALWAYS welcome here in this forum, and you’ll find a lot of friendly and helpful people here.

Perhaps this has to do with the nature of the game, as you talk of the game being based on plants. Well, there is some shooting and conquering and all, since we humans seem to need such, but all in all the game is definitely something other than the usual war & shooting games. I love it for the same reason. Might be a nice idea, though, to bring the possibility of co-operation w/ other factions into it, somehow. But I guess that might be quite hard … friendliness could, e.g., be communicated by visiting a new asteroid and leaving it immediately after having found that it's inhabited already, but that would have to happen before getting killed :D

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #140 on: July 22, 2010, 06:53:45 AM »
Well, you could make a tribute system by creating a trigger that may be used with the right click where if you right click, say 10 of your seeldings are given to another empire (killed and respawn as the other empire)  Or alternatively, you could create a trigger by having some roids FAR out in the distance where nobody can get to them with 1 seedling and based on which asteroid the seedling is on, it could change a setting in the game.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #141 on: July 22, 2010, 06:57:05 AM »
aarggg ok i change here and there
so it not working enymore
i change only now from straal to radius becaus it straal is just dutch for Radius
but normale
is it
i set me radius of asteriod 0 to 250
Code: [Select]
a:SetRadius(250)so
it but be like : if radius of asteroid 0 greater than the number 200 is than
( we put than a calculation volume and the volume is equal to SetCoreHealth of the same asteriod )
( the code of volume is V= (4/3) * Pi * radius³ ( to the third Square-algebra) BUT that number must come from that asteroid)
so
than must it be something like this :
Code: [Select]
V = ( 4 / 3 ) * 3.14159265 * ( GetAsteroid(0).Radius  * GetAsteroid(0).Radius  * GetAsteroid(0).Radius  )
than the output is the SetCoreHealth of that asteroid so it must

it should xD hmmm lol : 65 449 846,95
so that is realy to mutch xD So it must divide by a number that I take is 685,000( but I do not know how to do it)
but that is not so important at the moment


than the "full versie"
this is more important :
but some reason that not working i get the same thing 90....


Code: [Select]
if GetAsteroid(0).Radius > 200  then
V = ( 4 / 3 ) * 3.14159265 * ( GetAsteroid(0).Radius  * GetAsteroid(0).Radius  * GetAsteroid(0).Radius  )
GetAsteroid(0).SetCoreHealth = V
end

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #142 on: July 22, 2010, 07:08:39 AM »
about that  day/night it exists level : Night_Stalkers you can only move in day light link : http://www.dyson-game.com/smf/index.php?topic=789.0

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #143 on: July 22, 2010, 08:58:59 AM »
Right, and IIRC you can also only plant during daylight.

(Must. Update. List. Of. Maps.)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #144 on: July 22, 2010, 05:49:50 PM »
w4tc.

Here is the list of fields and functions.

CoreHealth, not SetCoreHealth, is a field. SetCoreHealth doesn't exist, so trying to call it will cause an error.

As I said in my previous post:

CoreHealth is a field, so you need to assign values directly to it rather than calling it like a function - for this you use the dot and equals:

GetAsteroid(0).CoreHealth = V

That is the syntax and field name you require. Just copy that line and use it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #145 on: July 22, 2010, 09:48:31 PM »
annikke.exe!  That use of the sin function gave me a great idea for a level, but I'm not nearly skilled enough to put it into effect.

The way you do it is by making a continuously-updated variable (using a loop).


So start out with your function LevelLogic() and lets make a loop:


(click to show/hide)




Hopefully you follow what is going on so far.  We've created a loop that will run indefinitely.
Next, lets make a variable to represent the up-and-down wavy motion we get with sin:


(click to show/hide)



Now we have a continously updating value.
fluffy will slowly roll between the values 1 and -1 as time goes by.

Here's a way to visualise what's going on:



Imagine the circle is a clock, and as it turns it represents time going by.

On the line above, the horizontal axis represents the value of fluffy.




Maybe we want the pulses to go faster...
(spot the difference here!)


(click to show/hide)

After 1 second, we'll be taking the math.sin of 2.5, instead of 1.
So it will rush through the cycles faster.  Adjust to taste.  :>



Now, drifting between 1 and -1 is all well and good, but perhaps we'd like to change the background colour between 0 and 255.  How to do that?
Well, all we do is run some maths on fluffy and we can convert the minimum value (-1) to 0 and the maximum value (1) to 255.
How to do that?

Like this:


(click to show/hide)


So with that bit of maths, now we have a constantly-updating variable with a suitable range to use for background colour.  :>

Finally, lets hook our variable up to control background colour:





(click to show/hide)


Now our background colour will range between totally black (0,0,0) and totally white (255,255,255).



Maybe we want it to fade between totally black and totally red.  Then we would replace the existing background colour command with this one:

Code: [Select]
SetBackdropColour(fluffy,0,0)


Hope this makes it clearer.  Let me know if there's anything you don't understand :>

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #146 on: July 23, 2010, 02:37:15 AM »
heh heh, when i said I'm not skilled enough, i meant I don't know all of the functions to kill off, and only allow planting during a certain phase, and make the trees hit max level during the summer phase.  I understand the math just fine.

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #147 on: July 23, 2010, 02:52:37 AM »
But me here, w/ near zero programming knowledge, I am happy to learn about this, thx @Annik. The visualisation from Wikipedia makes a lot clear to me. Been so long since I went to school …

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #148 on: July 23, 2010, 04:57:48 AM »
sorry alex but it not working, I dare not even post about i for that you be angry or something :$
So, I've changed things so that it is easy to start

I start just for manually change ( like the post : http://www.dyson-game.com/smf/index.php?topic=848.0 )

Code: [Select]
function LevelLogic()
mycorehealth = 100
GetAsteroid(0).CoreHealth = mycorehealth
end
But i dont work. I think that this problem be solved first, then we can make further steps?

the full code ( 2 roids + that funtcion )
(click to show/hide)

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #149 on: July 23, 2010, 07:07:01 AM »
try putting it in parenthesis, i don't know why but that might help.  Also try it without spaces between the = sign.  That's how I've been going about trying to get the syntax to work, just trying every possible combination! haha

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #150 on: July 23, 2010, 07:34:54 AM »
I discovered something cool, but not currently have what I need
The count on to its value, but not the value that I've made in

Code: [Select]
function LevelLogic()
mycorehealth = 100
GetAsteroid(0).CoreHealth="mycorehealth"
end

Also count upo whit and stops on 90Corehealth
Code: [Select]
GetAsteroid(0).CoreHealth='mycorehealth'
Also tried whit :

Code: [Select]
GetAsteroid(0).CoreHealth=(mycorehealth)
Even
Code: [Select]
GetAsteroid(0).CoreHealth=100
Code: [Select]
GetAsteroid(0).CoreHealth=(100)
Code: [Select]
GetAsteroid(0).CoreHealth(100)
with no result, i gave always 90

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #151 on: July 23, 2010, 10:54:50 AM »
So I started trying to make that seasons level.  I can't get the colors to change because I don't know how to make the game count up and restart.  (I couldn't figure out how to make the sin function work to change it between four different colors)

He's what I have so far if anyone wants to take a crack at it:
Pay no attention to the asteroids, they are just there to look pretty.

(click to show/hide)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #152 on: July 23, 2010, 04:24:26 PM »
Although you have stated this..

Code: [Select]
GetAsteroid(0).CoreHealth = 100

...you have forgotten this one:


Code: [Select]
GetAsteroid(0).MaxCoreHealth = 100

You need to change both.  :>




Like this:

Code: [Select]
function LevelLogic()
mycorehealth = 100
GetAsteroid(0).CoreHealth = mycorehealth
GetAsteroid(0).MaxCoreHealth = mycorehealth
end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #153 on: July 23, 2010, 04:34:40 PM »
Terrial,

Avoid nesting While loops.  Instead, use a series of If statements, like this [pseudocode]:


Code: [Select]
If colortimer is more than [i]this[/i], but less than [i]this[/i], then
  -- season 1
elseif colortimer is more than [i]this[/i], but less than [i]this[/i], then
  -- season 2
elseif colortimer is more than [i]this[/i], but less than [i]this[/i], then
  -- season 3
elseif colortimer is more than [i]this[/i], but less than [i]this[/i], then
  -- season 4
end



Also, the method you are using to make a timer will result in VERY fast seasons.  I think lua runs at 60 or 100 fps, so you will get 1 season per 1-2 sec.  :P
Instead, I would suggest tying your counter to the game time - this is a much more reliable way to set things up.  Use a mechanism something like this:


Code: [Select]
timer = GetGameTime()

for i = 0,100 do
  if timer > 400 then
    timer = timer - 400
  end
end

colortime = timer

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #154 on: July 24, 2010, 01:05:54 AM »
sorry alex but it not working, I dare not even post about i for that you be angry or something :$
So, I've changed things so that it is easy to start

I start just for manually change ( like the post : http://www.dyson-game.com/smf/index.php?topic=848.0 )

Code: [Select]
function LevelLogic()
mycorehealth = 100
GetAsteroid(0).CoreHealth = mycorehealth
end
But i dont work. I think that this problem be solved first, then we can make further steps?

the full code ( 2 roids + that funtcion )
(click to show/hide)

Oh DUDE - my mistake! As annikk.exe says it's MaxCoreHealth you want.

Sorry. Also regarding my last post, I was mega stressed out when I wrote that, sorry it was a little terse.

 :-*

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #155 on: July 24, 2010, 01:17:58 AM »
You need to change both.  :>

but thank you so much! annikk!

@Alex :
(click to show/hide)

omg xD I was 3 days long search how it works
but we are there to help each other :D !
That's no problem alex, thats understandably xD :-*

Now we will the next steps.

Hmm but i have a question when during the game:
I through : if roid X number of seeds greater than 200 on a asteroid then
so i want change TreeCap on that roid
so that the treecap changing to more or less in cap
but must i beter put it in a
Code: [Select]
while GameRunning() do
coroutine.yield()
or not?
« Last Edit: July 24, 2010, 01:21:59 AM by w4tc »

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #156 on: July 24, 2010, 01:21:13 AM »
Quote
Avoid nesting While loops.

AHAHAH Wow, it's been so long since I programmed, I should have known better than to try that.

hmm, that for loop.  So does i increase 1 for every game second then?

edit: I tested it and all the colors now cycle through and restart just fine. 

Can someone tell me what the default numbers are for these values in a regular game?

(click to show/hide)
« Last Edit: July 24, 2010, 03:00:25 AM by Terrial »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #157 on: July 24, 2010, 04:47:09 PM »
Quote
hmm, that for loop.  So does i increase 1 for every game second then?

Nope, i increases at an arbitrarily fast pace.
The reason for that loop is that, suppose the game time is 1201 seconds.... we don't have any rules for what the colours should change to beyond 400 seconds, so we need to reduce this to a domain that we have rules for.

On the first pass of the loop, the conditions of the If statement are met, and 400 is deducted from that amount to give 801... then on the second pass, another 400 is deducted, giving, 401.  A final loop through triggers the If Statement a third time, and the value drops to 1.

This 1 falls between the limits set for the seasons.  Remember, we only mapped out 400 seconds worth of colour changes, so when we get above that, we want to start again at the beginning.

So because it's i = 0,100 that means we will get roughly 100 full cycles of 4 different seasons, which takes us above 40,000 seconds of game time, which is enough for 11 hours of play.  If you played the level for 12 hours, the seasons would stop.  :P

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #158 on: July 25, 2010, 02:31:21 AM »
so if you made the loop go for i =0,200 then it would go for 200 cycles? 

If I were to make Globals.Structures.LevelTime1 (999999) during the winter phase of the game then would that make that level of the the tree pretty much never finish during that season? Same with the spawn rate?

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #159 on: July 25, 2010, 07:18:03 AM »
I was working now on the effect of the backdropcolour
You will begin on roid 0 and if you go to roid 2,3 or 4 than set the SetBackdropColour to SetBackdropColour(0,0,0) that working
but if i gi back i wanne have a normale backdropcolour
I hope it the good a setpoint
but that dont work
or must i use also else? but may I  it leave blank?
here is the code :

Code: [Select]
function OnAsteroidRevealed(id, owner)

if id == 2 or id == 3 or id == 4 then
SetBackdropColour(0,0,0)
elseif id == 0 then
SetBackdropColour(255,255,255)
end

end

@annikk i like that with your red fleshing things can you a little explain how this works? :p

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #160 on: July 25, 2010, 07:37:39 AM »
so if you made the loop go for i =0,200 then it would go for 200 cycles? 

Yes.  I figured 100 was plenty tho.  :>


Quote
If I were to make Globals.Structures.LevelTime1 (999999) during the winter phase of the game then would that make that level of the the tree pretty much never finish during that season? Same with the spawn rate?

I don't know.  Probably.  Try it.  :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #161 on: July 25, 2010, 07:50:39 AM »
I was working now on the effect of the backdropcolour
You will begin on roid 0 and if you go to roid 2,3 or 4 than set the SetBackdropColour to SetBackdropColour(0,0,0) that working
but if i gi back i wanne have a normale backdropcolour

When the seedling makes its return journey, you're not revealing any asteroids.  So the elseif id == 0 then is never triggered.


You will need to do this in function LevelLogic() instead.


If you don't already have a while GameRunning() loop, make one.  Then inside it you need to put something like this:


Code: [Select]
noseeds = 0

for i = 2,4 do
if GetAsteroid(i):GetNumSeedlings(1) > 0 then
SetBackdropColour(255,255,255)
elseif GetAsteroid(i):GetNumSeedlings(1) == 0 then
noseeds = noseeds + 1
end
end

if noseeds == 3 then
SetBackdropColour(255,255,255)
end


Remember, you will need to put this code inside a while GameRunning() loop, which should be inside function LevelLogic()






Quote
@annikk i like that with your red fleshing things can you a little explain how this works? :p

There is a specific state that the Infected AI is in when it orders the gather point to attack a target asteroid.  I set a variable called rcolour when this happens, to be equal to rcolour + 180.
Inside the AI engine's while loop, there is a command to set the background to rcolour for the red component of the colour.  There is also a part that checks whether rcolour is more than 0 - if it is, it subtracts 1 from rcolour.

This means that the red fades out of the background colour over the course of about 3 seconds.  If the AI launches several attacks in quick succession, as it is prone to do when swarming out of control, the background momentarily becomes an even more intense shade of red.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #162 on: July 26, 2010, 05:28:33 PM »
Can someone tell me what the default numbers are for these values in a regular game?

(click to show/hide)

If you check out the file Resources/default.xml, that has some values in it that are used when no others are given in the level xml or lua.

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #163 on: July 26, 2010, 05:44:07 PM »
Oh thank you! I never noticed that file before!

edit:

So I'm having a problem, when a tree is planted during a certain phase, it keeps the global variable from when it was planted.  For instance, if you plant a tree during the winter phase when they arn't supposed to grow, then it doesn't grow.  When the spring phase comes, it does not start to grow, instead it keeps it's time levels from when it was planted, and trees planted in spring do not change their growing behavior in the summer phase.  How can I fix this?


(click to show/hide)
« Last Edit: July 26, 2010, 07:11:17 PM by Terrial »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #164 on: July 26, 2010, 07:34:45 PM »
That's not an easy one to fix.  There doesn't seem to be a provision for editing the stats of pre-existing trees.  Unless Alex knows a sneaky way to do it...

I suppose one way to do it would be to abandon the spawn timing for trees, and simply make it such that every spring, all trees level up once.  Bit of a weak solution though.  I'll have a think on this and see if I can figure out something else cool.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #165 on: July 26, 2010, 07:59:53 PM »
Not tried this myself, but how about:


Code: [Select]
for surething = 0,400 do
a = GetEmpire(1):GetRandomAsteroid()
s = a:GetRandomDysonTree()
s.LevelTime1 = 30
s.LevelTime2 = 30
s.LevelTime3 = 30
s.LevelTime4 = 30
end

Does that let you change them?

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #166 on: July 26, 2010, 09:17:18 PM »
Bit of a waste though. I'll see if I can put something in.

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #167 on: July 27, 2010, 02:59:37 AM »

Code: [Select]
for surething = 0,400 do
a = GetEmpire(1):GetRandomAsteroid()
s = a:GetRandomDysonTree()
s.LevelTime1 = 30
s.LevelTime2 = 30
s.LevelTime3 = 30
s.LevelTime4 = 30
end

Does that let you change them?

I tried putting that in and it stopped the progression of the seasons.  Also, I think that, that random function could very possibly miss trees.

@Alex: That would be awesome if you could add something!

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Level design/ Code questions from a beginner
« Reply #168 on: July 27, 2010, 03:06:07 AM »
That's why he's doing it 400 times, just to brute force it and hope all the trees get chosen... you need to be able to iterate over the trees really.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #169 on: July 27, 2010, 05:23:09 AM »
When the seedling makes its return journey, you're not revealing any asteroids.  So the elseif id == 0 then is never triggered.

Of cours becaus we have al ready "revealing" that asteroid in the begin of the game
I gonne try it now, but first i take a stroopwafel (img : http://sannieslog.punt.nl/upload/stroopwafel.jpg

Edit Adding on 27/07/2010
i have change this :
Code: [Select]
for i = 2,4 do
to
Code: [Select]
for i = 2,3,4 do
but it was not working only for i = 2,4 do there a possible to more than 2 roids?

Edit again xD But :D a good reason xD
I've now solved this by using:
Code: [Select]
for i = 2,4 or 3 do
Edit : Now a big problem it must something block
the colour mai change only of you send de seeds to a asteroid
if you have a now born seed.... change the colour
« Last Edit: July 28, 2010, 03:09:47 AM by w4tc »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #170 on: July 28, 2010, 09:29:19 PM »
When the seedling makes its return journey, you're not revealing any asteroids.  So the elseif id == 0 then is never triggered.

Of cours becaus we have al ready "revealing" that asteroid in the begin of the game
I gonne try it now, but first i take a stroopwafel (img : http://sannieslog.punt.nl/upload/stroopwafel.jpg

Edit Adding on 27/07/2010
i have change this :
Code: [Select]
for i = 2,4 do
to
Code: [Select]
for i = 2,3,4 do
but it was not working only for i = 2,4 do there a possible to more than 2 roids?

That new code is NOT correct.
The old one was fine.

The old one counts 2,3,4.  You're saying "count from 2 to 4".  That inevitably includes 3 too.

Here's another example:

Code: [Select]
for count = 5,10 do
This means "count from 5 to 10".
So it will count 5, 6, 7, 8, 9, 10.




Quote
Edit again xD But :D a good reason xD
I've now solved this by using:
Code: [Select]
for i = 2,4 or 3 do

No idea where you are getting this from...  why not just use the correct one that I gave you?



Quote
Edit : Now a big problem it must something block
the colour mai change only of you send de seeds to a asteroid
if you have a now born seed.... change the colour

Post your whole code.  It sounds like you've messed things up a bit.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #171 on: July 29, 2010, 01:16:12 AM »
FOR loops:

for a,b,c do
     --stuff here
end

in the above 'example',  a is the start number, b is the end, c is the size of the step.

If you used

for 2,3,4 do

then it would use the value 2, then stop, because 2+4 is 6, bigger than 3.

Someone should write a general LUA reference, for things like while loops, for loops, if-elseif-else blocks, etc, rather than just eufloria specific code.

I could do it next week, but if anyone else want to do it before then, be my guest.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #172 on: July 29, 2010, 04:19:01 AM »
Oeps sorry annikk, Yesterday I had done something that was not working asteroid 3
that why
but now it works great
but i wanne now if i go to a other roid must change to black
so i tried :

(click to show/hide)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #173 on: July 29, 2010, 06:17:10 AM »
Code: [Select]
while GameRunning() do

noseeds = 0

for  i = 2,6 do
if GetAsteroid(i):GetNumSeedlings(1) == 0 then
noseeds = noseeds + 1
end
end

if noseeds == 5 then
SetBackdropColour(0,0,0)
elseif noseeds ~= 5 then
SetBackdropColour(150,0,0)
end

coroutine.yield()
end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #174 on: July 29, 2010, 06:20:04 AM »
That code will set the background colour to red if there are no seeds on Asteroids 2, 3, 4, 5, and 6.  If there are seeds, it sets the colour to black.


The reason I am checking if noseeds is equal to 5, is because we are checking for the presence of seedlings on 5 different asteroids.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #175 on: July 29, 2010, 06:55:22 AM »
but i wanne set more SetBackdropColour :$ that is what i mean :$ ( soory my fault )
like i trying the last code
roid 0 : SetBackdropColour(255,127,39)
roid 1 :SetBackdropColour dark blue
roid 2-4 : red
roid x : that collour
 

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #176 on: July 29, 2010, 07:00:41 AM »
maybe i can for a 3e collour
use hmmmm like this?
hmmm i must this calculate.....
example
Code: [Select]
elseif noseeds ~= 6 then
SetBackdropColour(200,0,0)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #177 on: July 29, 2010, 07:10:14 AM »
Annikk, I'd streamline that code if I were you.

The last bit doesn't need the elseif, it can just be
Code: [Select]
if noseeds == 5 then
--blah
else
--more blah
end
If x==y is false, then x~=y MUST be true (don't mention cats in boxes, please), so doesn't need to be checked.

In fact, that for loop could be done away with completely, and replaced with

Code: [Select]
if #check seeds on 2# and #check seeds on 3# and #check seeds on 4# and #check seeds on 5# and #check seeds on 6# then

--blah

else

-- more blah

end

noseeds can be removed, freeing it up even more.

I've not got access to Eufloria at the moment, so can't do any speed checks, but I think that's more efficient.

EDIT: The second codeblock (no for loop) speeds it up because there are, worst-case, only four tests, whereas before, there were five inside the for loop, to check if there were seeds on that asteroid, the for loop itself, which takes time, and memory in the form of the counter variable, one to check if noseeds == 5, and if not, another(completely redundant) check to see if it was not equal to 5. There was also noseeds to deal with.

So, six ifs, two variables before, four ifs, no variables after. Sorry if that sounds grumpy, or harsh or something, it's honestly not meant to be. Just showing the changes, not trying to say ' I'm better than you. '
« Last Edit: July 29, 2010, 07:25:44 AM by Pilchard123 »

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #178 on: July 29, 2010, 07:22:13 AM »
[..]

If x==y is false, then x~=y MUST be true (don't mention cats in boxes, please) [..]

ROTFL I’ve let that dead cat run free 20 yrs ago and it comes to my back door every day and meeows for more zombie fodder ;D

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #179 on: July 30, 2010, 01:05:15 AM »
but what means this? :
Code: [Select]
~=
the things that I know of:
>= greater than or equal
<= less than or equal
== eqaul

are ther more of this?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Level design/ Code questions from a beginner
« Reply #180 on: July 30, 2010, 01:08:28 AM »
It means is NOT equal to, in LUA.

So, 3 ~= 4 is true, but 3~=3 is false.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #181 on: July 30, 2010, 04:19:53 AM »
also i dont understant this

Code: [Select]
if noseeds == 5 then
SetBackdropColour(255,127,39)

but the noseeds is 0 how can it set that SetBackdropColour(255,127,39)?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #182 on: August 01, 2010, 09:58:48 PM »
w4tc,


I took a look at the code you sent.


Please can you describe to me what you want it to do?  It's not clear.

For example...

The background colour starts off (255,127,39), but if you send a seedling to asteroid 3 it becomes red.
If you move the seedling back off asteroid 3, it goes back to being (255,127,39).
If you move the seedling onto asteroid 30, the background turns blue.  When you move it off again, it goes back to (255,127,39).

So what do you want to happen when you have a seedling on asteroid 3 and asteroid 30 at the same time?



Please explain, in as much detail as possible, what you would like the code to do.  Then I can help you.

Also, please stop PM'ing me; I will not reply to PM's about coding, if you want help with coding then post it here on the open forum.  :>

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #183 on: August 02, 2010, 12:15:02 AM »
Hello Annikk
Oopes xD sorry for PM'ing you :$

There are 5 Colour's
The begin/start colour and the 4 step's or groups of colour's:

So background colour begins on (255,127,39) that is roid 0 ( colour soft organe )
The colour change only when you send your seeds to a ohter roid
[Step 1] The change the colour of roid 1-4 is : lime green
[Step 2] The change the colour of roid 5-7 is : dark red
[Step 3] The change the colour of roid 8-14 is : black
[Step 4] The change the colour of roid 15-33 is : blue

So a example
you are on roid 7 ( than is it the colour normal dark red )
if you send your seed to roid 8 than change the clour to black
if you send it back to roid 7 than it change to dark red

but if you send from roid 16 ( than is it the colour normal blue)
to roid 8 than must de colour change to black

for send at the same time :
it has nothing to do from where you send
but to where you send

example
You have just send a a seed to roid 4 than isnormale your colour lime green
you plant your seeds and you want to go, to roid 5
you send from roid 4 to roid 5 than will change the colour from limegreen to dark red

but you send also at the same time fromroid 15 to roid 8
here at that moment will not change things becaus you have send a seed to roid 4 so it still lime green
now the seeds they come closer from  roid 4 to roid 5
they are just arrived at their destination ! so now change the colour from lime green to dark red....
woow yes :D and now the seeds of roid 15 are also arrived on roid 8
now is it the colour black

So i hope i have now al little more clear


I have just a little question :
how can you tell that Owner 2 should not be moving with his seeds to ohtere?








InTouch

  • Achiever
  • Seedling
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
Re: Level design/ Code questions from a beginner
« Reply #184 on: August 02, 2010, 12:40:22 AM »
Can I get some coding help? I need to make a win condition. Soo I requested a king of the hill map. You can see my thread on the front page of this section. Ok so what I need help coding is a win condition and a timer and a message on event. I need a win
/ lose condition of holding an asteroid for a set amount of minutes. Also I need a timer for each empire that starts/resumes when they take an asteroid and pauses when they don't have it. Also is there a way to make an asteroid look different from the others?

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #185 on: August 02, 2010, 01:46:47 AM »
hmmm let me try help you,i thing you need something like this


Code: [Select]

TimerWin = GetGameTime() + 60

if TimerWin == GetGameTime()  then
Pause()
MessageBox("Victory!")
WaitDialog()
Unpause()
Quit(true)
end
end

but can you explain better, how exactly works King of the Hill?

InTouch

  • Achiever
  • Seedling
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
Re: Level design/ Code questions from a beginner
« Reply #186 on: August 02, 2010, 02:20:25 AM »
There's a specified asteroid that you have to take and hold for a specified time. It can be left for an unlimited time

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #187 on: August 02, 2010, 02:30:57 AM »
So if good I understand it, you must first conquer roids
and then start your timer to run for example 5 minutes and then you have won
but when the enemy comes back to conquer the counter will stop and you have to start over again.
is it that what you mean?

InTouch

  • Achiever
  • Seedling
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
Re: Level design/ Code questions from a beginner
« Reply #188 on: August 02, 2010, 02:43:55 AM »
i only need the timer for 1 roid. the "hill" in king of the hill. and the timer just pauses when you lose the asteroid

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #189 on: August 02, 2010, 03:33:27 AM »
I'm almost there
I just let the code you see

(click to show/hide)

But it can not realy work becaus the GetGameTime is a larger number befour it is equal
to the TimerKingoftheHill
« Last Edit: August 02, 2010, 03:54:17 AM by w4tc »

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #190 on: August 02, 2010, 03:50:50 AM »
Try this for your king of the hill, I'm pretty sure this will work:

Code: [Select]
function LevelLogic()  --holds code to run during the game

TimerWin = GetGameTime() + 9999999

while GameRunning() do

Challenger = GetAsteroid(AsteroidOfTheHillVariety).Owner


if Challenger ~= KingOfHill then
TimerWin = GetGameTime() + 60
KingOfHill = Challenger
Pause()
MessageBox("The Hill's Owner has changed!")
WaitDialog()
Unpause()
end

if TimerWin == GetGameTime() and KingOfHill == 1 then
Pause()
MessageBox("Victory!")
WaitDialog()
Unpause()
Quit(true)
elseif TimerWin == GetGameTime() and KingOfHill ~= 1 then
Pause()
MessageBox("You Have been Bested!")
WaitDialog()
Unpause()
Quit(true)
end

coroutine.yield()  --DO NOT DELETE THIS
end --EndGameRunning


end --LevelLogicEnd

edit: You will need something that makes the AI attack the Hill asteroid, or it will just be boring when you take it and they don't even try.
« Last Edit: August 02, 2010, 03:59:22 AM by Terrial »

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #191 on: August 02, 2010, 07:02:53 AM »
Ok i have find it  ;D ( edit : i thing )


Here is the code

(click to show/hide)

Ok what you need to do here is
Roid_ofkingofthehill this must you change to a number of a asteroid
and about this : TakeARoidThatYouNotUsed

if i understand what you mean http://www.dyson-game.com/smf/index.php?topic=774.msg5985#msg5985
than i understand there is not realy a "defeated"
so what you need to do is make a asteroid
like this

(click to show/hide)

we must add the defeated trigger about the game will crash and that no good
so we have put a defeated trigger to a asteroid that we not can see ingame
« Last Edit: August 05, 2010, 02:35:02 AM by w4tc »

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #192 on: August 02, 2010, 08:01:11 AM »
I'm pretty sure I had it right.

w4tc: The way he wants the level, is everyone tries to take the asteroid that acts as the hill.  When a new person takes the hill the timer resets.  If someone manages to hold the hill for the whole timer then they are the one that wins.  So if the AI holds the hill for the whole timer then you lose.

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #193 on: August 02, 2010, 08:25:17 AM »
Code: [Select]
So if the AI holds the hill for the whole timer then you loseHmmmm than i mis understand sorry.
So if the AI takes over the hill roids than one time too early to run?
the same as owner1? or longer

But i tried also your code, but if i take the hill roid for more than 1 min but nothing happens :S ???

Edit
I there need also a lose condition for the AI whit the same time than is it just :

(click to show/hide)

Roid_ofkingofthehill this must you change to a number of a asteroid for you King of the hill roid
« Last Edit: August 02, 2010, 08:31:32 AM by w4tc »

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #194 on: August 02, 2010, 08:37:22 AM »
hmm, I don't know why it's not working.  I have to go to work now, but maybe annike can figure something out

InTouch

  • Achiever
  • Seedling
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
Re: Level design/ Code questions from a beginner
« Reply #195 on: August 02, 2010, 09:51:54 AM »
i tried making a test map using euclid but it throws an error saying:
Unable to load level
Resources/Maps/test.lua:117:'end'
expected (to close function at line 99)
near'<eof>'
 ??? ???

w4tc

  • Achiever
  • Shrub
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 170
Re: Level design/ Code questions from a beginner
« Reply #196 on: August 02, 2010, 09:57:55 AM »
can you have you code?

Terrial

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
Re: Level design/ Code questions from a beginner
« Reply #197 on: August 02, 2010, 06:04:15 PM »
I got the level to work.  It wasn't recognizing when the timer = the game time  I fixed it by making it <=

So I'm putting together the asteroids now.  I should have the level up later today.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #198 on: August 05, 2010, 02:51:14 AM »
W4tc,

I have finally got around to reading your post properly, and building a response.

These changes should provide the functionality you described:



You'll need to make an array for this.
So you need to initialise the array first, you do that in function LevelSetup() using this command:


Code: [Select]
seednumber = {}


All the array slots start out with the value nil.  We want them to start with the value 0.  So initialise the needed slots like this:


Code: [Select]
for seedset = 1,33 do
seednumber[seedset] = 0
end




Finally, make sure you have set the initial background colour:

Code: [Select]
SetBackdropColour(255,127,39)



Next, put this code into function LevelLogic, replacing any existing while loops.




Code: [Select]

while GameRunning() do

for i = 1,4 do
if GetAsteroid(i):GetNumSeedlings(1) > seednumber[i] then
SetBackdropColour(0,255,0)
end
seednumber[i] = GetAsteroid(i):GetNumSeedlings(1)
end


for i = 5,7 do
if GetAsteroid(i):GetNumSeedlings(1) > seednumber[i] then
SetBackdropColour(155,0,0)
end
seednumber[i] = GetAsteroid(i):GetNumSeedlings(1)
end


for i = 8,14 do
if GetAsteroid(i):GetNumSeedlings(1) > seednumber[i] then
SetBackdropColour(0,0,0)
end
seednumber[i] = GetAsteroid(i):GetNumSeedlings(1)
end


for i = 15,33 do
if GetAsteroid(i):GetNumSeedlings(1) > seednumber[i] then
SetBackdropColour(0,0,255)
end
seednumber[i] = GetAsteroid(i):GetNumSeedlings(1)
end



coroutine.yield()
end



annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Level design/ Code questions from a beginner
« Reply #199 on: August 05, 2010, 03:05:48 AM »
RE King of the hill win condition.


I'm interpreting your requirements to mean the following, if this is not right, please say so:


Asteroid 0 will be the King of the Hill asteroid.

There will be two timers, they are called playertimer and aitimer.

playertimer ticks up for the player (empire 1) for every second they own the asteroid.
aitimer ticks up for the enemy (empire 2) for every second they own the asteroid.
If neither empire 1 or empire 2 own asteroid 0, no timer will tick up.

If playertimer reaches 180 sec, empire 1 (the player) wins, and the game ends.
If aitimer reaches 180 sec, empire 1 (the player) loses, and the game ends.



Is this correct?  Let me know if it is, and I'll show you how to make a win condition like this.  :>