Change energy and metals????

Change energy and metals????

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Change energy and metals????

Post by davidovo »

Hey guys im new here.

I want to create a Game in modern time.

I dont want to use Energy and metal resources can anybody explain me how to edit them or add new??

I would like to have 4 type of resources and replace energy for cash $$$.


Tell me if it is possible and wich .lua script should I modify.


Thanks!
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Change energy and metals????

Post by gajop »

Engine doesn't natively support different resources. You can always add a variable in gadget synced mode which will represent your custom resource.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

Okay cause i like all the stuff offer by the engine wich will works with my main idea.

I have some friends who'll get involved in the project too.
I want to make a Mafia game. Gangland style( look on google).

But i really dont want to see the energy or metal bars.
I know there is a commadn line to turn it off bu ti would like to add some icons with my new ressources and the count number example :

Cash : 3040$ Cocain : 3000gm Liquor : 345 L

Would it be possible?

And also to set the cost of units to consume those ressources.

Example : henchman cost 300$ and 1 gm of cocain every 2 mins.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Change energy and metals????

Post by knorke »

there is no single file to edit to change name of resources, as it is possible with for example faction names.

if you want two resources that behave just like metal and energy, but with different names you can not use the engine display things. (tooltip and resourcebars)
You will have to script new tooltip and resourcebars widgets, luckily there are already some of those that you could open and change "Metal" to "Cocain".
This is somewhat related:
http://springrts.com/phpbb/viewtopic.ph ... al#p462461
For more/different resources you need to progam their logic. If you know programing see here:
http://springrts.com/wiki/Lua_Scripting
If not, learn a bit programing and then try again.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

Thanks a lot for guiding me.

I'll look forward to create new tooltip and bar but the problem is I would need a fail who already exist just to see how the file is linked with others.

Also im kind of new in programming i know the baics of c++ and lua I dont know how to begin a script from start when I have no example.

Example: The unitdefs is simple to me but creating a new resource from nothing is hard.


If you know where I can download a file from another game wich use a new resources other than metal and energy refer it to me if not its fine too!

Thanks
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Change energy and metals????

Post by knorke »

If you know where I can download a file from another game wich use a new resources other than metal and energy refer it to me if not its fine too!
Kernel Panic's network faction has a "buffer" that is basically a new resource:
network_buffer.lua and the other network_xxx.lua files.

http://springrts.com/phpbb/viewtopic.php?f=23&t=16223 is only tutorial that somewhat explains how to begin from start.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

I found out in those file some information.

GameState
Lua_SyncedCtrl
---------------------
Spring.AddTeamResource

( number teamID, string "metal" | "energy", number amount ) -> nil
---------------------

UNITDEFS:
UnitDefs[216]["metalCost"] = 2500,
---------------------

I need to know where the information about energy and metal are stocked in.

And does more files are linked with.

So as example if I add MONEY in game.

I would change starting resources for money

resource
( number teamID, string "Money", 2500) -> nil

Unitdefs:
UnitDefs[216]["moneyCost"] = 250,


Do you have any ideas on wich other file should i edit.
And where should i insert my new money script in to get recognize by the resource files and unitdefs.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Change energy and metals????

Post by SinbadEV »

davidovo wrote:I found out in those file some information.

GameState
Lua_SyncedCtrl
---------------------
Spring.AddTeamResource

( number teamID, string "metal" | "energy", number amount ) -> nil
---------------------

UNITDEFS:
UnitDefs[216]["metalCost"] = 2500,
---------------------

I need to know where the information about energy and metal are stocked in.

And does more files are linked with.

So as example if I add MONEY in game.

I would change starting resources for money

resource
( number teamID, string "Money", 2500) -> nil

Unitdefs:
UnitDefs[216]["moneyCost"] = 250,


Do you have any ideas on wich other file should i edit.
And where should i insert my new money script in to get recognize by the resource files and unitdefs.
Sorry, I think you are barking up the wrong tree there.

Those functions behave in a static way... they only work for metal or energy and metalCost or energyCost... you will need to reinvent the wheel (or find someone else who has done so, and copy them).

You have two resources already so it would be "relatively trivial" to "rename" those two (they would still be metal and energy internally but the player would see the name you give them), otherwise you will need to basically, in layman's terms*:

Make a script somewhere that stores a synced table of values for each resource, for each player.

Make a script on the units that produce this resource that increments the related values in this table for the player who owns them (or possibly a global script that checked a property on all you units to see if they produce the resource) etc... there are a bunch of approached

Make a script on the units that expend this resource that decrements the related values etc etc...

You are already going to need to learn to make scripts in order for your units to move, aim and shoot so this would mostly just be a matter adding a little more code to each unit involved in the new resource infrastructure...

I think GundamRTS used a custom resource mechanism (at least for a while) but you may have alienated smoth.

*because I'm a layman when it comes to Lua scripting and don't know what I'm talking about... think of this as a questionably useful but technically inaccurate answer
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Change energy and metals????

Post by knorke »

I need to know where the information about energy and metal are stocked in.
in the engine. (the part that is written in c++)
Spring.AddTeamResource and similiar are interfaces to that part but since engine only knows about two resources, this will not work here.
New resource has to be entirely in Lua, like the "buffer" resource from Kernel Panic.

the scripts go in luarules\gadgets\ folder.
But resource system is not so easy as first project, read the tutorial first and start with "hello world" in spring.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

yaeh its done the hello world things.

hum okay fine then,

But i dont want unit to produce ressources or use em when they fire.

I only want a intial cost of ressources for each unit seperatly.

The game would start without any constructor.

The way i plan it would be :

- the player start with only 1 unit.

- The map would be a city or village with tons of neutral building (capturable).

- Some building would produces those custom resources I want to make wich will be tradable or sellable in a market.

Some resources would be usable (consume to fire) example bullets.

And bulding would produce money.

I dont want to collect resources or gather em on map.

I dont know if its clearer this way im way to bad in english to be really clear.:(
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

Also I want the initial player units (boss) to be able fo capturing units to join is team and not produce em.

Can i set up a kind of resources cost for capturing a neutral unit?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Change energy and metals????

Post by Silentwings »

With lua, yes.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

Okay then ill try to just set to 0 all the things with metal and energy remove their tooltip and bars and start working about new resources types.

Thanks for all your answer when ill be back home ill try this and give you feed back about it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Change energy and metals????

Post by zwzsg »

knorke wrote:Kernel Panic's network faction has a "buffer" that is basically a new resource:
network_buffer.lua and the other network_xxx.lua files.
Kernel Panic also has the SoS gamemode which is also kind of a super simple new resource:
sos.lua
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

zwzsg wrote:
knorke wrote:Kernel Panic's network faction has a "buffer" that is basically a new resource:
network_buffer.lua and the other network_xxx.lua files.
Kernel Panic also has the SoS gamemode which is also kind of a super simple new resource:
sos.lua

can you give me the direct link to download that file?

Thanks!
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Change energy and metals????

Post by zwzsg »

I can give you very indirect link:

Goto http://springrts.com/wiki/Kernel_Panic#Download_links:

Then download http://springfiles.com/spring/games/kernel-panic-zip

Then unzip it

Then get 7zip and unpack /mods/Kernel_Panic_4.4.sd7

Then inside Kernel_Panic_4.4.sd7 look into /LuaRules/Gadgets/
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

SUper thanks
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Change energy and metals????

Post by PicassoCT »

Wohoo... thats some game idea- a game were you play "the Game". Slinging and Smuggling, and every Corner is your ressource.

Im ususally here to discourage "Great Ideas" and drag there owners into the mudding coding swamp that is reality - but this is quite a good one. Get on with it!
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Change energy and metals????

Post by davidovo »

Well Its not 100% my idea I been inspired by Gangland and gangster 2 but those two games have disadvantage.

I see bigger than that, I want to get the best of those game and fix what they missed up.

If erver you wanna help you are welcome.
Post Reply

Return to “Lua Scripts”