Eufloria > Eufloria Classic Mods
Lua scripting in Eufloria - reference
Alex:
It's a function in "Structure" (i.e. trees), takes an integer from 0 to 4 inclusive and returns a colour. Each team has 5 colours that represent it, and trees store an internal version of it so that when tree ownership changes, the leaves that it bears can smoothly change colour instead of changing immediately.
If you want to get a team colour... here's a tasty bit for you.
--- Code: ---Game = luanet.import_type("Eufloria.ColonyGame");
team1red0 = Game.GetFactionColour(1,0)
team1red1 = Game.GetFactionColour(1,1)
team4red3 = Game.GetFactionColour(4,3)
--- End code ---
luanet.import_type gives you access to a class type theoretically giving you the opportunity to create instances of this type as well, though I am not sure what it would mean to do this in many cases for Eufloria's classes.
GetFactionColour is a static function of ColonyGame so you only need the type to be able to access it, not the ColonyGame instance. Hence the code above assigns the type ColonyGame to the variable CG, and this makes available the static functions of that type.
The base game class (that handles the front end etc) is Eufloria.Game, and has a static instance called Eufloria.Game.Instance from which various things are available (including Game.Instance.ColonyGame if the game is running).
e.g.
--- Code: ---Program = luanet.import_type("Eufloria.Game")
ProgramInstance = Program.Instance
Game = luanet.import_type("Eufloria.ColonyGame")
GameInstance = ProgramInstance.ColonyGame
if (GameInstance ~= nil) -- use some part of colonygame instance e.g. call ApplyDarkModeSettings()!
--- End code ---
All very untested and unsupported I must hasted to add!
Pilchard123:
Can you set the colours with this too?
annikk.exe:
Even with just what Alex has given me, I could effectively "set" colours. I could develop a script that checks what the colour is, and changes the asteroid to a different empire number if it's a colour I don't like. :>
This is freaking awesome... if it works, this will finally give me the ability to produce maps that look exactly how I intend them to look, every time they are played. :>
Alex:
I don't think you can set them at the moment, maybe there's a way but as ColorF (the data returned by GetFactionColour) is a struct not a class, you don't get passed back a reference, so going GetFactionColour(1,4).R = 0.8 won't do anything. Same for GetLeafColour. The changing empire plan ought to work though. Just bear in mind that the leaf colours may not be close to any of the team colours if the asteroid was recently taken over.
annikk.exe:
I'm currently working on an extremely large and complicated level and I'm looking for ways to increase the FPS ingame. I've already been able to make drastic improvements to some parts of the code by breaking out of loops early, using cheaper calculations to rule things out more quickly, avoiding math.sqrt wherever possible, trying to spot large inefficiencies in the looping structures, and so on.
I was wondering if you know if there are any Eufloria functions that are particularly expensive? EG, does it cost more CPU cycles to draw a sprite, or a line? Is "GetAsteroid" expensive? What about "GetNumSeedlings"? If there are any obvious cases where you can accomplish something in two different ways, and one is much cheaper than the other, I'd really like to know about them.. :>
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version