Lua and Map Loading

Lua and Map Loading

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

Moderator: Moderators

Post Reply
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Lua and Map Loading

Post by LathanStanley »

Ok ok, I'm jumping into this Lua scripting wtf head on...

I know a little code, keyword little, and I can understand most code if I stare at it long enough... (but bare with me, I'm using laymans terms for code commands because frankly, I'm not famaliar with the correct commands)

I also know that if you plan what you want to code before you start writing the code, it comes out faster, cleaner, and runs well, bug-free and more efficently.

anyways, I have some ideas on Lua scripts to implement... nearly to the point of scripted features... (which, I could to technically)...

my ideas are as follows:
(they all follow one another as a train of thought...)

Idea 1-

The map tdf itself, can it be setup to call a lua script from launch?
if so, how hard would that be?

(line within map.tdf file)
callscript=mapname.lua
callscript=userpref.lua

Idea 2-

Within the mapname.lua script it scans the map for current map features and runs any scripts associated with them. and also runs any lua scripts added to the userpref.lua (user run scripts for transport loading, queue changing, font whatever, etc...)

Idea 3-

within the feature.tdf there is the featuretype line, that runs an associated lua script per featuretype... wether it be an animation, a "grow", a damaging script, resource giving, whatever, creativity is the limit..

(line within feature.tdf file)
featuretype=(XXX) where xxx is a number 001 - 999

Idea 4-

Specific scripts per featuretype: (this is the biggest part I'm going to need help with)
1- grow
2- return fire
3- add weapontype (I.E. shielding or something)
4- add ai script (neutral compounds of un-civilized on maps)
5- give damage
6- give expierence (expierence crates for units!!!)
7- generate effects
8- teleportation (will use the .give and .take commands)
9- change terrain

etc... the imagination is the limit....


-----------------
but yeah, all and all, can a map START a lua script? if not, who wants to code it? if so, who is willing to help me script MAPS! muuu huuu HAAAA! :twisted:
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

As most of the new synced lua script feature are still undocument,
I'll point you to a couple of the relevant header files see that you'll
at least know some of the possible call-outs:
https://taspring.clan-sy.com/svn/spring ... ncedRead.h
https://taspring.clan-sy.com/svn/spring ... ncedCtrl.h

1. No, but LuaGaia/main.lua is called if it exists, and is not disabled
by script.txt/LuaGaia=0 or .springrc/LuaGaia=0 or the registry
(it depends on how the game is started).

2. You can use "include()" in LuaGaia/main.lua to load other scripts,
but it will only load archived scripts. The only time when you can load
raw files is if you enable ".devlua", in that gives you a fun warning about
desyncs.

<i'm sure i'll have to repeat this again>
SYNCED SCRIPTS CAN NOT RUN USER CODE
</i'm sure i'll have to repeat this again>

3. If you want to use tdf files to configure lua, then you'll have to write
a lua TDF parser (not especially difficult). An alternative is to have
separate lua format config files (the lua format is very good for config
files).

4. Quick notes:
1 - You can add and destroy features, and check their states
2 - the LuaGaia team has no allies, set the unit mode to return fire
3 - weapons can not be dynamically added, swap features for units?
4 - LuaGaia/main.lua can give units commands, it is a script
5 - See NOTE below
6 - See NOTE below
6 - See NOTE below
7 - Use LuaGaia/draw.lua to draw custom GL effects
8 - See NOTE below
9 - LevelHeightMap(), AdjustHeightMap(), RevertHeightMap() can be used

NOTE: LuaGaia does not have any special powers over normal player
units. It can control its own units and features' health, but it cannot modify
properties directly for other teams. LuaRules (the mod script), can control
all units.
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post by LathanStanley »

cool deal, I've been readin up every thread on the subforum all day.. I'm sure I'll have LOTS of questions... your patience with me is not going heartlessly, I thank you completely and utterly trepan, you've been all over pointing me in the correct direction.. :-)

I guess they might add more abilities later to the code, but from what you said, if it can only "automate user functions" and "edit its OWN stuff" then, it kicked alot of what I was hoping to do in the nuts.. but alas, some is better than none, and until the some works first, going for all, is pointless.. :P

I'll be reading and asking questions for days, all you code guys, poke around a bit and keep me on track, don't let me get too carried away with making a new nuke explosion effect or something lol :lol:
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

automate user functions?
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post by LathanStanley »

upgrading mexxes, units, auto move units from factories with transports... n'stuff
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Those would be LuaUI or LuaRules functions, definitely not LuaGaia.
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post by LathanStanley »

OK.. I think I found all the lua junk, and the gaia part....
https://spring.clan-sy.com/svn/spring/trunk/rts/Lua/
but.. this is all hebrew...
(well mostly)....

anyone wanna point me to the lua for dummies book?

or kindly get me started on a few lines and laugh at me while I fumble through the rest? :P
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Post by TheFatController »

best way is to look at existing lua code like some of the more simple widgets, also:

http://lua-users.org/wiki/TutorialDirectory

is mainly what I refer to (tho some newer stuff seems unavailable in springs version of lua)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Post Reply

Return to “Lua Scripts”