Extracting Energy instead of metal from the ground?
Moderator: Moderators
Extracting Energy instead of metal from the ground?
My Question is:
Is it possible to have building extracting energy instead of metal from the ground? (the actual metal will be gathered different )
My only solution currently would be switching Energy and Metal but that would be a bit confusing i guess...
on the other hand i'm still in the early phase of the mod so it would be an option X_X
Is it possible to have building extracting energy instead of metal from the ground? (the actual metal will be gathered different )
My only solution currently would be switching Energy and Metal but that would be a bit confusing i guess...
on the other hand i'm still in the early phase of the mod so it would be an option X_X
Re: Extracting Energy instead of metal from the ground?
Short answer, "Yes, you can do anything you feel like with Lua!"... however if you are trying to do something like this with the built-in TAist basic TDF tags and such-like, no... this behavior is a hard-coded effect of the "This is a metal harvester" tag...
Also, been FOREVER since I've made a unit myself so I'm not the person to answer any questions on specifics like HOW to go about achieving this behavior with Lua etc.
Also, been FOREVER since I've made a unit myself so I'm not the person to answer any questions on specifics like HOW to go about achieving this behavior with Lua etc.
Re: Extracting Energy instead of metal from the ground?
Doesnt the geo plant "extract" energy from the ground? its just a different color in one of the map-layers
Re: Extracting Energy instead of metal from the ground?
Its possible, and easily doable with geo vents. Ill elaborate if the need arises.
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Extracting Energy instead of metal from the ground?
In terms of Lua scripts there also is CA's windmill script which changes the energy production based on the windmill's height. It in the end includes all the logic needed to gather some info and overwrite the resource gains with the wanted values...
Re: Extracting Energy instead of metal from the ground?
So i can make it buildable only ontop a certain feature? That would also solve my problem i guess.
What do i need for that?
What do i need for that?
Re: Extracting Energy instead of metal from the ground?
Only if that feature is geovent.
Also I have a gadget to plant a geovent on every metal spot.
Also I have a gadget to plant a geovent on every metal spot.
Re: Extracting Energy instead of metal from the ground?
You need to make points of 255 green on your featuremaps to get geo vents. And you need to look at how geothermal plants are done in BA or similar.
Re: Extracting Energy instead of metal from the ground?
Geothermal plant are not jus mexx that extract energy:
- Geothermal plant can only be build on the geovent geyser feature, mexx can be built anywhere.
- Every geo output the same energy, mexx output more or less depending on how rich is the soil.
- Mexx have extraction radius, geo not.
- ...
Instead, you should write a gadget that:
- Use Spring.GetGroundInfo to see how much metal there is at the unit position.
- Use Spring.SetUnitResourcing to make the unit produce more or less energy.
At least this way you're not forced to litter maps with geovent, and you can keep variation in production relative to variation in the metal map.
If you want to keep the extraction radius, instead of reading the ground metal concentration, read how much the mexx produce (if you can get a value small enough that it doesn't contribute significatively to metal economy yet large enough the number read is precise). Or maybe read how fast the mexx spin, or something.
- Geothermal plant can only be build on the geovent geyser feature, mexx can be built anywhere.
- Every geo output the same energy, mexx output more or less depending on how rich is the soil.
- Mexx have extraction radius, geo not.
- ...
Instead, you should write a gadget that:
- Use Spring.GetGroundInfo to see how much metal there is at the unit position.
- Use Spring.SetUnitResourcing to make the unit produce more or less energy.
At least this way you're not forced to litter maps with geovent, and you can keep variation in production relative to variation in the metal map.
If you want to keep the extraction radius, instead of reading the ground metal concentration, read how much the mexx produce (if you can get a value small enough that it doesn't contribute significatively to metal economy yet large enough the number read is precise). Or maybe read how fast the mexx spin, or something.
Re: Extracting Energy instead of metal from the ground?
Guess i will come back at that later when i can code a bit better.
Re: Extracting Energy instead of metal from the ground?
Use the metalmap to represent a resource thats gathered from the ground. Resource names shouldnt matter at all as long as they make senseErik wrote:My Question is:
Is it possible to have building extracting energy instead of metal from the ground? (the actual metal will be gathered different )
My only solution currently would be switching Energy and Metal but that would be a bit confusing i guess...
on the other hand i'm still in the early phase of the mod so it would be an option X_X
Re: Extracting Energy instead of metal from the ground?
Shields can't be powered with metal.
Re: Extracting Energy instead of metal from the ground?
Couldnt someone just copy paste the code in the engine and change it to energy/ a ressource of choice.
Doesn't sound that much work, on the other hand im not sure if anyone besides me will ever need that feature
Doesn't sound that much work, on the other hand im not sure if anyone besides me will ever need that feature

-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: Extracting Energy instead of metal from the ground?
CA's mex overdrive gadget has all the functions/examples you need to make a gadget that extracts energy from the metal map. Overdrive does this:
- Reads the metal income of built mexes and sets the income to very near 0.
- Does a lot of complex wackey stuff with energy creating metal, calculus for maximum output, pylons that activate mexes and have an energy limit, input energy from all teammates...
- Gives the players metal income.
Re: Extracting Energy instead of metal from the ground?
Code: Select all
function gadget:GetInfo()
return {
name = "Soil Energy",
desc = "Energy production relative to ground metal",
author = "zwzsg",
date = "17 february 2010",
version = "1.0",
license = "Public Domain",
layer = 0,
enabled = true
}
end
if (gadgetHandler:IsSyncedCode()) then
-- Replace armllt and corllt by your units' name.
-- Add similar new lines for new units.
-- Replace 0.001 by how much energy they should extract.
-- Expressed in the same units as in mexxes extractsMetal tag.
local EnergyExtractors = {
[UnitDefNames.armllt.id]=0.001,
[UnitDefNames.corllt.id]=0.001,
}
-- This compensate for maps being made for mexx that have an area of effect
-- That gadget only measure metal in the middle, while mexxes cover an area
-- This factor make it the number are the same nonetheless
-- Obviously won't work if you built just over a spike in the metal map
local areafactor=Game.extractorRadius*Game.extractorRadius*math.pi/128
function gadget:UnitFinished(u,ud)
if EnergyExtractors[ud] then
local x,_,z=Spring.GetUnitPosition(u)
local _,metal=Spring.GetGroundInfo(x,z)
Spring.SetUnitResourcing(u,"ume",metal*EnergyExtractors[ud]*areafactor)
end
end
end
-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: Extracting Energy instead of metal from the ground?
That doesn't have mex radius. Or should I say eex radius.
Re: Extracting Energy instead of metal from the ground?
That could be added. But I wanted to keep the gadget simple so as to be easy to read and understand.
Re: Extracting Energy instead of metal from the ground?
Edit:
Why does the metalmap dissapear now with the script enabled?
Without the script i see the metalmap fine but with it it doesnt show up when building.
Sidnote:
Also why on earth is there music from kernel panic even when i play something else? Weird stuff...
Why does the metalmap dissapear now with the script enabled?
Without the script i see the metalmap fine but with it it doesnt show up when building.
Sidnote:
Also why on earth is there music from kernel panic even when i play something else? Weird stuff...
Re: Extracting Energy instead of metal from the ground?
The gadget I posted in this thread does not change anything with the metal map display.Why does the metalmap dissapear now with the script enabled?
- Delete /music/*.oggAlso why on earth is there music from kernel panic even when i play something else?
- Convert your TA CD audio track to .ogg and place into /music/
Re: Extracting Energy instead of metal from the ground?
nvm i works fine
Last edited by Erik on 03 Mar 2010, 10:36, edited 1 time in total.