Eufloria > Eufloria HD Mods

Notes for HD modders

(1/3) > >>

EDIT: This is rather out of date. Do people want me to update it? It's also relevant for the new PC/Mac/Linux/Android versions.

Since some of you amazing people are playing with iOS maps, here's some notes. I'm just pulling some random things out of scripts here but some of it may be useful.

It's worth giving me a prod on Twitter (sillytuna) if you have queries as I'm still across the other side of the world and will be travelling over the next few days.

Game text
This is exported from a Google doc as a tabbed tsc/csv file. Messages are referenced by the ID in the first column, and the message is in the second column. You can easily edit this in a text editor or in a spreadsheet (but be wary of characters being corrupted). # characters signify blank lines. {uXXXX} signifies a special character in the font such as an icon. ~ signifies a new paragraph. | signifies a new page of text.

Note that the text rendering routines don't calculate paragraphs particularly well as they were only added for limited use. More than 4 paragraphs is probably not supported and you need to try and balance paragraph lengths.

StartLevelLogic: First part is a quick debug hack (enabled by setting debugEnabled to true) allowing me to tap an asteroid as soon as a level starts in order to dump some seedlings on it. Second part if regular code to switch on some dark mode settings if relevant.

Debug: Prints a debug message to the console (I have no idea if you can get it to do this usefully - anyone?)

WaitMessage: Waits for a message to have completed, with an optional delay of 1 second afterwards. It also checks for if the game has finished at all times.

ClearMessage: Removes a message with an optional 2 second delay afterwards.

WaitDialog: Waits for a pop up dialog box to be closed.

WaitReal: Waits t seconds in real time

WaitGame: Waits t seconds in game time (i.e. if running at x3 speed then 1 real second = 3 game seconds)

Quit: Tells the game to exit, with a true or false parameter for has won/lost.

SetHelpAvailableStoryMode and SetTutorialButtonStoryMode enable help/tutorial buttons in non dark mode.

The comment at the top is incorrect - this is just the game over functionality in normal mode. Note to self, edit this file header!
The GameOver function takes care of ensuring the game finishes properly with appropriate messages and sounds. If no prefix is past, no message is displayed and the caller must take care of it, otherwise a message is put together based upon the prefex and _win/_lose, e.g. 07_win.

As RulesNormal but the actual level end conditions are also in here, in CheckConditions. This is because they're the same in all dark matter levels.

Default.lua / DarkMatter.lua / Classic.lua
You'll have to ask Rudolf or AlexM about a lot of these settings but these are what make the game what it is! I can usually look them up in the src if someone has any particular questions and the guys don't have time tho. Default is the regular game, DM is DM(!), classic is the easy/relaxed mode (which caused nightmares...).

Level Scripts
I restructured these for iOS.

LevelSetup() - put all level specific set ups here. You can override the game mode settings here and set up the asteroids. This will be similar to the original PC version I expect. Note that the camera is not necessarily fully ready at this point.

On asteroids, there is SetProtected(true) which stops the AI attacking the asteroid (well, it should do). You can later unprotect the asteroid.

You can also enable or disable buttons here (tho also elsewhere), e.g. SetFlowerDefenseButtonAvailable. Search levels 1-14 (probably 1-6, 8, 10, 14) for examples.

SetCameraPositionToAsteroidID and SetCameraZoomNow set the camera starting position.

The logic for the level goes here. You're best off looking at levels for examples. Essentially there is a little set up, a message, then a while GameRunning() do loop.

An asteroid has been revealed, indicated by id and owner. An owner id of 1 is the player, 0 is grey, 2+ is another enemy.

As revealed but the asteroid was taken.

Determine if the game has been won or lost, and display appropriate messages. Sometimes the GameOver routine takes care of all messages but sometimes the level is a little more particular so does it manually.

General notes - I tried to keep the scripts compatible with future non iOS versions [based on PS3, not existing PC build] hence a lot of iOS checks. However, I can't guarantee they work outside of iOS as I've not tested them so there will probably be bugs!

Also, all these functions have a standard layout, e.g. CheckConditions always exits immediately if gameFinished is true. Similarly LevelLogic calls StartLevelLogic and calls UpdateAsteroidLists for all empires on the level. It's important not to remove this code.

There are still a few minor inconsistencies but overall the levels should be reasonably clean.

Thanks for this!!

A massive treasure trove of valuable information... :>

So many questions...

Lets start with this one:

Tom recently posted that WaitReal() was preventing a while GameRunning() loop from looping... He did a bunch of tests and the while loop always terminates after the WaitReal command.
How does that command work?  How is it intended to be used?

As Annikk said, thank you so much, really is appreciated sillytuna.

And like Annikk, I have questions as well.

Just to let you know, I have an iPad 3, Wi-Fi 64GB

1. Is there any reason on which some code could possibly stop WaitReal() from working? But on top of not working, all the code works until it reaches WaitReal() and then nothing happens. but this is not the case for every level, I have 7 levels which work great with the WaitReal() but not on my 8th level, but I did combat this with Annikks custom timer though, see the code below, that is how I've made a slight delay before the seedlings are sent.

--- Code: ---function LevelLogic()

Puzzle1 = 0
puzzletimer = GetGameTime() + 4
GetAsteroid(16).Owner = 1

while GameRunning() do
if Puzzle1 == 1 then
if GetGameTime() > puzzletimer then
puzzletimer = puzzletimer + 30

if CheckPoint = 1 and GetEmpire(1).NumSeedlings == 0 then

--- End code ---

As you can see, instead of having puzzletimer this and that, I would have loved to have used WaitReal(2) or something, but you know, you can't do everything can you.

But now, I have added this into the code.

--- Code: ---function LevelLogic()

Puzzle1 = 0
puzzletimer = GetGameTime() + 4
GetAsteroid(16).Owner = 1

if IsiOS() then -- TESTING
Message("Testing", true, 1.0, "Left")

while GameRunning() do
--- End code ---

Notice that i'm trying to start adding some text now, but when I input that code, it does not work one bit, but after messing around with it, I realised that the WaitReal() is actually causing the problem, because when I take it out (ALSO THE SAME WITH WaitGame()). The level works. Now I'm guessing this is a Glitch/My Fault for doing something wrong during LevelSetup(), but honestly, I can't see anything different from my other levels.

So, what the heck? :P

2. SetCameraPosition(x,y) seems to be a very buggy, thats IF the player moves the position around, if the player doesn't move the position in the game then the camera will set it's position to whatever (x,y) I state. What I am not saying is moving the camera while the camera is being changed, I mean if the camera is at (0,0) already, and I swipe to (-1000,0) and I want the camera to be at (2000,2000), because I've swiped on my screen, it would just go somewhere completely different, not (2000,2000)

3. Is there actually any way of seeing what crashes a level? PC users get a error message that pops up, All i get it a shut off game :P

4. It seems I don't need the lang.csv for messages, by putting my text in the actual level itself, is that doing anything dangerous?

5. I've noticed that if I used this code:

--- Code: ---while GetAsteroid(1).NumSeedlings < 38 do
--- End code ---

does not work at all, but this code:

--- Code: ---while GetEmpire(1).NumSeedlings < 38 do
--- End code ---

The only problem with that is that what if I want to do something after a certain asteroid has something special, this is also the same case with .NumTrees .NumDysonTrees .NumDefenseTrees, but if it's just how it is then I'll have to deal with it.

I can't think of anymore questions now but I probably will have some :D

Looking forward to some feedback :)

WaitReal() definitely shouldn't cause the game loop to quit unless CheckConditions hasn't been set up right. It's used all over the place and the code is minimal (it's a simple function defined in the source file mentioned). I'll need to look at your source.

Text - I forgot, yes, you can add text directly. If the ID isn't recognised it'll just use the text.

SetCameraPosition - camera stuff on iPad is quite different and it's very possible you can't do some things you'd like to do due to what areas are 'unlocked' for viewing. You can't just set a position, the area needs to be viewable and even then the camera needs to be in a valid area. This is all to do with the sort of fog of war/or not, and the iPad's pan controls, if you know what I mean.

I'll have to check on the other stuff AM (night time here in NZ).

So you're telling me CheckConditions HAS to be in there for WaitReal()/WaitGame() to work?


[0] Message Index

[#] Next page

Go to full version