Login  Register
 



Post new topicReply to topic
 
Author Message
 PostPosted: 02 Feb, 2013 
 
User avatar

Joined: 30 Aug, 2008
Posts: 438
Location: Cambridgeshire, UK
Offline
I want to double the BuildTime of every unit with the Category BUILTBYTIER2ENGINEER without having to manually hook each one individually.

I have looked at the Resource Rich mod and extrapolated the following, but, predictably, it doesn't work.

Code:
-- Copyright 2007 Gas Powered Games - All rights reserved
--
-- Author: Matt Mahon
--
-- Description:
--    Sample Mod to double economic output of econ units.
--


--this function is called already in game. This gives us a hook to screw the
--blueprint values for the units

do
    local oldModBlueprints = ModBlueprints

    function ModBlueprints(all_bps)
       oldModBlueprints(all_bps)

        local TimeScale2 = 1.5
   local TimeScale3 = 2
       
        --loop through the blueprints and adjust as desired.
        for id,bp in all_bps.Unit do
            if bp.Categories.BUILTBYTIER2ENGINEER then
               bp.Economy.BuildTime = bp.Economy.BuildTime * TimeScale2
            end
            if bp.Categories.BUILTBYTIER3ENGINEER then
               bp.Economy.BuildTime = bp.Economy.BuildTime * TimeScale3
            end 
        end
    end

end



Is there any way of doing this?

_________________
Quote:
Supcom 2 is like a car, Its got a great engine, suspension and drive train, a sweet *** body where every curve is just right, but the guy at the paint shop accidentally painted it neon pink.

Mike


Last edited by aeoncleanse on 03 Feb, 2013, edited 1 time in total.

Top
 Profile  
 PostPosted: 03 Feb, 2013 
 
Forum Engineer
Forum Engineer

Joined: 05 Oct, 2007
Posts: 16520
Location: camping near the biggest power-up
Offline
Code:
bp.Economy.BuildTime = bp.Economy.BuiltTime * TimeScale3


This line has your mistake. It's but only one character wrong.


Also, you're not checking if a unit has no BuildTime defined. If something is built by an engineer (or at the very least has the BUILTBYTIER2ENGINEER, or BUILTBYTIER3ENGINEER category tags) but doesn't have a built time (I'm not saying a zero time, but one that is completely missing) it'll crash in a fiery ball of death.

_________________
Nephylim wrote:
But, an FA army in an FA environment just looks... right.
help wrote:
Does anyone know how to use air transports? I cant get them to pick up troops.


Top
 Profile  
 PostPosted: 03 Feb, 2013 
 
User avatar

Joined: 30 Aug, 2008
Posts: 438
Location: Cambridgeshire, UK
Offline
BulletMagnet wrote:
Code:
bp.Economy.BuildTime = bp.Economy.BuiltTime * TimeScale3


This line has your mistake. It's but only one character wrong.


Also, you're not checking if a unit has no BuildTime defined. If something is built by an engineer (or at the very least has the BUILTBYTIER2ENGINEER, or BUILTBYTIER3ENGINEER category tags) but doesn't have a built time (I'm not saying a zero time, but one that is completely missing) it'll crash in a fiery ball of death.


I spotted that typo just after I posted, and it makes no difference. I simply don't think that I can do this using the BUILTBYTIER2ENGINEER category check, though I know of no alternative. I can't use the error log either, as for some reason it gives me a looping error to do with my external sound card and crashes the game when I bring it up.

I'll check, but I'm pretty sure everything with the categories has a BuildTime cost...

_________________
Quote:
Supcom 2 is like a car, Its got a great engine, suspension and drive train, a sweet *** body where every curve is just right, but the guy at the paint shop accidentally painted it neon pink.

Mike


Top
 Profile  
 PostPosted: 04 Feb, 2013 
 
Forum Engineer
Forum Engineer

Joined: 05 Oct, 2007
Posts: 16520
Location: camping near the biggest power-up
Offline
Try this:

Code:
if bp.Economy and type(bp.Economy.BuildTime) == 'number' then
    bp.Economy.BuildTime = bp.Economy.BuildTime * TimeScale3
end


Also, spend some time fixing that problem with your sound. It's holding you back as a modder.

_________________
Nephylim wrote:
But, an FA army in an FA environment just looks... right.
help wrote:
Does anyone know how to use air transports? I cant get them to pick up troops.


Top
 Profile  
 PostPosted: 04 Feb, 2013 
 
User avatar

Joined: 30 Aug, 2008
Posts: 438
Location: Cambridgeshire, UK
Offline
BulletMagnet wrote:
Try this:

Code:
if bp.Economy and type(bp.Economy.BuildTime) == 'number' then
    bp.Economy.BuildTime = bp.Economy.BuildTime * TimeScale3
end


Also, spend some time fixing that problem with your sound. It's holding you back as a modder.


I don't understand what this code would do/ If it has an economy section, and if the economy section is a certain number, then apply the modification? How does this limit the changes to only those structures built by the corresponding Engineer?


Is 2 days time enough? :(

_________________
Quote:
Supcom 2 is like a car, Its got a great engine, suspension and drive train, a sweet *** body where every curve is just right, but the guy at the paint shop accidentally painted it neon pink.

Mike


Top
 Profile  
 PostPosted: 04 Feb, 2013 
 
Forum Engineer
Forum Engineer

Joined: 05 Oct, 2007
Posts: 16520
Location: camping near the biggest power-up
Offline
You are correct, that's exactly what the code does. This should prevent some crashes, if a unit doesn't have a BuildTime.

I'm thinking the Cybran construction drones (oh yes, they are units) might be problematic at times.

_________________
Nephylim wrote:
But, an FA army in an FA environment just looks... right.
help wrote:
Does anyone know how to use air transports? I cant get them to pick up troops.


Top
 Profile  
 PostPosted: 04 Feb, 2013 
 
User avatar

Joined: 30 Aug, 2008
Posts: 438
Location: Cambridgeshire, UK
Offline
Ah, so 'number' does not have to be replaced with a specific value, that tells the code that if it has any value at all, do the if, yes? If it had to be replaced with a specific value that would be useless.

The T2 drones don't worry me as they don't have BUILTBYTIER2ENGINEER... Do they? :?:

It's a nice bit of safeguard code, and thanks for it. Unfortunately, the main code function is still not working. Is there any way of doing what I want to do?

_________________
Quote:
Supcom 2 is like a car, Its got a great engine, suspension and drive train, a sweet *** body where every curve is just right, but the guy at the paint shop accidentally painted it neon pink.

Mike


Top
 Profile  
 PostPosted: 16 Feb, 2013 
 

Joined: 26 Feb, 2009
Posts: 3062
Offline
Hi,

The categories table is a numbered table so bp.categories.tag will not work
You need to use table.find (categories, 'tag')

A few checks though

If bp.Categories and table.find (bp.Categories, 'TAG') then
If bp.Economy then
If bp.Economy.BuildTime then
--do cool stuff
End
End
End

Sorry I written this on my tablet

_________________
Domino.
______________


Top
 Profile  
 PostPosted: 16 Feb, 2013 
 
Forum Engineer
Forum Engineer

Joined: 05 Oct, 2007
Posts: 16520
Location: camping near the biggest power-up
Offline
Well ****, Domino is absolutely right.

_________________
Nephylim wrote:
But, an FA army in an FA environment just looks... right.
help wrote:
Does anyone know how to use air transports? I cant get them to pick up troops.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic



Quick Tools

Search for:
Jump to:  

© 2002-2010 Gas Powered Games Corp. All Rights Reserved. Gas Powered Games is the exclusive trademark of Gas Powered Games Corp.
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
 
Home| Games | Company | News & Press | Support
  Terms of Use   |    Copyright Information   |    Privacy Policy