Author Topic: iPad Custom Level [HELP, Very Beginner]  (Read 19351 times)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
iPad Custom Level [HELP, Very Beginner]
« on: May 01, 2012, 05:23:15 AM »
Since I don't have the PC version of this game, I only have the iPad version, and would love to start creating my custom levels, I would like to create a full 25 level story which replaces the original story, but suprise suprise, I don't know much about scripting.

There is hope though, from looking through the .lua file of say level 4, I have been playing around with the attributes and seedlings of the asteroids and i'd say I understand that, but from the level_4.lua file I'll upload some code I don't understand, and hopefully someone will be kind enough to help me.

Code: [Select]
function LevelSetup()
if IsiOS() then
SetSpeedSwitchAvailable(false)
end

Some of you may laugh, because this is the start of the scripting, but is this just the speed setting at the top left? and because it says false it means it's not visible/usabe?

Code: [Select]
Globals():Get("Asteroids"):Set("RadiusPowerRule",1.2)
Globals():Get("Asteroids"):Set("SizeFromEnergy",120)
Globals():Get("Asteroids"):Set("SizeFromStrength",120)
Globals():Get("Asteroids"):Set("SizeFromSpeed",120)
Globals():Get("Asteroids"):Set("CoreHealthPowerRule",2.5)
Globals():Get("Asteroids"):Set("SendPowerRule",2.5)

I just don't get these lines of codes, I know it's to do with the Asteroids, but i'm not understanding the PowerRule?

Code: [Select]
Globals():Get("Structures"):Set("LevelDuration1",25)
Globals():Get("Structures"):Set("LevelDuration2",60)
Globals():Get("Structures"):Set("LevelDuration3",120)
Globals():Get("Structures"):Set("LevelDuration4",180)
Globals():Get("Structures"):Set("SpawnTime1",27)
Globals():Get("Structures"):Set("SpawnTime2",22)
Globals():Get("Structures"):Set("SpawnTime3",17)
Globals():Get("Structures"):Set("SpawnTime4",17)

I can guess? But i'd rather be told the real thing.

Code: [Select]
Globals():Get("Game"):Set("MinAsteroidSeparation",1500)
Globals():Get("Game"):Set("MaxAsteroidNeighbourDist",3500)
Globals():Get("Game"):Set("GreysProbability",0.15)

Help. :/

Code: [Select]
AddAsteroidRing(4, 0, 0, 1700, 6500)
Is this something to do with position?

Code: [Select]
-- Asteroid 4
a = AddAsteroidWithAttribs(4000,-3500, 0.7,0.7,0.7)
a.Owner = 1
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
a:AddSeedlings(30)
a.Moveable = false

I'll tell you first what I understand from this...
Code: [Select]
-- Asteroid 4                                     =   Just a name? not that important?
a = AddAsteroidWithAttribs(4000,-3500, 0.7,0.7,0.7)      =   (X , Y, 0-1 energy, 0-1 strength, 0-1 speed)
a.Owner = 1                                   =  0 - Empty 1 - ME 2+ - other factions, depends on max factions I set with the globals():?
s = a:AddDysonTree()                              =  s = a:AddDysonTree() simply adds a dysontree (I know the other add codes aswell, such as defence trees and that)
s:LevelUp()                                         = Don't really understand this, does it automatically level up the dyson tree?
s:LevelUp()
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
a:AddSeedlings(30)                               = Starts with 30 seedlings
a.Moveable = false                                = Don't know?

Code: [Select]
asteroidID = GetRandomRange( 6, 8 )

?

Code: [Select]
stage = 0

function LevelLogic()
StartLevelLogic()

GetEmpire(1):UpdateAsteroidLists()
GetEmpire(0):UpdateAsteroidLists()
GetEmpire(2):UpdateAsteroidLists()

No idea?

I don't really want to add text at the moment so is the following useful to me at the moment?

Code: [Select]
--
-- Mission text
--
if IsiOS() then
WaitReal(1)
Message("04_01", true, 1.0, "Top")
WaitMessage(true)
SetSpeedSwitchAvailable(true)
Message("04_GOAL", true, 1.0, "Left")
else
MessageBox("04_01")
WaitDialog()
end

--
-- Artifact intro
--
if IsiOS() then
WaitMessage(true)
WaitReal(2)

Message("04_ARTIFACT", true, 1.0, "Top")

if GetLevelHasTimeRecorded() then
SetHelpAvailableStoryMode("res/iOS_ArtifactIntroduce.png",512, "iOS_ArtifactIntroduce")
end

WaitMessage(true)
WaitReal(1)

if not GetLevelHasTimeRecorded() then
ImageBox("res/iOS_ArtifactIntroduce.png",512, "iOS_ArtifactIntroduce")
WaitDialog()
SetHelpAvailableStoryMode("res/iOS_ArtifactIntroduce.png",512, "iOS_ArtifactIntroduce")
end
else
ImageBox("res/Artifact1.png",256,"ArtifactIntroduce")
WaitDialog()
end

-- stay here until stage is not zero - this is set when a certain asteroid is REVEALED (see below)
while stage == 0 do
CheckConditions()
coroutine.yield()
end

WaitGame(3)

--
-- Another seedling empire???
--
if IsiOS() then
Message("04_02", true, 1.0, "Top")
else
MessageBox("04_02")
WaitDialog()
end

while GameRunning() do
CheckConditions()
coroutine.yield()
end
end


function CheckConditions()
if gameFinished then
return
end

if GetEmpire(1):GetNumOwnedAsteroids() >= 9 and GetEmpire(0).Defeated and GetEmpire(2).Defeated then
if IsiOS() then
GameOver(true, "")
Message("04_win", true, 1.0, "Centre")
WaitMessage(false)
MessageBox("HintGoal")
WaitDialog()
Quit(true)
else
GameOver(true, "04")
end
end

if GetEmpire(1).NumDysonTrees == 0 and GetEmpire(1).NumSeedlings == 0 then
GameOver(false, "04")
end
end


function OnAsteroidRevealed(id, owner)
if id == 9 and owner == 1 and stage == 0 then
GetAsteroid(9):SetGraceTime(5)
stage = 1
end
end


Again to whoever has taken their precious time to help me, thank you, it won't be underappreciated.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #1 on: May 01, 2012, 08:25:20 PM »
Oh wow, new functions :D

A lot of the codes are already covered by Annikk in the beginner guide, go check it out! :)
The other codes I guess you'll need to experiment with or wait for A||R to answer :)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #2 on: May 02, 2012, 01:16:44 AM »
The other codes I guess you'll need to experiment with or wait for A||R to answer :)

Bitwise, short-circuiting?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #3 on: May 02, 2012, 01:21:12 AM »
Hey Aino, firstly thanks for replying :)

And most of the code is kind of the same but a bit different from looking at Annikk.exe's guide, I've emailed an Admin/Mod, can't remember who, they posted something about iPad level testing, i'll see what happens.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #4 on: May 02, 2012, 01:26:15 AM »
The other codes I guess you'll need to experiment with or wait for A||R to answer :)

Bitwise, short-circuiting?

You mean the ||? That's or in java :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #5 on: May 02, 2012, 01:37:12 AM »
It's time to break this thing down:

This is the most complicated one:
(click to show/hide)

GetEmpire(1):UpdateAsteroidLists() is Updating the Asteroid List (i.e how many asteroid the empire has, which asteroids, if the empire is defeated and other stuff).
SetSpeedSwitchAvailable(true) is probably allowing to change the speed in-game, like the developers mode +/-.
WaitReal(1) is, I think, to stop everything. 1 should be 1 millisecond, not a second.
Message("04_01", true, 1.0, "Top") is probably Message(Text, Clickable???, Size, Position(Text Based))(I'm not certain about this, do some experiementation! :D)
IsiOS() doesn't need any explanation.

The rest is very well known code.
I also bet this is how it will look after the update :)
« Last Edit: May 02, 2012, 01:46:44 AM by Aino »

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #6 on: May 03, 2012, 02:59:56 AM »
Well here we go, this is the basic level isn't it.

Code: [Select]
function LevelSetup()
SetBackdropColour(240/255,221/255,163/255)

Globals():Get("Asteroids"):Set("MaxTrees",1)
Globals():Get("Asteroids"):Set("MinRadius",90)
Globals():Get("Asteroids"):Set("MaxRadius",100)
Globals():Get("Asteroids"):Set("RadiusPowerRule",1.1)
Globals():Get("Asteroids"):Set("SizeFromEnergy",120)
Globals():Get("Asteroids"):Set("SizeFromStrength",120)
Globals():Get("Asteroids"):Set("SizeFromSpeed",120)
Globals():Get("Asteroids"):Set("MinCoreHealth",50)
Globals():Get("Asteroids"):Set("MaxCoreHealth",175)
Globals():Get("Asteroids"):Set("CoreHealthPowerRule",2)
Globals():Get("Asteroids"):Set("MinSendDistance",2400)
Globals():Get("Asteroids"):Set("MaxSendDistance",6000)
Globals():Get("Asteroids"):Set("SendPowerRule",3.2)

Globals():Get("Structures"):Set("LevelDuration1",15)
Globals():Get("Structures"):Set("LevelDuration2",30)
Globals():Get("Structures"):Set("LevelDuration3",60)
Globals():Get("Structures"):Set("LevelDuration4",100)
Globals():Get("Structures"):Set("SpawnTime1",15)
Globals():Get("Structures"):Set("SpawnTime2",12)
Globals():Get("Structures"):Set("SpawnTime3",10)
Globals():Get("Structures"):Set("SpawnTime4",8)

Globals():Get("Flowers"):Set("Available",0)

Globals():Get("StructuresDefense"):Set("TreeCost",10000)
Globals():Get("StructuresDefense"):Set("LevelDuration1",100000)

Globals():Get("Game"):Set("EnemyFactionsMin",0)
Globals():Get("Game"):Set("EnemyFactionsMax",0)
Globals():Get("Game"):Set("MinAsteroidSeparation",1500)
Globals():Get("Game"):Set("MaxAsteroidNeighbourDist",6000)
Globals():Get("Game"):Set("GreysProbability",0)

-- Asteroid 1
a = AddAsteroidWithAttribs(2200,6000, 0.2,1.0,0.3)
a.Owner = 1
a:AddSeedlings(10)
a.Moveable = false

SetDefenseTreeButtonAvailable(false)
SetFlowerDefenseButtonAvailable(false)
SetFlowerSeederButtonAvailable(false)
SetTerraformingButtonAvailable(false)
SetBeaconButtonAvailable(false)

if IsiOS() then
SetEnemyInfoAvailable(false)

SetSpeedSwitchAvailable(false)
SetSendModeScoutAvailable(false)
SetSendModeUnitsSelectorAvailable(false)
else
SetEnemyInfoAvailable(false)
SetCoreInfoAvailable(false)
end

SetCameraPositionToAsteroidID(0)
SetCameraZoomNow(50)
end

It doesn't complete yet, as in, theres no code to say if all enemies are defeated then I have completed the level, but I don't want that in yet. I want to play around with a few things, but I do have a question.

I had a look at the lua reference and I can't find help on the Zoom function, The...

Code: [Select]
SetCameraPositionToAsteroidID(0)
SetCameraZoomNow(50)

Is fine, Later i'd like to add some text (need to find where thats stored on iPad first). Back on to the zoom thing, I don't want the user to be able to zoom out from (50) yet? How would I go about doing that?

The help is appreciated?
   
EDIT:: Found were the text is stored, it's a land.csv file that is easily opened with excel.
« Last Edit: May 03, 2012, 03:21:58 AM by Tomfloria »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #7 on: May 03, 2012, 03:58:16 AM »
Is fine, Later i'd like to add some text (need to find where thats stored on iPad first). Back on to the zoom thing, I don't want the user to be able to zoom out from (50) yet? How would I go about doing that?

To do this:

Code: [Select]
if (GetCameraZoom() > 50) then
SetCameraZoomNow(50)
end

BTW, those () brackets in the if condition isn't needed in Lua. It's just a java habit :P

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #8 on: May 03, 2012, 04:15:21 AM »
Thank you Aino! Trying to get some text working now, hopefully get the first level done tonight, If I need any help i'll reply here or message you, since you're the helper.

Thank you! :)

EDIT::

You're code

Code: [Select]
if (GetCameraZoom() > 50) then
SetCameraZoomNow(50)
end

Seems to crash my level, is it supposed to look like this?

EDIT::

Also remember this is for the iPad, so it might need to be wrote differently?

Code: [Select]
SetCameraPositionToAsteroidID(0)
SetCameraZoomNow(10)
if (GetCameraZoom() > 50) then
SetCameraZoomNow(50)
end
« Last Edit: May 03, 2012, 05:30:05 AM by Tomfloria »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #9 on: May 03, 2012, 05:42:00 AM »
Geee, how can I forget:
It's supposed to be in a while loop in levellogic, or the logic function that exists.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #10 on: May 03, 2012, 06:08:01 AM »
So...

Code: [Select]
SetCameraPositionToAsteroidID(0)
SetCameraZoomNow(50)
end

function LevelLogic()
StartLevelLogic()

if (GetCameraZoom() > 50) then
SetCameraZoomNow(50)
end


Just a question.... That code you gave me, does it restrict zooming capabilities until I want the user to be able to use it?
« Last Edit: May 03, 2012, 06:14:22 AM by Tomfloria »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #11 on: May 03, 2012, 06:25:29 AM »
No, it doesn't. You'll need to add that in yourself. Try something like

Code: [Select]
if GetCameraZoom() > 50 and zoomRestricted then
    SetCameraZoomNow(50)
end

Of course, you will have to set zoomRestricted to TRUE at the start of the level and then FALSE when you want it unlocked.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #12 on: May 03, 2012, 06:36:55 AM »
Where would I add zoomRestricted? or even, what would the code look like?

Also how do I change the text colour from black to white?
« Last Edit: May 03, 2012, 07:20:51 AM by Tomfloria »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #13 on: May 03, 2012, 02:51:48 PM »
Your code should look something like this for the zoom capper:

Code: [Select]
SetCameraPositionToAsteroidID(0)
SetCameraZoomNow(50)
end

function LevelLogic()
StartLevelLogic()

zoomRestricted  = true
while GameRunning() do
if GetCameraZoom() > 50 and zoomRestricted then
SetCameraZoomNow(50)
end

coroutine.yield() --if you need this one....
end
end

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #14 on: May 03, 2012, 11:53:39 PM »
The code you give me crashes the level :/

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #15 on: May 04, 2012, 01:08:34 AM »
That's because he missed out a few lines at the start. Ignore the first three lines of Aino's code.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #16 on: May 04, 2012, 01:23:21 AM »
Thanks Pilchard, but now I have the problem of the camera being able to move off screen.

Code: [Select]
zoomRestricted  = true
cameraRestricted  = true
while GameRunning() do
if GetCameraZoom() > 3500 and GetCameraPosition() = (0,0) and zoomRestricted and cameraRestricted then
SetCameraPositionNow(0,0)
SetCameraZoomNow(3500)
end

See this is the annoying thing for a beginner.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #17 on: May 04, 2012, 01:37:49 AM »
I see the problem. You will only lock the camera if it is zoomed out, and will only lock the zoom if the camera has not moved. Change the code to check each thing individually, like this

Code: [Select]
zoomRestricted  = true
cameraRestricted  = true

while GameRunning() do
if GetCameraZoom() > 3500 and zoomRestricted then
SetCameraPositionNow(0,0)
SetCameraZoomNow(3500)
end
                if not GetCameraPosition() = (0,0) and cameraRestricted then
SetCameraPositionNow(0,0)
SetCameraZoomNow(3500)
end

                coroutine.yield()
end

That NOT will basically check if the camera has moved - if it is NOT at (0,0). Sorry that's such a quick explanation, if you need more help just ask.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #18 on: May 04, 2012, 01:41:22 AM »
I will be needling a lot of help, but thank you for replying, I will add this and get back to you :)

I have this for function LevelLogic() but it crashes my game still :/
Code: [Select]

function LevelLogic()
StartLevelLogic()

zoomRestricted  = true
cameraRestricted  = true

while GameRunning() do
if GetCameraZoom() > 3500 and zoomRestricted then
SetCameraPositionNow(0,0)
SetCameraZoomNow(3500)
end

if not GetCameraPosition() = (0,0) and cameraRestricted then
SetCameraPositionNow(0,0)
SetCameraZoomNow(3500)
end

                coroutine.yield()

end
end
« Last Edit: May 04, 2012, 01:45:44 AM by Tomfloria »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #19 on: May 04, 2012, 01:43:31 AM »
Oh, one thing that I will ask - could you post any error messages that come up when you test a level?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #20 on: May 04, 2012, 01:46:13 AM »
I'm using the iPad, I no idea how to find the error messages?


Also, how would I state the senddistance to be exaclty 250 per say? I want to create asteroids to 'pop up' into the world when I've gone over some text, could I just place the asteroids in LevelSetup() then make them hidden? then put some code up in LevelLogic()?

Code: [Select]
--Starting Asteroid
a = GetAsteroid(0)
a = GetEmpire(1)
a = AddAsteroidWithAttribs(0,0, 1.0,1.0,1.0)
a.Owner = 1
a:AddSeedlings(10)
a.TreeCap = 1
a.Moveable = false
a:SetRadius(1040)
a.SendDistance = 100

This is the starting asteroid, but I know for a fact the senddistance isn't 100
« Last Edit: May 04, 2012, 02:10:23 AM by Tomfloria »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #21 on: May 04, 2012, 02:13:40 AM »
Ah, so you are. On the PC version if a map fails to load there will be a message that reads something like

Unable to load level "A_PATH_HERE" due to the following error: A_PATH_HERE: NUMBER : Unexpected token near 'i'

Does that happen on the iPad?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #22 on: May 04, 2012, 02:20:17 AM »
The last thing I remember in coding is that == is equal to and = is set to... I might've been mistaken :o

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #23 on: May 04, 2012, 02:32:45 AM »
No, nothing happens with the ipad, if you want I can paste my current whole level code?

Is it possible to do something like

Camera movement only allowed from top left (-1000,1000) to bottom right (1000,-1000) so the user can move it, but only between that box/region so it's still restricted but I have defined the space

Also Aino, putting a.SendDistance == 100 crashes the game

Also guys, How would I change the colour of the message text?
« Last Edit: May 04, 2012, 02:42:12 AM by Tomfloria »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #24 on: May 04, 2012, 03:53:07 AM »
a.SendDistance == 100 should be used in an if statement.
a.SendDistance = 100 is correct when you want to change the senddistance.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #25 on: May 04, 2012, 03:58:16 AM »
It still doesn't work Aino, it's like the game automatically changes it so all asteroids are reachable

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #26 on: May 04, 2012, 04:59:39 AM »
You said it crashed the game, to fix that you'll need to either change a to a unique name for each asteroid and us that as a in the LevelLogic function. Like this:
Code: [Select]
IMANASTEROID = AddAsteroid(0,0)

function LevelLogic()
IMANASTEROID.SendDistance = x
end

Or you can use GetAsteroid(ID) and change the senddistance in LevelLogic.

THE POINT IS: do it in LevelLogic as I believe it has a greater chance of success.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #27 on: May 04, 2012, 05:10:34 AM »
Okay I will try this, Thank you for the help I am currently having throuble with something I experimented on...

Code: [Select]
if GetAsteroid(a):GetNumSeedlings() = 60 and GetNumDysonTrees() = 4 then
Message("You now have 60 seedlings, lets expand this Empire.~Notice the Asteroid to the left - Take it.", true, 1.0, "Centre")
b = GetAsteroid(0)
b = GetEmpire(1)
b = AddAsteroidWithAttribs(1432,4523, 0.6,0.1,0.5)
b.Owner = 0
b.TreeCap = 2
b.Moveable = false
b:SetRadius(124)
WaitDialog()

I want to spawn an asteroid if the number of seedlings on asteroid a is 60 and the number of dyson trees is 4


Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #28 on: May 04, 2012, 05:30:29 AM »
That is in the LevelLogic, this is wrong :P

The only thing you should be doing in LevelLogic is to change the senddistance, creating asteroids still belongs in LevelSetup :)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #29 on: May 04, 2012, 05:36:01 AM »
Yes, but what if I didn't want the asteroid at the start? So i wanted it to magically pop up after the seedlings and dyson trees are met on asteroid a?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #30 on: May 04, 2012, 05:49:17 AM »
I thought you could add asteroids during LevelLogic()...

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #31 on: May 04, 2012, 06:01:57 AM »
Well hopefully, because even if I used a:Hide(1) it's only hiding the attributes and stuff, wish it actually hid the asteroid.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #32 on: May 04, 2012, 06:11:37 AM »
You could make it very, very small with a sendDistance that is also small.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #33 on: May 04, 2012, 06:30:40 AM »
I'll figure that out in a bit, can you tell me what is wrong with this?

Code: [Select]
if GetEmpire(1).NumDysonTrees == 4 and GetEmpire(1).NumSeedlings == 10 then
Message("This is going to take a while.~I will give you the ability to speed up time.", true, 1.0, "Top")
SetSpeedSwitchAvailable(true)
WaitDialog()



end

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #34 on: May 04, 2012, 06:36:07 AM »
Doesn't work that way. The game can't make asteroid in the middle of the game, atleast not in LevelLogic...

You must make it in the beginning, hide it and show it up when it's needed. I have to go now and I'm really tired so I'm not much of help at this moment, sry :(

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #35 on: May 04, 2012, 06:57:59 AM »
Can anyone help me on this please?

I would like the code to do this...

When asteroid 0 gets 4 seedlings and has 4 dyson trees i would like a message to be shown and the speed option available

Code: [Select]
if GetAsteroid(0).NumDysonTrees + 4 and GetAsteroid(0).NumSeedlings + 4 then
WaitReal(2)
SetSpeedSwitchAvailable(true)
Message("This is going to take a while~Use the Speedometer on the top left of the screen to speed things up.", false, 1.0, "Left")
end

-- Wait for 4 seedlings to be made
while GetAsteroid(0).NumSeedlings < 4 do
coroutine.yield()
end
« Last Edit: May 04, 2012, 09:09:23 PM by Tomfloria »

sillytuna

  • Eufloria lacky
  • Administrator
  • Arboreal Being
  • *****
  • Thank You
  • -Given: 58
  • -Receive: 73
  • Posts: 442
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #36 on: May 25, 2012, 05:34:12 PM »
GetEmpire(1):UpdateAsteroidLists() is Updating the Asteroid List (i.e how many asteroid the empire has, which asteroids, if the empire is defeated and other stuff).
SetSpeedSwitchAvailable(true) is probably allowing to change the speed in-game, like the developers mode +/-.
WaitReal(1) is, I think, to stop everything. 1 should be 1 millisecond, not a second.
Message("04_01", true, 1.0, "Top") is probably Message(Text, Clickable???, Size, Position(Text Based))(I'm not certain about this, do some experiementation! :D)
IsiOS() doesn't need any explanation.

SetSpeedSwitchAvailable: This just disables or enables the top left speed control. Levels disable it for the first few seconds during opening message displays for one reason - some levels have AI on both switches and timers which are only affected after the text has finished. Having a speed control at the start can thus give a player a head start. It's perhaps not the ideal fix but that's why you'll see this in levels (disabled in set up, enabled after the intro message).

There are many other availability messages too - note that these tend to match game settings although you could be evil and prevent the player planting flowers by disabling the button even though they could grow them according to the rules!

WaitReal(t) - waits t seconds of real time. This is not game time, i.e. it is unaffected by the speed control. It's mainly used for message delays. WaitGame(t) is game time. Parameters are seconds. Nothing actually stops by the way, it just pauses further execution of that function. The game can still end as normal as long as scripting has been done correctly (i.e. the CheckConditions function is valid).

Message(<ID>, <AUTO DISPLAY TIME true/false>, <SIZE>, <LOCATION ["Top", "Left", "Center", possibly right and bottom]>) - you can add text to lang.csv. See my iOS scripting post.

Also, someone was setting zoom to 50. I have no idea if this is ok or not but it looks like a really low number to me. Crashing may be possible if the zoom is set beyond a sensible range (zooms tend to be in the high 100s or 1000s from memory). The camera code was reworked heavily a couple of times to suit the iPad and is probably not hugely flexible.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #37 on: May 25, 2012, 06:02:08 PM »
Thanks for the info about camera zoom...  the iPad version of the command expects different ranges than the PC, I think..?

All very informative.. :>

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #38 on: May 25, 2012, 07:44:39 PM »
It's cleared a few things up, definitely thought WaitReal(1) was wait 1 second in game time, and the camera zoom, you'll have definitely seen me do this, but the player can zoom out whenever they want :P, the camera zoom was only for scripted events, e.g say an explanation of the level and functions where dramatic poses of the asteroids adds to the drama :p I could show you what I mean, but I don't want to use your time :D

sillytuna

  • Eufloria lacky
  • Administrator
  • Arboreal Being
  • *****
  • Thank You
  • -Given: 58
  • -Receive: 73
  • Posts: 442
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #39 on: May 25, 2012, 08:30:01 PM »
I think level 2 does a pan and back at some point?

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #40 on: May 25, 2012, 08:34:46 PM »
I'm not sure, levels 1 - 8 are currently my own at the moment :P, but I've definately seen movement of camera positions during the story mode.

sillytuna

  • Eufloria lacky
  • Administrator
  • Arboreal Being
  • *****
  • Thank You
  • -Given: 58
  • -Receive: 73
  • Posts: 442
  • Eufloria: Yes
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #41 on: May 26, 2012, 06:45:36 AM »
To pan the camera:

SelectionClear() -- Clear current selection
SetCameraFocusToAsteroidID(2, 90000) -- Zoom to asteroid 2, set zoom to 90000

I don't know if setting the camera position itself will work on iOS, but either way you definitely need to have unhidden an asteroid in the area around where you're going or the camera won't be allowed there.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #42 on: May 26, 2012, 09:16:44 AM »
Well 3 camera positions which are the first three change to different positions of the home asteroid, so the area is fine, it just doesn't go we're I want if the user moves the screen.

It would have been nice if you made a movecameraavalablebutton haha.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #43 on: May 26, 2012, 08:13:23 PM »
Tom,

You asked for some code help a few posts back.

Quote
When asteroid 0 gets 4 seedlings and has 4 dyson trees i would like a message to be shown and the speed option available



I spotted this:

Code: [Select]
if GetAsteroid(0).NumDysonTrees + 4 and GetAsteroid(0).NumSeedlings + 4 then
Should be:

Code: [Select]
if GetAsteroid(0):GetNumDysonTrees() == 4 and GetAsteroid(0):GetNumSeedlings(1) >= 4 then

http://www.dyson-game.com/smf/index.php?topic=212.msg1913#msg1913
For info on getting asteroid infos like this :>


By the way, if you're running this code inside a loop, once the conditions are met, they'll be met on EVERY run through the loop.
So you might want to add a latch variable, so that it only triggers once..

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: iPad Custom Level [HELP, Very Beginner]
« Reply #44 on: May 26, 2012, 08:20:09 PM »
You could do it with while loops..


Code: [Select]
while GetAsteroid(0):GetNumDysonTrees() < 4 and GetAsteroid(0):GetNumSeedlings(1) < 4 then
coroutine.yield()
end

WaitReal(2)
SetSpeedSwitchAvailable(true)
Message("This is going to take a while~Use the Speedometer on the top left of the screen to speed things up.", false, 1.0, "Left")


Or you could do it the pro way (heh) with conditionals..


Code: [Select]
latch = false

while GameRunning() do

if GetAsteroid(0):GetNumDysonTrees() == 4 and GetAsteroid(0):GetNumSeedlings(1) >= 4 and latch == false then
latch = true
WaitReal(2)
SetSpeedSwitchAvailable(true)
Message("This is going to take a while~Use the Speedometer on the top left of the screen to speed things up.", false, 1.0, "Left")
end

coroutine.yield()
end