Author Topic: Experimental Lab  (Read 152778 times)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Experimental Lab
« on: March 25, 2011, 09:32:21 PM »
Ok, making a new topic for: Experimentation! Ok, so you can just goa round experiementing with cool codes and stuff and keep it for yourself... Or you can post the cool code here! I hope that we in the end will end up with tons of ways to make stuff :D

So I'll add all the codes that is presented under this spoiler button :)
(click to show/hide)

So I hope you find this either useful or funny :)

P.S Post your experiements here :D
« Last Edit: May 01, 2011, 09:21:12 PM by Aino »

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: Experimental Lab
« Reply #1 on: March 26, 2011, 03:28:59 PM »
You could make some interesting maps if you used either of those code snippets to position your asteroids. :)

I noticed a small error when I was testing the radar sweep code. You seem to have missed the closing bracket for math.cos, which looks like it's supposed to go after math.pi.

Also, for the Strange "Thing" (which looks a lot like a vortex to me), you might want to seed the positions with something other than just the result of GetGameTime(). I wasn't actually testing your code in Eufloria (so I may be wrong here), but if GetGameTime() always starts at 0 you could use the system time instead so that the things you're positioning don't just start out in one straight line.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #2 on: March 26, 2011, 07:35:04 PM »
They don 't "start" in a straight line I belive, but they do seem to, maybe because GetGameTime() is faster than your eyes?
« Last Edit: March 26, 2011, 07:38:21 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #3 on: May 01, 2011, 12:01:33 AM »
Added GetMouseX() and GetMouseY()... maybe A&R should add it themself(just sayin' :))

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #4 on: August 24, 2011, 08:55:05 AM »
I was playing around with some of Annikk's mathematics and made a hypnotic screensaver.

It's fun to tweak the graphics.

Attached is a more 3D-looking version.
« Last Edit: August 24, 2011, 06:19:40 PM by Lost Seedling »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #5 on: August 24, 2011, 03:10:42 PM »
Wow!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #6 on: August 24, 2011, 05:58:25 PM »
That's awesome :>

(I told you guys there was beauty!! here's some proof :>)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Experimental Lab
« Reply #7 on: August 24, 2011, 09:03:24 PM »
*Picks jaw up off floor*

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #8 on: August 24, 2011, 10:21:35 PM »
As we are on it, try out "Madness" and solve the riddle without looking at the code!

I warn you though, you can't unsee the crazyness x.x

But it's a very cool use of Annikks starfield :)

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #9 on: November 28, 2011, 07:45:49 AM »
Wow. Has the Euflorium ever been this dead before? I wonder if Annikk is still alive?

Here's a little program that should provide you with a few minutes of amusement...

Left mouse-click for three different "modes".

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #10 on: November 29, 2011, 03:07:06 PM »
The forum is way too dead now :/

And Annikk seems to have disappeared, hope he returns though :)
I am busy doing Java, maybe I'll share what I've made for now?

The map though, eye-candy!
Also, Seedling, maybe you want to look into atan2? Useful for angles, especially if you want to program in the future too :D

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #11 on: November 29, 2011, 03:38:16 PM »
If there was more activity or interest in the forum, I might be willing to spend time creating more maps, but I guess the "classic" pc Eufloria has run it's course, so to speak, and there is no point in investing my time and effort into more programming. From what I read here, the new pc version will not be as accessible to modifications, so the map-making for me is at its end. It was fun and challenging learning how to write code and solving problems, but I have no interest in moving on to other platforms or languages. There are too many other areas of interest to pursue with my limited time.

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Experimental Lab
« Reply #12 on: November 29, 2011, 05:13:54 PM »
Whoa there partner! The pc version has NOT run its course, Alex is working hard to get all the PSN advances back into the pc build.
We are also going to release a Mac and hopefully a Linux port so I hope we will see more activity once these new releases start appearing. :-)

Furthermore, we suspect that we will see a big influx of new players soon, which means the Eufloria audience will suddenly have players that have never seen all the mods. :-)

I know Alex and I have not been spending a lot of time on the forum, but that is simply because we are working so hard to get all the new stuff in. I shall definitely update more once things calm down again. :-) (Started doing that anyway)

Oh, and the iPad release is coming as well of course!! We may or may not somehpw plug mods into that eventually, cant say at this stage, but if we do it will be pretty cool. We got some ideas on how we can include community efforts in the future but it is too early to share ideas. Keep an eye on the forum though!

R


Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Experimental Lab
« Reply #13 on: November 30, 2011, 01:13:25 AM »
Yea, I come back every now and then, but real life happens too. No programming for me. :(

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #14 on: November 30, 2011, 05:28:20 AM »
Well that is very good news if the NEW PC version will be modable like the current version, but I believe that the "old", or current, version will naturally be less popular as time goes on and particularly once the "new" PC version is released.  If the current mods and user-made maps are not easily transferable to the new PC version, then I for one would prefer to wait and make maps for the new version rather than spend time working on the old one.

This is all very exciting for all of us who love Eufloria and would like the whole world to enjoy it. Strictly addressing the map and mod-making community aspects, however, I personally will wait and see how the new PC version develops before continuing to invest my time in those endeavors. Besides, I'll need someone like Annikk to simplify any new programming language with another Beginner's Guide!                                                                                                            

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Experimental Lab
« Reply #15 on: November 30, 2011, 05:46:00 PM »
It'll be Lua still, just a very feature-poor version, at least at release. It has been said that they'll put most/all of the Lua stuff back, so...

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Experimental Lab
« Reply #16 on: November 30, 2011, 09:11:16 PM »
Number of Eufloria owners has gone up by 25000 at the the timee of this post, and will go up a fair bit more over the next few days :D
http://www.indieroyale.com/


Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #17 on: February 11, 2012, 10:15:22 AM »
Bored?

Here are some program samples that I think are fun to tweak and play with.

They are basically the same, with only one variable changed from positive to negative, but with very different-looking results. (One is a hybrid of the other two.)

I chose the names based on what I thought they looked like.

The default colors are kind've dark so it might look better in a dark room.
« Last Edit: February 14, 2012, 04:35:52 AM by Lost Seedling »

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #18 on: May 17, 2012, 02:50:32 PM »
Here's a fun little program to pass a few minutes of your time while making some interesting patterns with your mouse.
« Last Edit: May 18, 2012, 02:53:51 AM by Lost Seedling »

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #19 on: May 17, 2012, 10:56:11 PM »

Oh, and the iPad release is coming as well of course!! We may or may not somehow plug mods into that eventually, cant say at this stage, but if we do it will be pretty cool. We got some ideas on how we can include community efforts in the future but it is too early to share ideas. Keep an eye on the forum though!

R



I know this was made before the iPad release, but I've already modded my own levels for iPad, but yeah, would love to be able to just have a sub forum just for ios user levels and what, and in the game you can download the .lua file from the post, or integrate a download page with top 10 most played levels, top 10 best rated levels, etc... Would love to see that for me and the iOS lovers of this game


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #20 on: May 17, 2012, 11:16:40 PM »
It shouldn't be too bad to get a level to run on all platforms.

Maybe we can test this stuff at some point Tom :>  I'll make random test levels with lots of different commands, and send to you... then you can test whether they work or not. :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #21 on: May 17, 2012, 11:27:31 PM »
Sure Annikk, I'd be happy too, And also I might need to give you some code from my level to test out, on PC, because the number of iPad users for this game is slack. You'd probably have to change WaitReal() to something else though

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #22 on: May 17, 2012, 11:32:20 PM »
I think you should do your delays using something other than WaitReal()...  since there are loads of different ways to create a delay, and as far as I'm aware, WaitReal() is the only one that is iOS-specific..

If I do some awesome example guides to show you how to create a series of delays, would that be helpful? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #23 on: May 17, 2012, 11:39:48 PM »
You could if you wanted, but if it's iOS specific, and I'm using iOS, shouldn't i be using the iOS version? :P I mean, Alex must have created it for a reason?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #24 on: May 17, 2012, 11:43:51 PM »
I think it's there so you know whether you can/should be using commands that relate specifically to that platform, such as touch related commands.

Maybe there is a special set of UI buttons that only appears in the iPad version or something; you could do something like:

Code: [Select]
if IsiOS() then
   hide iOS-specific buttons
end


However you could make levels that are playable on both platforms..  surely that is better, because then it increases your potential audience size? :>

I sent you a level the other night to test your screen move thing.  That worked on your iPad, didn't it? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #25 on: May 17, 2012, 11:47:05 PM »
It worked but I had to change the globals, but if you completely take out goobals in a level, there is a default.lua file that inputs the defaults into your level

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #26 on: May 18, 2012, 12:58:05 AM »
I wonder if we can do something like:

Code: [Select]
if IsiOS() ~= nil then
-- the function IsiOS() is recognised so we must be running on iOS
else
-- the function IsiOS() wasn't recognised, so we must be running on PC/Mac
end


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #27 on: May 18, 2012, 01:12:38 AM »
Nope, that didn't work.


This works for me:

Code: [Select]
function IsiOS()

return false

end

function LevelLogic()

if IsiOS() == false then
MessageBox("PC/Mac detected")
else
MessageBox("iOS detected")
end

end

Can you check that code on iPad Tom? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #28 on: May 18, 2012, 01:36:31 AM »
Sure, my dad has stolen my iPad at the moment, but later on I will be able to do it :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #29 on: May 18, 2012, 01:47:30 AM »
Ok, cool :>


If it works, you should get a message saying "iOS detected".

If it doesn't work, it will either crash, or display "PC/Mac Detected"

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #30 on: May 18, 2012, 01:51:38 AM »
Found this for you.

Code: [Select]
function WaitReal(t)
t = t + GetRealTime()
while GetRealTime() < t do
CheckConditions()
coroutine.yield()
end
end


function WaitGame(t)
t = t + GetGameTime()
while GetGameTime() < t do
CheckConditions()
coroutine.yield()
end
end

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #31 on: May 18, 2012, 02:56:04 AM »
You might like this :D The only is now everything with iOS() related doesn't work haha, But thats what you wanted, right?




Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #32 on: May 18, 2012, 03:05:30 AM »
Just thought i'd give you a little update on what you're code actually did.

It seems that the code

Code: [Select]
function IsiOS()

return false

end

Actually saved the IsiOS() state throughout the whole game(THE WHOLE GAME, EVERY LEVEL). I deleted all your code from my level, then put it onto my iPad, but nothing worked still, after just having a 20 second "Uh-Oh" i decided to put

Code: [Select]
function IsiOS()

return true

end

Into my level, which made everything worked again, I took out the code again and it saved it, so it seems that the game checks if IsiOS() is true, then if it is, every IsiOS() function will work, but if not, bye bye IsiOS()

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #33 on: May 18, 2012, 03:26:06 AM »
Sometimes the game saves values between levels - to fix, close Eufloria then reopen it.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #34 on: May 18, 2012, 05:39:51 AM »
to cross platform a level,  I guess you could do this for the globals

Code: [Select]
if IsiOS() then

Globals():Get("Game"):Set("EnemyFactionsMin",0)
Globals():Get("Game"):Set("EnemyFactionsMax",1)

else

Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(1)

end

That would work right?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #35 on: May 18, 2012, 06:32:49 AM »
Herein lies the crux of the problem.  If you run this command on a PC:

Code: [Select]
if IsiOS() then
Then the level will crash!


We need to find a way to figure out if we're on PC or iOS, other than using this command...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #36 on: May 18, 2012, 06:34:42 AM »
Or wait... does it ?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #37 on: May 18, 2012, 06:36:00 AM »
Actually.....  maybe it does work...


Hold on a second. :>  Let me do a proper test.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #38 on: May 18, 2012, 06:42:24 AM »
I don't know why it would crash?

I can put something like asdifjsuas() in my level, and it won't crash, even if I havn't defined it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #39 on: May 18, 2012, 06:44:08 AM »
Code: [Select]
function LevelSetup()

-- Set Global Values
if IsiOS() then

Globals():Get("Game"):Set("Asteroids",0)
Globals():Get("Asteroids"):Set("MinSendDistance",0.5)
Globals():Get("Asteroids"):Set("MaxSendDistance",0.5)
Globals():Get("Game"):Set("EnemyFactionsMin",1)
Globals():Get("Game"):Set("EnemyFactionsMax",1)
Globals():Get("Game"):Set("GreysProbability",0)
Globals():Get("AI"):Set("GraceTimer",99999)
Globals():Get("Structures"):Set("FlowerProbability",0.015)
Globals():Get("Asteroids"):Set("MinCoreHealth",150)
Globals():Get("Asteroids"):Set("MaxCoreHealth",300)
Globals():Get("Asteroids"):Set("SpawnCap",100)
Globals():Get("Asteroids"):Set("SeedlingCap",5000)

else

Globals.G.Asteroids=(0)
Globals.Asteroids.MinSendDistance=0.5
Globals.Asteroids.MaxSendDistance=0.5
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(1)
Globals.G.GreysProbability=0
Globals.AI.GraceTimer=(99999)
Globals.Structures.FlowerProbability=(0.015)
Globals.Asteroids.MinCoreHealth=150
Globals.Asteroids.MaxCoreHealth=300
Globals.Asteroids.SpawnCap=100
Globals.Asteroids.SeedlingCap=5000

end


t = 1600

coordx = {}
coordy = {}
roidradius = {}

roidnumber = 31


for i=0,roidnumber do

x = math.cos(t) * t
y = math.sin(t) * t

s = math.random(3,10) / 10
e = math.random(4,10) / 10
sp = math.random(5,10) / 10

roidradius[i] = 175 + ((i / 21) * (500 * ((s + e + sp) / 3)))

a = AddAsteroidWithAttribs(x,y,e,s,sp)
a.Owner = 2
a.TreeCap = 4
a:SetRadius(roidradius[i])
a:Reveal(2)
a:Reveal(1)




a.Moveable = False



coordx[i] = x
coordy[i] = y



t = t + 294.5

a.SendDistance = (roidradius[i] * 7) + 1500


end

a = GetAsteroid(roidnumber - 16)
a:AddSeedlings(150)




a = GetAsteroid(0)
a.Owner = 1

a.Moveable = False


a = GetAsteroid(27)
a.Owner = 1

a.Moveable = False
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()

s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s:LevelUp()
--f = s:AddFlower()
a:AddSeedlings(75)

SetCameraZoomNow(0.01)

rcolour = 0
SetBackdropColour(0,0,0)

endfinal = false

finality = false

dangertimer = {}




for dset = 0,roidnumber do
dangertimer[dset] = GetGameTime() - 90
end

danger = {}

torchlit = {}

constructionmetric = {}


gathermetric = {}

gatherexists = 0


gatherpoint = GetAsteroid(0)

end






function LevelLogic()

SetCameraPosition(((coordx[27] * -1) + 500),((coordy[27] * -1) + 500))
SetCameraZoom(4.8)

GetAsteroid(0):ChangeOwner(2)

purgetimer = GetGameTime()

while GameRunning() do


if rcolour > 0 then
rcolour = rcolour - 1
end

SetBackdropColour(rcolour,0,0)

if GetEmpire(1):GetNumOwnedAsteroids() == 0 then


Quit(false)

end

if GetEmpire(2):GetNumOwnedAsteroids() == 0 then

Pause()
MessageBox("you have won.")
WaitDialog()
Unpause()
Quit(true)
end

--AI

checkedroid = GetAI(2):GetRandomAsteroid()


if GetGameTime() > purgetimer + 35 then
purgetimer = 0
end



-- First, find out which asteroids are close enough to travel in 1 jump, and

traversable = {}
pathsavailable = 0

attackable = {}
attackpaths = 0

actiontaken = 0

increasemetricvote = 1
increasegathermetricvote = 1
confirmedzero = 0
confirmedgatherpoint = 0



if GetEmpire(2):OwnsAsteroidID(checkedroid.ID) then

if checkedroid:GetNumSeedlings(1) == 0 and checkedroid:GetNumSeedlings(2) > 5 then
for minecheck = 0,roidnumber do

if GetEmpire(2):OwnsAsteroidID(minecheck) == true and GetAsteroid(minecheck):GetNumMines(1) > 0 and checkedroid:GetNumMines(1) == 0 then
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),GetAsteroid(minecheck))
end

end

end

for u = 0,roidnumber do

if GetAsteroid(u) ~= checkedroid then
-- only learn about this asteroid if it's not the one being checked
-- can we send seeds to this roid from the checked one?
if (GetAsteroid(checkedroid.ID):GetSendDistance() + roidradius[u]) > math.sqrt(((coordx[u] - coordx[checkedroid.ID])^2) + ((coordy[u] - coordy[checkedroid.ID])^2)) then
-- we can !  Now is this a friendly path or an attackable path?
if GetEmpire(1):OwnsAsteroidID(u) == true or GetAsteroid(u):GetNumSeedlings(1) > 10 and GetAsteroid(u):GetNumTrees() == 0 then
attackable[attackpaths] = GetAsteroid(u)
attackpaths = attackpaths + 1

-- moar aggression ! advantage pressing, etc
if checkedroid:GetNumSeedlings(2) > 120 and GetAsteroid(u):GetNumSeedlings(1) < (checkedroid:GetNumSeedlings(2) / 2) then
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),GetAsteroid(u))
if rcolour < 105 then
rcolour = rcolour + 150
end
end
end

if GetAI(2):OwnsAsteroidID(u) == true then

traversable[pathsavailable] = GetAsteroid(u)
pathsavailable = pathsavailable + 1
end

end

-- ok, this roid is not in range for us.






end
-- ok, we were trying to check ourselves.





end
-- end of neighbour-checking sequence









-- end of metric checking sequence

else

torchlit[checkedroid.ID] = nil
constructionmetric[checkedroid.ID] = nil
gathermetric[checkedroid.ID] = nil

end













-- we have selected "checkedroid" for checking.  We must find out all we can about the asteroid and it's surroundings, and act appropriately.
if GetAI(2):OwnsAsteroidID(checkedroid.ID) == true and checkedroid:GetNumMines(1) > 0 then

-- do buggerysquat.


elseif GetAI(2):OwnsAsteroidID(checkedroid.ID) == true then
-- this roid is ours ! :>


if pathsavailable == 0 then
-- Orphan Control
boltfriendly = GetEmpire(2):GetRandomAsteroid()
letsgo = 0

for iii = 0,attackpaths do

if attackable[iii] ~= nil then
letsgo = letsgo + (attackable[iii]:GetNumSeedlings(1))
end

end

if letsgo > checkedroid:GetNumSeedlings(2) and checkedroid:GetNumSeedlings(2) > 10 and checkedroid:GetNumSeedlings(2) < 39 then

checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),boltfriendly)


elseif letsgo < checkedroid:GetNumSeedlings(2) and checkedroid:GetNumSeedlings(2) > (39 + (attackable[0]:GetNumDysonTrees() * 5) + (attackable[0]:GetNumDefenseTrees() * 15)) then

checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),attackable[0])
if rcolour < 105 then
rcolour = rcolour + 150
end


elseif attackable[0]:GetNumSeedlings(2) > 5 then

checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),attackable[0])


end


end
-- how many player seedlings are here?

-- more than what we have, and enough to be dangerous.  Also, we do have at least 1 tree here, right?
if checkedroid:GetNumSeedlings(2) < checkedroid:GetNumSeedlings(1) and checkedroid:GetNumSeedlings(1) > 10 and checkedroid:GetNumTrees() > 0 then
-- *** WE OWN THIS ASTEROID, THE ENEMY OUTNUMBER US.  WE HAVE AT LEAST ONE TREE HERE.  We are under attack.  torchmetric 0! ***
torchlit[checkedroid.ID] = 0
-- ***

-- elseif checkedroid:GetNumSeedlings(2) < checkedroid:GetNumSeedlings(1) and checkedroid:GetNumSeedlings(1) > 10 and checkedroid:GetNumTrees() == 0 then
-- *** ITS A FALSE ALARM....but dont try to build here unless the player leaves. ***
--torchlit[checkedroid.ID] = nil
--constructionmetric[checkedroid.ID] = nil
-- but once we get a bit more powerful, we can have a crack at it :>


-- if purgetimer == 0 then
-- purgetimer = GetGameTime() + 30
-- end

-- if GetGameTime() > purgetimer then


-- torchlit[checkedroid.ID] = 0

--for purge = 0,roidnumber do
-- if GetEmpire(2):OwnsAsteroidID(purge) == true and torchlit[purge] == nil and GetGameTime() > purgetimer + 45 then

--GetAsteroid(purge):SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(1),checkedroid)


-- if rcolour < 105 then
-- rcolour = rcolour + 150
-- end
-- end

-- end

-- purgetimer = 0

-- end

-- ***
end


--  more than zero but less than what we have
if checkedroid:GetNumSeedlings(1) > 0 and checkedroid:GetNumSeedlings(2) > checkedroid:GetNumSeedlings(1) then
-- *** WE OWN THIS ASTEROID, THERE ARE ENEMIES BUT WE OUTNUMBER THEM.  Not elligible for sending reinforcements to other asteroids, but not in serious danger either. ***
-- ***
end

-- No enemies here at all.
if checkedroid:GetNumSeedlings(1) < 1 then

-- how many of our seedlings are here?
if checkedroid:GetNumSeedlings(2) > 1 then
-- 1 or more


--how many trees are here?
if checkedroid:GetNumTrees() < 4 and checkedroid:GetNumSeedlings(2) > 9 then
-- less than four trees
-- *** WE OWN THIS ASTEROID, THERE ARE NO ENEMIES HERE.  WE HAVE AT LEAST 10 SEEDLINGS AND LESS THAN 4 TREES.  Plant a tree. ***


-- but... is the enemy building up a force nearby, ready to take our freshly built trees..?

danger[checkedroid.ID] = false

for ooo = 0,roidnumber do
if GetEmpire(1):OwnsAsteroidID(ooo) and GetAsteroid(ooo):GetSendDistance() > math.sqrt(((coordx[ooo] - coordx[checkedroid.ID])^2) + ((coordy[ooo] - coordy[checkedroid.ID])^2)) then

if GetAsteroid(ooo):GetNumSeedlings(1) > 35 then

danger[checkedroid.ID] = true
dangertimer[checkedroid.ID] = GetGameTime()

end

end
end

if danger[checkedroid.ID] == true and checkedroid:GetNumSeedlings(2) > 15 then

checkedroid:PlantDysonTree(2)

elseif danger[checkedroid.ID] == false and GetGameTime() > dangertimer[checkedroid.ID] + 30 then

checkedroid:PlantDysonTree(2)

end
-- ***



elseif checkedroid:GetNumTrees() == 4 then
-- four trees.  ELLIGIBLE FOR SENDING REINFORCEMENTS!

if constructionmetric[checkedroid.ID] == 0 then
-- we just built the last tree.  now we should stop advertising to neighbours that we need more seedlings for construction.
constructionmetric[checkedroid.ID] = nil
end


-- is my torch metric nil?

if torchlit[checkedroid.ID] ~= nil then
-- no, my torch metric is not Nil.

-- is my torch metric 0?  Cause, like, I don't have any enemies orbiting me dudez...
if torchlit[checkedroid.ID] == 0 then
-- *** ok, so my torch metric is 0 but there are no enemies here.  Switch all torches off....if other roids are under attack they will just switch theirs on again straight away. ***
-- *** this step is needed to prevent the rest of the torch metrics from spiralling upward out of control.  ***
for g = 0,roidnumber do
torchlit[g] = nil
end
-- ***
else

-- so my torch IS lit, but it's value is NOT zero.  checkedroid is not nil and not 0.

totm = true

for ooo = 0,pathsavailable do

if traversable[ooo] ~= nil then

trav = traversable[ooo]

hopIDint = trav.ID

if torchlit[hopIDint] == 0 and GetGameTime() < 180 then

for emerg = 0,roidnumber do
if GetEmpire(2):OwnsAsteroidID(emerg) == true then
GetAsteroid(emerg):SendSeedlingsToTarget(2,GetAsteroid(emerg):GetNumSeedlings(2),traversable[ooo])
end
end

totm = false


elseif torchlit[hopIDint] == 0 then
-- *** WE HAVE FOUND A NEIGHBOUR THAT HAS A ROUTE TO AN ASTEROID IN NEED OF DEFENCE.  Send seedlings ***

if GetAsteroid(hopIDint):GetNumSeedlings(1) < 10 then
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),traversable[ooo])

elseif GetAsteroid(hopIDint):GetNumSeedlings(2) > GetAsteroid(hopIDint):GetNumSeedlings(1) * 0.6 then
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),traversable[ooo])


elseif checkedroid:GetNumSeedlings(2) > (GetEmpire(2).NumSeedlings / 20) then
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),traversable[ooo])
end

totm = false
torchlit[checkedroid.ID] = 1

-- elseif torchlit[checkedroid.ID] == nil then

-- totm = false
-- torchlit[checkedroid.ID] = torchlit[hopIDint] + 1
-- shortestpath = hopIDint


elseif torchlit[hopIDint] == nil then

-- do nothing, maybe there's no more attack and the metric should be turned off.



-- my torch metric is already non-nil, so set mine to be his + 1 if he has a shorter path than me.
elseif torchlit[hopIDint] < torchlit[checkedroid.ID] - 1 then
totm = false
torchlit[checkedroid.ID] = torchlit[hopIDint] + 1
shortestpath = hopIDint
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),traversable[ooo])


elseif torchlit[hopIDint] == torchlit[checkedroid.ID] - 1 then

totm = false
torchlit[checkedroid.ID] = torchlit[hopIDint] + 1
shortestpath = hopIDint
checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),traversable[ooo])



end

end
end







-- *** WE OWN THIS ASTEROID.  THERE ARE NO ENEMIES HERE.  WE HAVE AT LEAST 10 SEEDLINGS AND MAXIMUM TREES.  OUR TORCH METRIC INDICATES ***
-- *** THAT A NEARBY ASTEROID REQUIRES SEEDLINGS FOR DEFENSE.  Find a neighbour with the lower metric and send 10 seedlings there.  ***



end



elseif torchlit[checkedroid.ID] == nil then

-- yes my torch metric is nil, now lets see if any neighbours have a torch metric of 0..

totm = true



for ooo = 0,pathsavailable do

if traversable[ooo] ~= nil then

trav = traversable[ooo]

hopIDint = trav.ID



if torchlit[hopIDint] == 0 then
-- *** WE HAVE FOUND A NEIGHBOUR THAT NEEDS MORE SEEDS TO DEFEND WITH.  Send 10 seedlings, or more if we have them available. ***
checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),traversable[ooo])
totm = false
torchlit[checkedroid.ID] = 1



elseif torchlit[hopIDint] ~= nil then
if torchlit[hopIDint] > 0 then
-- seedlings needed in this direction!

-- my torch metric is nil at the moment, so set it to his + 1.
if torchlit[checkedroid.ID] == nil then
totm = false
torchlit[checkedroid.ID] = torchlit[hopIDint] + 1
shortestpath = hopIDint
end

-- my torch metric is already non-nil, so set mine to be his + 1 if he has a shorter path than me.
if torchlit[hopIDint] < torchlit[checkedroid.ID] - 1 then
totm = false
torchlit[checkedroid.ID] = torchlit[hopIDint] + 1
shortestpath = hopIDint
end



end



end

end
end

-- send seeds along the shortest torch path
if torchlit[checkedroid.ID] ~= nil then
if torchlit[checkedroid.ID] > 1 then

checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),GetAsteroid(shortestpath))
end
end

if totm == true and torchlit[checkedroid.ID] ~= nil then
torchlit[checkedroid.ID] = nil
end


-- check if we are still under attack on any asteroids
stillattacked = false

for o = 0,roidnumber do
if GetAsteroid(o):GetNumTrees() > 0 and GetAI(2):OwnsAsteroidID(o) and GetAsteroid(o):GetNumSeedlings(1) > 1 then
stillattacked = true
end
end

if stillattacked == false then
for l = 0,roidnumber do
torchlit[l] = nil
end
end



-- yes, my torch metric is Nil and so is all my neighbours' - check my construction metric next.

-- turn off construction metric
tocm = true

for cc = 0,pathsavailable do

if traversable[cc] ~= nil then

trav = traversable[cc]

hopIDint = trav.ID

if constructionmetric[hopIDint] == 0 and danger[checkedroid.ID] == false and GetGameTime() > (dangertimer[checkedroid.ID] + 90) and GetAsteroid(hopIDint):GetNumSeedlings(1) < 8 then
-- *** WE HAVE FOUND A NEIGHBOUR THAT NEEDS MORE SEEDS TO BUILD WITH.  Send 10 seedlings, or more if we have them available. ***
checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),traversable[cc])
tocm = false
constructionmetric[checkedroid.ID] = 1


elseif danger[checkedroid.ID] == true or GetGameTime() < (dangertimer[checkedroid.ID] + 90) then

-- *** WAIT A BIT... THERE'S STILL A BIG FORCE NEARBY ***

tocm = false
constructionmetric[checkedroid.ID] = 1




elseif constructionmetric[hopIDint] ~= nil then
if constructionmetric[hopIDint] > 0 then
-- seedlings needed in this direction!

-- my construction metric is nil at the moment, so set it to his + 1.
if constructionmetric[checkedroid.ID] == nil then
tocm = false
constructionmetric[checkedroid.ID] = constructionmetric[hopIDint] + 1
shortestpath = hopIDint
end

-- my construction metric is already non-nil, so set mine to be his + 1 if he has a shorter path than me.
if constructionmetric[hopIDint] < constructionmetric[checkedroid.ID] - 1 then
tocm = false
constructionmetric[checkedroid.ID] = constructionmetric[hopIDint] + 1
shortestpath = hopIDint
end



end



end

end
end

-- send seeds along the shortest construction path
if constructionmetric[checkedroid.ID] ~= nil then
if constructionmetric[checkedroid.ID] > 1 then

checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),GetAsteroid(shortestpath))
end
end

if tocm == true and constructionmetric[checkedroid.ID] ~= nil then
constructionmetric[checkedroid.ID] = nil
end


-- check if we are finished building trees on all asteroids
stillbuilding = false

for o = 0,roidnumber do
if GetAsteroid(o):GetNumTrees() < 4 and GetAI(2):OwnsAsteroidID(o) then
stillbuilding = true
end
end

if stillbuilding == false then
for l = 0,roidnumber do
constructionmetric[l] = nil
end
end


end

-- ok, we didn't hit on torch metric or construction metric.  So lets do some gathering instead.

if torchlit[checkedroid.ID] == nil and constructionmetric[checkedroid.ID] == nil and GetGameTime() > 60 then
-- is there already a gather point?
-- gatherexists = 0
gathertrue = false
for h = 0,roidnumber do
if gathermetric[h] == 0 then
gatherexists = 1
gathertrue = true
end
end

if gathertrue == false then
gatherexists = 0
end


-- there's no gather point at the moment.
if gatherexists == 0 then


-- ok, is there at least one player-owned asteroid and one traversable asteroid within my send distance?
if pathsavailable > 0 and attackpaths > 0 then
-- yep.
-- *** THEN I'M THE NEW GATHER POINT!! Bringin all the seedlings to the yard, y0. ***
gathermetric[checkedroid.ID] = 0
gatherexists = 1

-- MessageBox("new gather point")
--MessageBox(checkedroid.ID)


else
-- nope.



-- *** I CAN'T BE THE GATHER POINT because I am totally surrounded by either all friendly neighbours or all enemy asteroids. ***

end




-- a gather point already exists.
elseif gatherexists == 1 then

-- Am I the gather point?

if gathermetric[checkedroid.ID] == 0 then
-- I AM the gather point! :>

-- is there still at least 1 player asteroid and 1 friendly asteroid nearby?
--validpath = 0
--validattack = 0
--for i = 0,pathsavailable do
-- if traversable[i] ~= nil then
-- travv = traversable[i]
-- travvy = travv.ID

-- if GetAI(2):OwnsAsteroidID(travvy) == true then
-- there's at least one friendly asteroid nearby.
-- validpath = 1
-- end

-- if GetAI(2):OwnsAsteroidID(travvy) == false then
-- there's at least one player asteroid nearby.
-- validattack = 1
-- end
-- end
--end

if attackpaths > 0 and pathsavailable > 0 then
-- yes, there's at least 1 friendly and 1 enemy asteroid nearby.


-- add up all the player seedlings in the nearby enemy systems.  Do I have at least that, plus 50?

totalseeds = 50
currentlowest = 9000
attackpaths = attackpaths - 1
for j = 0,attackpaths do

totalseeds = totalseeds + attackable[j]:GetNumSeedlings(1)

-- this bit checks which of the asteroids has the lowest number of seedlings.
if attackable[j]:GetNumSeedlings(1) < currentlowest then
currentlowest = attackable[j]:GetNumSeedlings(1)
RAPETARGET = attackable[j]
end



end



-- "if i have more seeds than the enemy does, then..."
if checkedroid:GetNumSeedlings(2) > totalseeds + (RAPETARGET:GetNumDysonTrees() * 5) + (RAPETARGET:GetNumDefenseTrees() * 23) then

checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),RAPETARGET)

if rcolour < 105 then
rcolour = rcolour + 150
end

--MessageBox("Rape time!")
-- *** RAEP TIEM!!!"!"

elseif checkedroid:GetNumSeedlings(2) > 400 then
-- if i have silly numbers of seeds, just gogo anyway.

checkedroid:SendSeedlingsToTarget(2,checkedroid:GetNumSeedlings(2),RAPETARGET)

if rcolour < 105 then
rcolour = rcolour + 150
end


else
-- *** Hold, precious... we have not enough seeds yet to launch an attack... ***






-- ***
end

-- this bit checks if we have a "Cold War" situation on our hands - if so, we'd be better off moving to a different gather point with less player defenses nearby.
-- if totalseeds > 300 and totalseeds > checkedroid:GetNumSeedlings(2) and GetEmpire(1):GetNumOwnedAsteroids() > attackpaths + 1 then
-- MessageBox("ColdWar Detected - reset gather point")
-- for gathreset = 0,roidnumber do
-- gathermetric[gathreset] = nil
-- end
-- gatherexists = 0
-- end

else
-- *** I AM NO LONGER A SUITABLE GATHER POINT.  RESET ALL GATHER POINTS
for r = 0,roidnumber do
gathermetric[r] = nil

end
gatherexists = 0
-- ***

end

else
-- I am not the gather point. :<
-- so send some seedlings to whichever traversable asteroid has the lowest gather metric.

-- ADD SOEM CODE HERE DRUIDS

if gathermetric[checkedroid.ID] ~= nil then
-- no, my gather metric is not Nil.
-- so my torch IS lit, but it's value is NOT zero.

for ddd = 0,pathsavailable do

if traversable[ddd] ~= nil then

trav = traversable[ddd]

hopIDint = trav.ID

if gathermetric[hopIDint] == 0 then
-- *** WE HAVE FOUND A NEIGHBOUR THAT HAS A ROUTE TO AN ASTEROID IN NEED OF SEEDS.  Send 10 seedlings, or more if we have them available. ***
checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),traversable[ddd])

gathermetric[checkedroid.ID] = 1

electiontimer = GetGameTime()



elseif gathermetric[hopIDint] ~= nil then
if gathermetric[hopIDint] > 0 then
-- both checkedroid and the neighbour we are looking at have a gather metric set.  Also, the neighbour has a metric of at least 1.
-- seedlings needed in this direction!


-- my gather metric is already non-nil, so set mine to be his + 1 if he has a shorter path than me.
if gathermetric[hopIDint] < gathermetric[checkedroid.ID] - 1 then

gathermetric[checkedroid.ID] = gathermetric[hopIDint] + 1
shortestpath = hopIDint


elseif gathermetric[hopIDint] == gathermetric[checkedroid.ID] - 1 then

if shortestpath == nil then
shortestpath = hopIDint
end

if gathermetric[shortestpath] ~= nil then
if gathermetric[hopIDint] < gathermetric[shortestpath] then
shortestpath = hopIDint
end
end

end






end



end

end


end

checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),GetAsteroid(shortestpath))


-- *** WE OWN THIS ASTEROID.  THERE ARE NO ENEMIES HERE.  WE HAVE AT LEAST 10 SEEDLINGS AND MAXIMUM TREES.  OUR TORCH METRIC INDICATES ***
-- *** THAT A NEARBY ASTEROID REQUIRES SEEDLINGS FOR DEFENSE.  Find a neighbour with the lower metric and send 10 seedlings there.  ***

elseif gathermetric[checkedroid.ID] == nil then

-- yes my gather metric is nil, now lets see if any neighbours have a gather metric of 0..



for ddd = 0,pathsavailable do

if traversable[ddd] ~= nil then

trav = traversable[ddd]

hopIDint = trav.ID

if gathermetric[hopIDint] == 0 then
-- *** WE HAVE FOUND A NEIGHBOUR THAT IS A GATHER POINT.  Send 10 seedlings, or more if we have them available. ***
checkedroid:SendSeedlingsToTarget(2,((checkedroid:GetNumSeedlings(2)/pathsavailable) + 10),traversable[ddd])

gathermetric[checkedroid.ID] = 1

elseif gathermetric[hopIDint] ~= nil then
if gathermetric[hopIDint] > 0 then
-- seedlings needed in this direction!

-- my gather metric is nil at the moment, so set it to his + 1.

if shortestpath == nil then
shortestpath = hopIDint
end

gathermetric[checkedroid.ID] = gathermetric[hopIDint] + 1


end



end

end
end



end




end

end


end

end

end





-- how many of our seedlings are here?
if checkedroid:GetNumSeedlings(2) < 10 then
-- 9 or less

-- how many trees are here?
if checkedroid:GetNumTrees() < 4 then
-- less than four trees

-- *** WE OWN THIS ASTEROID, THERE ARE NO ENEMIES HERE.  WE HAVE LESS THAN 10 SEEDLINGS AND LESS THAN 4 TREES.  We need seedlings for more trees!  Advertise to neighbours that we need some.
constructionmetric[checkedroid.ID] = 0

-- ***
end


if checkedroid:GetNumTrees() == 4 then
-- four trees
-- constructionmetric[checkedroid.ID] = nil
-- *** WE OWN THIS ASTEROID, THERE ARE NO ENEMIES HERE.  WE HAVE LESS THAN 10 SEEDLINGS AND MAXIMUM TREES.  Wait until we have more seedlings before we can reinforce.


end

end






end







else
-- *** THIS ROID IS NOT OURS, it's a PLAYER asteroid!!  Do nothing with it.  :> ***

-- ***
end

if GetEmpire(1):GetNumOwnedAsteroids() < 4 and GetEmpire(2).NumSeedlings > 800 and finality == false then
finality = true
for doom = 0,roidnumber do
if GetEmpire(2):OwnsAsteroidID(doom) then
GetAsteroid(doom):SendSeedlingsToTarget(2,GetAsteroid(doom):GetNumSeedlings(2),GetEmpire(1):GetRandomAsteroid())
end
end
end



if electiontimer ~= nil then
if GetGameTime() > electiontimer + 45 then
-- we haven't managed to send any seedlings to a gather point for 45 seconds now.  Lets try resetting all the gather metrics to trigger a new gather point election.
for greset = 0,roidnumber do
gathermetric[greset] = nil

end
--MessageBox("Due to low activity a new gather point election was held")
-- lets see if this helps, and seeds now start moving towards the gather point.  if it doesn't, hold a new gather point election in 15 seconds.
electiontimer = electiontimer + 45
gatherexists = 0

end

end


gatherzero = false

for gatherzerocheck = 0,roidnumber do
if gathermetric[gatherzerocheck] == 0 then
gatherzero = true
end
end


if gatherzero == false then
gatherexists = 0
end



if GetEmpire(2).NumSeedlings > 1200 and GetEmpire(2):GetNumOwnedAsteroids() > roidnumber / 2 and endfinal == false then
endfinal = true
for final = 0,roidnumber do

if GetEmpire(2):OwnsAsteroidID(final) then

GetAsteroid(final):SendSeedlingsToTarget(2,GetAsteroid(final):GetNumSeedlings(2),GetEmpire(1):GetRandomAsteroid())

end
end
end


coroutine.yield()

end







end


function OnAsteroidTaken(id,owner)

if owner == 1 then
for reset = 0,roidnumber do
gathermetric[reset] = nil
end
gatherexists = 0
return
end

if owner == 2 then
for reset = 0,roidnumber do
gathermetric[reset] = nil
end
gatherexists = 0
return
end

end


Does this level load on ipad? :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Experimental Lab
« Reply #40 on: May 18, 2012, 06:46:21 AM »
Lua has a function pcall(X), for protected call. Try something like

Code: [Select]
var OnIPad = false

if pcall(IsiOS) then
 OnIPad = true
else
 OnIPad = false
end

That will set OnIPad to true if there are no problems in running the function IsiOS. If there are problems (such as it not being defined) it will set the value to false.

http://www.lua.org/pil/8.4.html

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #41 on: May 18, 2012, 06:52:04 AM »
This is what the level looks like that you just gave me Annikk.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #42 on: May 18, 2012, 08:53:19 AM »
Can you scroll around?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #43 on: May 18, 2012, 06:12:43 PM »
Yeah I can do everything :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #44 on: May 18, 2012, 06:34:22 PM »
Does the enemy colonise asteroids, build an empire, and ultimately attack you?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #45 on: May 18, 2012, 07:51:58 PM »
There's only one asteroid, and that's the one you see haha

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #46 on: May 18, 2012, 08:15:49 PM »
Strange.

How can there only be one asteroid?  The level declares dozens of them...


Don't suppose you'd be up for trying to work out which commands it is failing on? :>  That will help a lot to determine how we can make cross-compatible levels...

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #47 on: May 18, 2012, 08:26:03 PM »
I'll take a look through the code when my dads finished with laptop, but I'm guessing it's because there aren't any asteroids stated in level setup, just asteroid number = 20 or something like that

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #48 on: May 18, 2012, 08:36:18 PM »
I'll take a look through the code when my dads finished with laptop, but I'm guessing it's because there aren't any asteroids stated in level setup, just asteroid number = 20 or something like that

Yea, the "addAsteroidWithAttribs" command occurs inside a for loop, though... so it should be run a bunch of times, creating a bunch of asteroids.

You're probably right that it has something to do with it though..  perhaps the For loop is only being run once or something.


Are you totally sure it's just one asteroid?  When I load it on my PC, one asteroid is showing, and I can only scroll down.... scroll left, right, or up does not work.  That's because the camera starts as far north as you can currently see.  Once you scroll down a bit, you can then scroll in all directions again.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #49 on: May 18, 2012, 08:44:51 PM »
There is only one, kept look for another, it's definitely the for loop, I don't think I've seen one in any of the levels originally created. But I might not have looked so good.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #50 on: May 18, 2012, 08:53:06 PM »
Can you test if For loops in general work on iOS?


For example:


Code: [Select]
function LevelSetup()

end

function LevelLogic()

for i = 0,2
MessageBox("Fluffy")
end

end


That should produce 3 messageboxes...  does it? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #51 on: May 18, 2012, 08:55:20 PM »
If I had my IPad jailbroken, I'd be able to do all my editing on IPad, but it's not :/, have to wait till my dads done, he's watching stupid YouTube videos -_-

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #52 on: May 18, 2012, 09:25:19 PM »
Come to my house. :>  I have a spare laptop you can use..

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #53 on: May 18, 2012, 09:46:49 PM »
Paying for the plane ticket? Haha

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #54 on: May 18, 2012, 09:48:58 PM »
Laptop is now at my disposal though! So I will test your code :D

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #55 on: May 18, 2012, 09:51:26 PM »
Things changed fast, dad wants laptop again.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #56 on: May 18, 2012, 09:56:12 PM »
Paying for the plane ticket? Haha

My mate Smokey is a helicopter pilot, I'll have him come pick you up.
Can you climb a rope ladder? :>



(my mate Smokey really is a helicopter pilot but he doesn't have a helicopter of his own... and neither do I..  would have been cool though!)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #57 on: May 18, 2012, 10:07:02 PM »
All this for a Eufloria level test hahaha

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #58 on: May 18, 2012, 10:28:38 PM »
http://twolivesleft.com/Codea/

I just cried watching the beauty of that video on that site haha

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #59 on: May 18, 2012, 11:57:06 PM »
The Lastest code you asked me to test crashes the level man

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #60 on: May 19, 2012, 12:49:05 AM »
Whoops - I forgot a "do" :>


Code: [Select]
function LevelSetup()

end

function LevelLogic()

for i = 0,2 do
MessageBox("Fluffy")
end

end

How about that code?  It works on my PC.. :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #61 on: May 19, 2012, 01:46:01 AM »
Don't understand why I personally didn't see that

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #62 on: May 19, 2012, 01:47:29 AM »
I only get one messagebox haha

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #63 on: May 19, 2012, 01:59:43 AM »
Interesting..

I wonder if it doesn't support For loops.. or if it doesn't support stacked messageboxes.


How about this one?

Code: [Select]
function LevelSetup()

end

function LevelLogic()

x = 0

for i = 0,2 do
x = x + 1
end

MessageBox(x)

end

I got a messagebox with "3" in it.  What do you get? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #64 on: May 19, 2012, 02:04:39 AM »
Nothing happens now :/ but the level works

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #65 on: May 19, 2012, 03:31:20 AM »
Interesting.  So maybe iPad message boxes can't display variables.


Try this:

Code: [Select]
function LevelSetup()

end

function LevelLogic()

x = 0
MessageBox(x)

end

MessageBox works for you normally, right ?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #66 on: May 19, 2012, 03:59:04 AM »
MessageBox("hi my name is Tom") will display a box with the text MessageBox

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #67 on: May 19, 2012, 04:07:49 AM »
That code doesn't do anything Annikk :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #68 on: May 19, 2012, 08:47:01 AM »
Ok so iPad message boxes can't display variables. :>

Useful to know..

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #69 on: May 19, 2012, 08:53:11 AM »
This is off topic to our discussion but has anyone of this forum created a world Gravity,

As in, one massive planet, which would be a world. And then other smaller asteroids which move around that world, similar to your gravity suggestion, but a more defined path.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #70 on: May 19, 2012, 04:05:53 PM »
Look at annikk's mechanics, there is a gravity function there which allows you to create orbiting asteroids.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #71 on: May 20, 2012, 09:19:44 PM »
Gravity is a lot of fun to play around with.. :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #72 on: May 20, 2012, 09:33:20 PM »
Gravity doesn't work with IOS :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #73 on: May 20, 2012, 09:48:16 PM »
I wonder why not.

Maybe asteroids can't move on iOS?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #74 on: May 20, 2012, 09:56:44 PM »
Your Gravity-After.lua file on my iPad loads, and shows 4 Asteroids, but other than that, nothing.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #75 on: May 20, 2012, 10:04:13 PM »
Is there any way to open the console on iPad?


Also, have you tried stuff like removing the globals?  Obviously they won't work on iPad..

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #76 on: May 20, 2012, 10:46:56 PM »
Annikk, the LevelLogic stop running if it encounter a problem. It obvious that one of the functions used doesn't exist in the iOS version :)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #77 on: May 20, 2012, 10:48:41 PM »
There is a debug option in the support.lua, but when I change it from false to true, nothing happens

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #78 on: May 21, 2012, 12:16:12 AM »
Annikk, the LevelLogic stop running if it encounter a problem. It obvious that one of the functions used doesn't exist in the iOS version :)

I'm interested in which functions don't work.  I suspect GetAsteroid():MoveBy and MoveTo don't work at the moment.

It's a shame there's no way to open the console.  That would show error messages and helps a lot with debugging.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #79 on: May 21, 2012, 12:19:07 AM »
The main file is encrypted, tried getting into it

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #80 on: May 21, 2012, 06:24:17 PM »
Code: [Select]
function LevelSetup()

a = AddAsteroidWithAttribs(50,50,1,1,1)
a:SetRadius(180)
a.Owner = 1
a:Reveal(1)

a = AddAsteroidWithAttribs(400,400,1,1,1)
a:SetRadius(180)
a.Owner = 2
a:Reveal(1)

end

function LevelLogic()

x = 0
y = 0
scale = 1000
speed = 3

while GameRunning() do

input = GetGameTime() / speed

x = math.cos(input) * scale
y = math.sin(input) * scale

GetAsteroid(0):MoveTo(x,y)

coroutine.yield()
end

end

Try this level?  That's a good test for whether MoveTo works.. :>

If it works, you should be able to find one asteroid in the level that is floating around in circles.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #81 on: May 22, 2012, 09:51:51 PM »
I wish it did, but no the asteroid doesn't move :/

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #82 on: May 22, 2012, 10:54:50 PM »
Bummer.  No gravity on ipad yet then..
Thanks for testing it.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #83 on: May 22, 2012, 11:26:51 PM »
What about using Entity.Position.X/Y and changing them directly? I guess that'll work?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #84 on: May 22, 2012, 11:40:54 PM »
Wouldn't that bulk up the code though? If you wanted it smooth?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #85 on: May 23, 2012, 05:45:04 PM »
Good point Aino. :>


Code: [Select]
function LevelSetup()

a = AddAsteroidWithAttribs(50,50,1,1,1)
a:SetRadius(180)
a.Owner = 1
a:Reveal(1)

a = AddAsteroidWithAttribs(400,400,1,1,1)
a:SetRadius(180)
a.Owner = 2
a:Reveal(1)

end

function LevelLogic()

x = 0
y = 0
scale = 1000
speed = 3

while GameRunning() do

input = GetGameTime() / speed

x = math.cos(input) * scale
y = math.sin(input) * scale

GetAsteroid(0).position.x = x
GetAsteroid(0).position.y = y

coroutine.yield()
end

end

How about that? :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Experimental Lab
« Reply #86 on: May 23, 2012, 07:23:25 PM »
Nope, doesn't work haha, shows the same thing as last time, Two asteroids XD

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Experimental Lab
« Reply #87 on: May 23, 2012, 07:45:34 PM »
Yep so asteroid movement does not work on iPad.  Shame, hopefully that will be changed eventually.

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Drag and Drop Concept
« Reply #88 on: December 26, 2012, 05:31:01 AM »
I'm experimenting with an idea for a map, but am unsure if it is worth pursuing due to an early problem. I'd like some input.

I want to enable the player to drag and drop icons onto asteroids to affect the game-play. Unfortunately, I'm having performance issues with the icons failing to follow the cursor efficiently. I'm not sure if the problem is with my computer speed, my mouse, my code, or just a limitation with the game itself.

If anyone is interested, please run the attached sample and try dragging the spheres around and dropping them on the asteroid or anywhere. For me, in order for the icon to track smoothly, I have to move the cursor rather slowly, otherwise it "drops" the sphere, and I'm not sure if this limitation would be satisfactory for actual game-play. Please let me know how it works on your computer and if you think it is too slow or erratic to be practical. Ideally, the icon would follow the cursor regardless of how fast the mouse is moved.

I don't want to waste time on this idea if it isn't practical.

Thanks!

(我希望我能說中國話)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Experimental Lab
« Reply #89 on: December 26, 2012, 05:45:47 AM »
I haven't looked at the code, but could you do something like:

OnMouseDown(){
  if (over an icon){
    selected icon = the icon that was clicked
  }
}

OnMouseUp(){
  if (selected icon~=nil){
    if (mousepos over asteroid){
      //do asteroid + icon things
    }
    selected icon = nil
  }
}

while GameRunning() do {
    if(selected icon ~= nil){
      //draw selected icon at mouse position
    }
}

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Drag and Drop Concept
« Reply #90 on: December 26, 2012, 06:11:22 AM »
Quote
I haven't looked at the code, but could you do something like:

Well that's pretty much what I'm doing. I'm not having a problem with the coding so much as having concerns with performance. Run the program and see if you have the same problem with tracking that I am. I think it might just be my slow computer but it could very well be poorly written code. Thanks.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Experimental Lab
« Reply #91 on: December 26, 2012, 10:32:35 AM »
Quote
I haven't looked at the code, but could you do something like:

Well that's pretty much what I'm doing. I'm not having a problem with the coding so much as having concerns with performance. Run the program and see if you have the same problem with tracking that I am. I think it might just be my slow computer but it could very well be poorly written code. Thanks.

Well, you can just simply make the ball being rendered to the mouse screen coords, it's after all rendered on screen. Then, when the mouse is lifted you calculate distances from the roids.

The balls are bugging out because it's actually checking the distance per tick and if it's outside it won't do anything for you.
You should just store a number variable for the current active ball and move it around without checking the current distance from the mouse.

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Experimental Lab
« Reply #92 on: December 26, 2012, 01:16:38 PM »
Quote
Well, you can just simply make the ball being rendered to the mouse screen coords, it's after all rendered on screen. Then, when the mouse is lifted you calculate distances from the roids.

The balls are bugging out because it's actually checking the distance per tick and if it's outside it won't do anything for you.
You should just store a number variable for the current active ball and move it around without checking the current distance from the mouse.

Alright! I changed the code to get rid of the "checking distance per tick" and that seems to have corrected the problem. This also solved another problem I was having with the mouse picking up every ball it rolled over!

Thanks you guys!

Corrected code attached...
« Last Edit: December 26, 2012, 01:27:52 PM by Lost Seedling »