Setting resources storage value (probably trivial)

Setting resources storage value (probably trivial)

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

Moderator: Moderators

Post Reply
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Setting resources storage value (probably trivial)

Post by aash29 »

Greetings,
I want to manually set metal and energy storage values at the beginning of the game using SetTeamResource. My question is, when and where should I call it?

Code: Select all

function gadget:GetInfo()
  return {
    name      = "setStorage",
    desc      = "2",
    author    = "3",
    date      = "4",
    license   = "5",
    layer     = 0,
    enabled   = true  --  loaded by default?
  }
end

function gadget:Initialize()
Spring.SetTeamResource(0,"es",1000)
Spring.SetTeamResource(0,"ms",1000)
end
I tried putting it in a gadget and using Initialize() callout, but that resulted in eeror message - namely "attempt to call "SetTeamResource" field - a nil value"

Thanks in advance
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Re: Setting resources storage value (probably trivial)

Post by Gnomre »

No need for lua:
- The TDF tags MetalStorage and EnergyStorage now override the StartMetal and
StartEnergy specified in the startscript, instead of the other way round. If
MetalStorage or EnergyStorage isn't specified the default values for commander
units are StartMetal and StartEnergy. For other units the default remains 0.
Just put Metal/Energystorage=1000; in your commander unit's FBI file.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Setting resources storage value (probably trivial)

Post by trepan »

If you do want to make the lua method work, make sure
that you only use synced call-outs in the synced part of
scripts. Add this immediately following your GetInfo():

Code: Select all

if (not gadgetHandler:IsSyncedCode()) then
  return false  --  quietly kill the gadget
end
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Re: Setting resources storage value (probably trivial)

Post by aash29 »

thanks both of you guys,
Gnome
I tried this method but I got 1001k of storage
trepan
It works, yay!
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Setting resources storage value (probably trivial)

Post by Forboding Angel »

Just put Metal/Energystorage=999; in your commander unit's FBI file then.
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Re: Setting resources storage value (probably trivial)

Post by aash29 »

By 1001k I meant 1 million and 1 thousand of storage.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Setting resources storage value (probably trivial)

Post by Forboding Angel »

Then you're doing it very very wrong.

Evolution and Gundam are doing it and it works just fine.
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Re: Setting resources storage value (probably trivial)

Post by aash29 »

Ok, I`ll look into them then
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

Re: Setting resources storage value (probably trivial)

Post by KingRaptor »

Don't take my word for it, but I'm pretty sure the starting resources are added to your maximum storage at start.
Post Reply

Return to “Lua Scripts”