View topic - MapOptions.lua and possible usefull functions ? *Request*


All times are UTC + 1 hour


Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 27 Oct 2008, 13:19 
Map Creator
User avatar

Joined: 23 Jan 2008, 18:29
Hello!

I think this MapOptions.lua is quite cool thing, but so far havent seen any in real use. I think reason to this is that theres actually no usefull functions you could add to it (Or anyone to make these functions.)

What I'm personally looking for is for example:

Max Metal
Max and min wind speed
Hardness
Gravity
TidalStrength
Typemap = "true/false"
Water Damage = true/false
AI Bonus

So I need someone to help me out a little... How can i make gadget to LuaGaia that would give access to manipulate .smd file ? Or is there other way to do this ?


Attachments:
MapOptions.lua [4.96 KiB]
Downloaded 136 times


Last edited by SirArtturi on 27 Oct 2008, 17:55, edited 1 time in total.
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 15:19 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
As example lets make SmallDivide have maphardness as map option.

1)
Write the .smd file in LUA, instead of TDF format (don't change extension!):
Code:
local mapInfo = {
  maphardness = 100.0,
  // TODO: convert other SmallDivide tags to LUA
}
return mapInfo


2)
Add MapOptions.lua to the map (root of the archive, ie. next to the maps folder in the archive):
Code:
SmallDivide.sdd/
|-- MapOptions.lua
`-- maps
    |-- SmallDivide-MapOptions.smd
    |-- SmallDivide-MapOptions.smf
    `-- SmallDivide.smt

(I renamed this test map to "SmallDivide-MapOptions.smf", as you can see.)

3)
Add the following to MapOptions.lua:
Code:
local options =
{
  {
    key    = 'maphardness',
    name   = 'Hardness',
    desc   = 'How much the map deforms due to explosions',
    type   = 'number',
    def    = 100.0,
    min    = 0,
    max    = 500.0,
    step   = 10.0,  -- quantization is aligned to the def value
                    -- (step <= 0) means that there is no quantization
  },
}
return options

This will add map option to lobbies with which you can change hardness to any value (in steps of 10) between 0 and 500.

4)
As last step, we need to make the .smd file read the map option, instead of having the value hardcoded in there. To do this, we get the map options table from Spring, and use this to read back all the map options from from the lobby:
Code:
local mapOptions = Spring.GetMapOptions()

local mapInfo = {
  maphardness = mapOptions.maphardness,
  // TODO: convert other SmallDivide tags to LUA
}
return mapInfo


5)
Profit! Test it with mapoption-compliant lobby and you should be able to freely change hardness to about anything between 0 and 500.

Others can help you with LUA details btw.

Good luck with it :-)
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 16:25 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
Hmm I think my example needs a check for when map info is being loaded in unitsync and Spring.GetMapOptions is nil.

I suppose now only engine default values would be visible in the lobby for all map parameters.

Probably want last step like this (untested pseudocode, my LUA isn't fluid enough yet...):
Code:
local mapInfo = {
  maphardness = 100.0,
  // TODO: convert other SmallDivide tags to LUA
}
if (Spring.GetMapOptions != nil) {
  local mapOptions = Spring.GetMapOptions()
  mapInfo.maphardness = mapOptions.maphardness
}
return mapInfo
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 16:25 
Redacted
User avatar

Joined: 08 Jan 2007, 06:13
Location: Don't be silly. If there's no machine heaven, where do all the toasters go?
Hardness 0?
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 16:26 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
I tried it, gives nice infinite depth holes :-)

When you move camera over them screen turns entirely blue.

And then it crashes :-)
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 17:03 
Map Creator
User avatar

Joined: 23 Jan 2008, 18:29
Okay... Cool thing that it could be done this way, but is there way to do it without turning .smd TDF into LUA ?

Im having problems turning .smd into lua here's the file:
http://pastebin.com/m7df9bd29

Im so noob at this :(

Whatsoever here is MapOptions.lua I would like to implement:


Attachments:
MapOptions.lua [4.96 KiB]
Downloaded 138 times
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 19:35 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
Can't really help you cause I'm LUA noob too, but I noticed some things:
Code:
local mapOptions = Spring.GetMapOptions()
[...]
maphardness = (mapOptions and mapOptions.maphardness)

I don't think this works as variant for what I suggested: the entire function GetMapOptions does not exist when the map is parsed in unitsync. That's different from the function existing but returning nil.

Code:
   team0 = {

      startPosX = 1364,
      startPosZ = 4494,

   },

   team1 = {
      
      startPosX = 7889,
      startPosZ = 4494,

   },
   [...]

If I understood the Spring code correctly, this needs to be more like this (though I can't get it working either...), because it gets a subtable "teams" from there in an indexed subtable, and there in a subtable called "startPos":
Code:
teams = {
  { startPos = { x = 1364, z = 4494 } },
  { startPos = { x = 7889, z = 4494 } },
  -- etc.
}


I don't know either about exact tags for the other variables, will have to reverse engineer more code sometime.

I don't think map options can be done without turning the .smd into LUA. It should be possible though to rename the original .smd and call the LUA TDF parser in your .smd but this will just make stuff complexer...

EDIT: poke some LUA guru in #lua maybe :-)
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 20:38 

Joined: 17 Nov 2005, 00:52
Location: Canada
A couple of hints:
- MapOptions can be used with TDF *.smd files
- maps are loaded via mapinfo.lua, take a look there
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 21:15 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
trepan, maybe give useful info actually?

of course I know they get loaded via mapinfo.lua I've been reverse engineering that code for a while to make first post...



Update on how to define start positions in LUA .smd:

Code:
local mapInfo = {
  -- TODO: all other tags
}

-- load start positions
local teams = {}

teams[0] = { startPos = { x = 100.0, z = 100.0 } }
teams[1] = { startPos = { x = 200.0, z = 100.0 } }
teams[2] = { startPos = { x = 300.0, z = 100.0 } }
teams[3] = { startPos = { x = 400.0, z = 100.0 } }

mapInfo.teams = teams
Top
 Offline Profile  
 
PostPosted: 27 Oct 2008, 22:03 

Joined: 17 Nov 2005, 00:52
Location: Canada
"MapOptions can be used with TDF *.smd files" -- not useful?

At the end of mapinfo.lua:
Code:
if (Spring.GetMapOptions and mapInfo.defaultoptions) then
  local optsFunc = VFS.Include('maphelper/applyopts.lua')
  optsFunc(mapInfo)
end

Note that there's also a setupopts.lua in the same directory.

Sorry for having wasted your time with the previous post, will
try to keep the following in mind:
(less spring posts) > (more spring posts)
Top
 Offline Profile  
 
PostPosted: 28 Oct 2008, 00:44 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
Well I noticed that line but it also causes other stuff I couldn't immediately figure out, and I couldn't see mapinfo.lua or dependencies (the map tdf parser) defining mapInfo.defaultoptions anywhere.

So you'd still need a LUA'ed .smd to set mapInfo.defaultoptions, right?

IOW, it's nice you point out that that line is there, but I've no clue what to do with that information without more instructions or without reverse engineering the rest of the code: which I'd have to do anyway even without the hint.
Top
 Offline Profile  
 
PostPosted: 28 Oct 2008, 00:57 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
Edit: nm this doesn't work
Top
 Offline Profile  
 
PostPosted: 28 Oct 2008, 01:11 

Joined: 17 Nov 2005, 00:52
Location: Canada
Fair enough. You're right, I'm wrong. Have fun ;-)
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 00:24 
Map Creator
User avatar

Joined: 23 Jan 2008, 18:29
Ok heres the smd right now:

http://pastebin.com/m2c9a8aee

Map loads now properly without errors. However seems that, while global parametres and start positions work properly, everything else is loaded by mapdefaults... (athmosphere, lightning, water etc.)

Whatsoever, from issue to another:
Im still wondering if theres no possibility to do this without "manually" converting smd into lua. if we could include somekinda of converter/parser with other lua that it could be possible to leave smd as it is...

This would make possible to use these mapoptions by other mappers aswell without learning to write their smds into lua first..

I wanted to make lua that could be easily used by mappers like "just attach the files into your map directory!"

maybe that parse_tdf_map.lua parser could be changed to produce lua code instead of actually making that data structure ?
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 00:36 
User avatar

Joined: 24 Aug 2006, 05:13
Location: USA West
Tbh, it's pretty trivial to write your mapdefs in lua, just a couple of extra braces and whatnot right? I mean, you're not actually writing any code, just writing the mapdefs using lua formatting rules.

Also, the map editors by frostregen and sefidel should start writing smds by default using lua.
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 14:06 
Supreme Annihilation Maintainer
User avatar

Joined: 11 Jan 2008, 16:55
Thing is.
You need to have presets.
People will not just waste play time on testing some random value with a map.
Most people do not even look there.

Stuff like animations of birds in the trees or wildlife or maybe some atmospheric effects...that would be hot..
Imagine you new map,Eye of Horus,with light dust storms coming randomly along with sound effects of a dust storm..
Or meteor showers.
Light rain if the map looks all swampy or just grim and wet.
rays of flickering light if the map is sunny..that's what will give maps a more natural feel to them..give them some character.
Nobody is really gonna play with tens of different values when he hosts a game..people like to play a map study it and know how to play on it to develop a sorted out gameplay.like a musician needing to know the technique to than improvise using that basis.
Players don't like to start playing a familiar map with some random experimental options that will probably not be used again and will just waste their time.
IMO any changes to maps need to be compulsory and permanent.
If the changes are cosmetic than you need a few presets that will only slightly modify the way the map looks but not how it plays.

Like a stormy preset sunny preset cold preset etc.
That will be something people will want to use.
Play the same familiar map but make it look slightly different and fresh.
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 14:31 
Map Creator
User avatar

Joined: 23 Jan 2008, 18:29
Gota wrote:
Thing is. You need to have presets. People will not just waste play time on testing some random value with a map. Most people do not even look there. Stuff like animations of birds in the trees or wildlife or maybe some atmospheric effects...that would be hot..


There would still be the presets. and the presets are the settings that mapper have set. Changing these settings some people might find meaningless and waste of time but there are still some who would like to play around and adjust the map for their own taste...

I understand your point and agree with most of it... Well maybe those athmospherical settings and such are quite useless to be included because they are only for visual look. You can still modify the map in smd for screenshots or whatsoever. It doesnt have much global effect or effects on multiplaying dimensions.

my mapoptions lua are to make maps more flexible towards the style of gameplay you want. As also for maps that "fail" in some of these conditions. For example: DSD and folsomdamfinals typemap works with ba, but it may fail drastically for other mods, therefore it would be really nice option to turn off the typemap...

What comes natural effect luas, lups and such, I'd really like to include such luas you mention but there's none ! and no one is willing or skilled to make such things...

Other point is that these are options that are customable by your own choice. From now on, hopefully, you can easily add whatever you like to your mapoptions, whether it is gaia effects, athmospheric or global parametres etc...
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 19:52 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
I am just poking in asking for 3 other options

skyboxsun
skyboxclouds


just a bool that would allow us to also render the sun and cloud layer along with our skybox image.

Fogstartdistance

numeric saying how far away the fog will start.

name it what you want but they would be handy tags.

I hope this was the type of input you wanted SirArtturi, I am still terribly ill so I am not able to read the whole thread, sorry if I am repeating something already posted
Top
 Offline Profile  
 
PostPosted: 29 Oct 2008, 20:09 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
smoth wrote:
Fogstartdistance

numeric saying how far away the fog will start.

like fogStart? ...
Top
 Offline Profile  
 
PostPosted: 30 Oct 2008, 15:03 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
oh yeah, so we do, then I guess I meant fogend.

I knew we had one or another.
Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Site layout created by Roflcopter et al.