[HELP] Change map name on IA list?

Started by Kit Fisto, September 09, 2013, 09:44:31 PM

Previous topic - Next topic
September 09, 2013, 09:44:31 PM Last Edit: September 09, 2013, 09:50:23 PM by Kit Fisto
Is it possible to change a mod maps name? The name that appears on the Instant Action list to be specific.

Would I edit the addle.script?

September 09, 2013, 10:09:41 PM #1 Last Edit: September 09, 2013, 10:15:34 PM by -RepublicCommando-
you'd need to remunge the LUA for addme.

Pretty simple really, most of them aren't a big spectacular change, if you search the mission.lvl the map comes with, you can find the lua names (like Bes2a) and input them where they're needed. I recommend doing this incase the map creator got creative (heh) with the mission.lua names for his/her map.
[spoiler]local newEntry = { mapluafile = "MOD1", showstr = "MOD MAP 1", side_c = 1, side_a = 1, dnldable = 1, }

--    Play-a-ble in single player.
local n = getn(sp_missionselect_listbox_contents)   
sp_missionselect_listbox_contents[n+1] = newEntry
--    Play-a-ble in multiplayer.
n = getn(mp_missionselect_listbox_contents)
mp_missionselect_listbox_contents[n+1] = newEntry

AddDownloadableContent("MOD1","MOD1c",4)
AddDownloadableContent("MOD1","MOD1a",4)

-- all done
newEntry = nil
n = nil[/spoiler] That is the stock "DataTemplate" addme, and it will change the mod ids when you create a BFBuilder project (Which I don't think you can create, since you're on a mac..)
You would change it accordingly for whatever the map is:[spoiler]local newEntry = { mapluafile = "ModMapID", showstr = "Mod map full name", side_c = 1, side_a = 1, dnldable = 1, }

--    Play-a-ble in single player.
local n = getn(sp_missionselect_listbox_contents)   
sp_missionselect_listbox_contents[n+1] = newEntry
--    Play-a-ble in multiplayer.
n = getn(mp_missionselect_listbox_contents)
mp_missionselect_listbox_contents[n+1] = newEntry

AddDownloadableContent("ModMapID","Clone mission lua",4)
AddDownloadableContent("ModMapID","Alliance mission lua name",4)
-- Like Bes2c (suffix is for attacking; clones = c, rebs = a, imps = i, reps = c or r sometimes..)

-- all done
newEntry = nil
n = nil[/spoiler]
Then you would munge the map, and pull out the addme and replace it. (keep a backup of course.)
--
DO NOT TRY EDITING ADDME.SCRIPT WITH AN EDITOR, it breaks the file.

Quote from: -RepublicCommando- on September 09, 2013, 10:09:41 PM
DO NOT TRY EDITING ADDME.SCRIPT WITH AN EDITOR, it breaks the file.
It only breaks the file because you do not know the file format ;) You can safely edit the strings so long as you don't make the name longer than it already was and if you make it shorter you need to fill in the rest of the strings will nulls.

You don't have to replace the maps addme.lua to rename it. This Lua function here should be able to rename any map, be it stock or addon. You just need to put it into and an addon.lua script and then call it for the maps you want to rename.

I haven't tested it, but it should work and let you quickly and easily rename any number of maps. Although it is only setup for SP. (Mainly because I don't expect anyone to actually use it.)

function ChangeName(mapID,name)

local size = getn(sp_missionselect_listbox_contents);
local i = 0;

repeat

if sp_missionselect_listbox_contents[i].mapluafile == mapID then

sp_missionselect_listbox_contents[i].showstr = name;

end

i=i+1;
until(i==size)

end

--Usage example.
--MapID without an era suffix. Then what you want the new name to be.
ChangeName("bes2","CLOUD CITY RENAMED")

I have the same desire. That is to change the map names to maintain the PLANET: MAP NAME standard because thats how I organize them in my downloads.

Nice and useful bit of code, Sleepkiller. Going to start my day with it.

Quote from: tirpider on September 10, 2013, 06:56:48 AM
I have the same desire. That is to change the map names to maintain the PLANET: MAP NAME standard because thats how I organize them in my downloads.
We think alike Tirpider. :cheers:

So, could I have a little step by step tutorial on how to do this? My modding terminology and things like that is a little rusty.

I am able to do it on my Mac correct?

September 10, 2013, 09:18:32 AM #5 Last Edit: September 10, 2013, 12:07:19 PM by tirpider
To get a lua script into the game, you will need to munge it.

I seem to remember the mungers not working out on Macs, so you might have to resort to hex-editing the addme.
If you do, I recommend backing up any file you alter first.

--
Well, I fail.
I can't seem to find an appropriate place to run it.
At first I thought common would be a good start.. nope, cause nothing in there does anything with the mission list collection.

The only place I found that handles the list is shell.lvl. there are several references to sp_missionselect_listbox_contents there, so I tried jamming in the function declaration and calling it at a few points with no success.

The function looks solid, afaik.  I just don't have a solid grasp of how all those scripts flow.

So I'm going to see if I can make a quick and dirty addme hack instead.. hehe

-edit
wheee...
yeah, if you hex edit the addme, then do as SK says and mind that you DO NOT alter the size of the string. Replace any unused characters at the end with null values.

I tried identifying the fields that need to be updated in order to use an arbitrary length name (so far ucfb, scr_, BODY, and the length just before the string itself,) but I missed something.  If it's off at all you get a crash. Not just a game crash, but a system crash.

I think it's because it offsets the bytecode data for the lua and the interpreter built into the game freaks out on it.  I may have missed a size field in the bytecode somewhere.

I won't be able to make a proper addme hack utility until more about the ucfb wrappers is uncovered and/or the structure of compiled lua is verified.

That means that editing over the existing string via hex editing, or finding a way to get SK's function operating is the best approach, so far.  er, well, the best hacky approach, that is.  THE best way is to munge a new addme.

September 10, 2013, 01:15:10 PM #6 Last Edit: September 10, 2013, 01:17:28 PM by Snake
I tried reading all the posts but they seemed WAY too complicated for what you're trying to do. This will change your map name on the Instant Action screen.

Step 1: Open the addme.lua
Step 2: See this at the top? The red is your map name. Change it to whatever you want.

-- add the new tat level to the missionlist
local newEntry = { mapluafile = "snakesmap", showstr = "Snake's Insanity", side_c = 1,  dnldable = 1, }

Step3: Save and you're done.
=AaTc= Forever

SALLY....

-Retired Modder

He's wanting to change the name of addon maps that have already been made/munged.


Quote from: tirpider on September 10, 2013, 01:41:24 PM
He's wanting to change the name of addon maps that have already been made/munged.
piece of cake. PM me if you need instructions for this.

Holy crap it makes so much more sense now. I was wondering what in the world you guys were going on about when all you had to do was open the addme.lua.. Anyway, disregard what I said.
=AaTc= Forever

SALLY....

-Retired Modder

A really quick guide on using it. If you need more specific instructions I can write them later.


Step 1.

Create a map and call it <INSERTNAMEHERE>.

Step 2.

Open addme.lua and copy the function over all existing code.

Step 3.

Call the function in the addme.lua as many times as desired.

Step 4.

Munge and copy the Addme.script from _Build_PC/Addon(Me?)/Munged/ and create a new folder in your SWBF Addon folder and call it ZZZ. This will make the game load it up last so that it can rename any mission.

Thats awesome and all, but does it take up a addon map slot? (I doubt it could from reading your script and using some common sense, but just incase.)

Quote from: -RepublicCommando- on September 10, 2013, 07:27:27 PM
Thats awesome and all, but does it take up a addon map slot? (I doubt it could from reading your script and using some common sense, but just incase.)
It doesn't contribute towards the mission limit. If you're worried about memory or anything just nil the function after you've executed it all the times you need to.

ChangeName = nil;

September 10, 2013, 11:53:17 PM #13 Last Edit: March 02, 2014, 04:14:52 PM by tirpider
I got it going.

Had to make a couple of changes, and made one more to add a feature:
Code (lua) Select
function ChangeName(mapID,name)
-- added strlower() to make mapID case insensitive
mapID = strlower(mapID)
local size = getn(sp_missionselect_listbox_contents)
local i = 1 -- starts at 1. fails when starting at 0
repeat
-- have to make the stored name lower case as well
if strlower(sp_missionselect_listbox_contents[i].mapluafile) == mapID then
sp_missionselect_listbox_contents[i].showstr = name
end
i = i + 1
until(i == size + 1) -- size + 1 lets it catch the last map in the list

end

--Usage example.
--MapID without an era suffix. Then what you want the new name to be.
ChangeName("BES1","Bespin: Tron Deadly Discs Edition")
ChangeName("BES2","Bespin: Death Of A Salesman")
ChangeName("028","Utapau: Now In 3-D")
ChangeName("Tat3","Jabba's Watching You")
ChangeName("tatFT","Unfinished Bussiness")



It works perfect as just a bare addme.script in the last folder in your addon dir. (zzz is what I tested.)

- changed the starting index from 0 to 1
- added 1 to the upper index limit of the loop
- added strlower() to mapID and mapluafile so it doesn't matter if the case is right (it mattered on "tatFT")

To make it easier to set up and test, I copied the addme.lua to zzz.
Then copied luac.exe and scriptmunge.exe from the BFBuilder\ToolsFL\Bin folder into the zzz folder.
Then made a makeit.bat in the zzz folder with the following:
Code (dos) Select
@echo off
del addme.script
scriptmunge -platform pc -inputfile addme.lua
del scriptmunge.log


So now, to get it going, I just edit the lua, run makeit.bat, then run SWBF to test.

Good work, SleepKiller.

(This is cool. Running code from the addme. Custom code without having to munge a new common or shell.)


Btw Kit, I don't know if you can run the mungers on your mac.  If you make a list of what you want changed, I'll be happy to munge it up for you.

-edit
for anyone following this, the addme script works very well, but only as an addme script.

The version of the sp_missionselect_listbox_contents table (mp as well) available to the shell.lvl scripts only contains the 16 stock maps. The addon map information is only available during the time the game is populating the list with addon map info.

If you only want to change stock map info, then the function will still work fine if included in a shell.lvl mod. But will only be able to change stock map names.

So Lua does index tables from 1. I've been working with C++ lately (Hence the ";" to close the lines.) so I had forgotten how Lua handled it.

Glad to see you got it working and nice job on fixing up the code.