Lua mission scriptin
Moderator: Moderators
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
Lua mission scriptin
is there a handy guide and command list for making the lua single player missions somewhere? im pretty poor at coding but it dosnt look to complex. sorry if there is already a thread, if there was I couldnt find it.
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
Read the wiki page already?
http://spring.clan-sy.com/wiki/Mission_development
http://spring.clan-sy.com/wiki/Mission_development
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
I think you can set the commanders' metal & energy storage values to something low when the mission starts.
EDIT: as for your 2nd question. I think there would be 2 units created, of which only the last one would move if you give it a command.
Use different variables to be able to reference both of them...
EDIT: as for your 2nd question. I think there would be 2 units created, of which only the last one would move if you give it a command.
Use different variables to be able to reference both of them...
I have been working on a tutorial a few weeks ago, but haven´t got it to a releasable stage yet. I thought it might be helpful for you though, so I´ve uploaded it now:
http://spring.unknown-files.net/file/23 ... orial.lua/
As you will certainly notice quickly enough if you try it, its directed towards people who have no prior RTS experience (which I guess is highly unrealistic for anybody playing spring, but whatever :D ).
Also the bits I made will probably not be commented very well :/ . But feel free to ask if you want to know why, how I´m doing something (not that I´m doing much...)
Edit:
On giving multiple units orders, I don´t know if the way you wrote does or does not work, what I know does work is the way its done in missiontest.lua (where I ripped most of my script from) :
Thus putting all the units you want as a group in an array, and then just having it loop the orders though for the whole array with the "for i = 1, ..." if I understand the code correctly.
Edit: P.S. , I think your XTA guide rocks, and think its great you want to make an ingame tutorial. While I probably don´t have much time to spare in the next week or two, I would generally gladly give you a hand on making the an in game guide.
http://spring.unknown-files.net/file/23 ... orial.lua/
As you will certainly notice quickly enough if you try it, its directed towards people who have no prior RTS experience (which I guess is highly unrealistic for anybody playing spring, but whatever :D ).
Also the bits I made will probably not be commented very well :/ . But feel free to ask if you want to know why, how I´m doing something (not that I´m doing much...)
Edit:
On giving multiple units orders, I don´t know if the way you wrote does or does not work, what I know does work is the way its done in missiontest.lua (where I ripped most of my script from) :
Code: Select all
-- Enemy stuff
local first = {
units.Load("CORe_AK", float3(1200, 80, 200), 1, false),
units.Load("CORe_AK", float3(1200, 80, 300), 1, false),
units.Load("CORe_AK", float3(1200, 80, 400), 1, false),
units.Load("CORe_AK", float3(1200, 80, 500), 1, false),
units.Load("CORe_AK", float3(1000, 80, 200), 1, false),
units.Load("CORe_AK", float3(1000, 80, 300), 1, false),
units.Load("CORe_AK", float3(1000, 80, 400), 1, false),
units.Load("CORe_AK", float3(1000, 80, 500), 1, false)
}
local c = Command()
c.id = Command.PATROL
c:AddParam(1100)
c:AddParam(80)
c:AddParam(1000)
for i = 1, table.getn(first) do
first[i]:GiveCommand(c)
end
Edit: P.S. , I think your XTA guide rocks, and think its great you want to make an ingame tutorial. While I probably don´t have much time to spare in the next week or two, I would generally gladly give you a hand on making the an in game guide.
A little bit of pseudocode to add in the update function
Code: Select all
a = getEnergy()
if(a > Energylimit){
b = a-EnergyLimit
AddEnergy(-b)
}
Thor, what exactly do you mean by limiting resources ? Do you mean limiting as in: not start with the crazy (but usefull for testing purposes) 200 k metal and 1000 k storage you get at the moment, but rather the standard 1000 each of metal and energy ? Cause than it might be an idea to have a look at the cmdrscript.lua . If you run that you start with the regular resources I think. No idea how its done though :/. Just let me check...
Ok I was wrong, the cmdrscript starts with loads of resources as well. However I did find this:
in the Luabinder.cpp
I´ve tried playing around with it, but I don´t really know how I would have to implement it. The bad news is, that I don´t have the impression that loosing your com means loosing your starting storage, as it does in normal games, so maybe this isn´t going to work anyhow :/ ...
Code: Select all
class_<UnitDef>("UnitDef")
.def_readonly("name", &UnitDef::name)
.def_readonly("humanname", &UnitDef::humanName)
.def_readwrite("metalstorage", &UnitDef::metalStorage) // readwrite so we can set commander's metalstorage at start of game
.def_readwrite("energystorage", &UnitDef::energyStorage), // readwrite so we can set commander's energystorage at start of game
I´ve tried playing around with it, but I don´t really know how I would have to implement it. The bad news is, that I don´t have the impression that loosing your com means loosing your starting storage, as it does in normal games, so maybe this isn´t going to work anyhow :/ ...
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
Thats not actually code to put in a script, thats from the c++ file in which the lua commands and classes are defined (I think, to be honest I don´t have much of an idea either). As stated above I haven´t managed to actually use /get working the function: metalstorage, as I´m not much of a coder myself :/. I just happened to have seen the comment in the code, and its obviously about what you (and me for that matter) want to get to make "building" missions possible.
Edit: well [edit: expletive deleted] me , forget all of the stuff I said above and check out this thread. I was about to say apparently, cause I still can hardly believe it but I just tried, and You can call different startscripts from the script.txt (used by the lobby) ! That means you can easily start with 1000 1000 res, or do just about anything else thats possible with the lobby as well *Jaw drop*. The only thing missing is lobby support... But by using a manually edited script.txt, and starting spring via a shortcut with the argument script.txt it works fine (in easyspeak that is: make a shortcut to the spring.exe, open its properties, and then change its target to "[wherever you have spring]\Spring\spring.exe script.txt " . Then use the shortcut and viola !). Wow ... where is Betalord ?
Edit: well [edit: expletive deleted] me , forget all of the stuff I said above and check out this thread. I was about to say apparently, cause I still can hardly believe it but I just tried, and You can call different startscripts from the script.txt (used by the lobby) ! That means you can easily start with 1000 1000 res, or do just about anything else thats possible with the lobby as well *Jaw drop*. The only thing missing is lobby support... But by using a manually edited script.txt, and starting spring via a shortcut with the argument script.txt it works fine (in easyspeak that is: make a shortcut to the spring.exe, open its properties, and then change its target to "[wherever you have spring]\Spring\spring.exe script.txt " . Then use the shortcut and viola !). Wow ... where is Betalord ?