Tileset types in custom Sanario Menu

Asked by Travis on 2011-01-31

I was playng around with the lua files, and thought to myself, this game mod doesn't have the ability to select the type of tileset you want when playing a custom map, or even a built in one, and you don't want to use the default tileset the map was made with.

I was looking at the code, and managed to find the menu options in the "guichan.lua" file for the race, resources amount, units, opponents and Game Type. But in the original it also has an option to select the forest/winter/swamp/wasteland tileset to use for whatever map you choose to play.

I tried a few things with no success. I managed to make the dropdown list with all the tileset names in it, but how do I actually get each one to perform the function of assigning the tileset type to the specified name selected in the list so I can use it for the map I am playing?

I found code in the "editor.lua" file that enables you to select the tileset you want to use for making a map. Can I use that code in the "guichan.lua" file to use for what tileset I want maps to use in-game?

Question information

Language:
English Edit question
Status:
Solved
For:
Stratagus Edit question
Assignee:
No assignee Edit question
Solved by:
Joris Dauphin
Solved:
2011-02-10
Last query:
2011-02-10
Last reply:
2011-02-07
Joris Dauphin (joris-dauphin) said : #1

It may be more difficult than using LoadTileModels as editor.lua does because tileset should also be in map itself.
You should use the same "hack" that is used for SetPlayerData in wc2.lua

Travis (dinky-dye-aussie) said : #2

How would I use the "SetPlayerData" code piece for the Tileset Selection? Editor.lua loads the tileset based on the selected tileset name's script file.

In the editor tileset option, it loads "scripts/tileset/" .. tilesets[1+ dropDownTileset:getselected()] .. ".lua", which loads the appropriate file based on whatever tilesets selected. I used this code last night without success to try and get the game to load the type I wanted. I'll keep trying the hack you mentioned and see what I get. I'll let you know what happens.

Could you maybe give some pointers as how to use that hack code plaese?

Joris Dauphin (joris-dauphin) said : #3

You have to overwrite function as it is done for SetDataPlayer
So, something like that (not tested) :
if (OldLoadTileSet ~= nil) then
  OldLoadTileSet = LoadTileSet
end
function LoadTileSet(arg)
if (defaultbehavior) then
  OldLoadTileSet(arg)
else
  OldLoadTileSet(newArgBasedOnOPtions)
end
end

Travis (dinky-dye-aussie) said : #4

I've been trying for days to get it working. I can't figure it out. I swear the solution is staring at me laughing. Im not having a go at anyone, I am just so eager to this code working. Have you tried anything with this yet Joris? It's cool if you haven't or have. I'd just really like to have this option in the game again.

Travis (dinky-dye-aussie) said : #5

what about the parameter from the Constructions.lua?

wargus.tileset

that would work wouldn't it? it's so simple and effective.

Joris Dauphin (joris-dauphin) said : #6

I have not tested/try my code yet, I was more busy than I think these weeks...

In a Map, there is a LoadTileModels(tilesetOfTheMap) (and not LoadTileSet which doesn't exist)

LoadTileModels() is equivalent to Load(arg) + set internal value in stratagus.

Ideally, Constructions.lua should be call after the LoadTileModels
wargus.tileset is set in the specified tilset.lua (summer, ...)

I will add this task in my todo-list...

Best Joris Dauphin (joris-dauphin) said : #7

It has been added in the trunk.

Travis (dinky-dye-aussie) said : #8

Dude you're a genius! Thankyou so much. And yes, the solution is laughing at me. so simple! I feel so stupid now. I've never really been a coder, I just nut stuff out.

Travis (dinky-dye-aussie) said : #9

Thanks Joris Dauphin, that solved my question.