SWBFGamers

Modding for the Original SWBF1 and SWBF2 => SWBF1 Modding => Topic started by: Kit Fisto on September 09, 2013, 09:44:31 PM

Title: [HELP] Change map name on IA list?
Post by: Kit Fisto on September 09, 2013, 09:44:31 PM
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?
Title: Re: [HELP] Change map name on IA list?
Post by: RepComm on September 09, 2013, 10:09:41 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: SleepKiller on September 09, 2013, 10:22:26 PM
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")
Title: Re: [HELP] Change map name on IA list?
Post by: 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.

Nice and useful bit of code, Sleepkiller. Going to start my day with it.
Title: Re: [HELP] Change map name on IA list?
Post by: Kit Fisto on September 10, 2013, 06:59:39 AM
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?
Title: Re: [HELP] Change map name on IA list?
Post by: tirpider on September 10, 2013, 09:18:32 AM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: Snake on September 10, 2013, 01:15:10 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: 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.

Title: Re: [HELP] Change map name on IA list?
Post by: Phobos on September 10, 2013, 01:45:28 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: Snake on September 10, 2013, 01:46:34 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: SleepKiller on September 10, 2013, 05:39:28 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: RepComm 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.)
Title: Re: [HELP] Change map name on IA list?
Post by: SleepKiller on September 10, 2013, 07:30:16 PM
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;
Title: Re: [HELP] Change map name on IA list?
Post by: tirpider on September 10, 2013, 11:53:17 PM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: SleepKiller on September 11, 2013, 12:50:34 AM
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.
Title: Re: [HELP] Change map name on IA list?
Post by: tirpider on September 11, 2013, 01:08:54 AM
I struggled every step of the way. heh
Not too familiar with lua.

It wouldn't work all day.. even tried changing the loop to a for/do .. during the digging sessions looking through stock luas for structure examples, I noticed that some of them do start at 0.  I think some of the lists are dealt with in lua, and some in the executable (c/c++?,) so it could be either. Just have to know when you make it, or trial and error it.

Now the fun of going through my archive and renaming maps with strings that only I will ever see....
Yeah. That's a chore for another day (or month).
Title: Re: [HELP] Change map name on IA list?
Post by: Kit Fisto on September 11, 2013, 06:25:44 PM
So...

Out of all of those posts I really only used this:
Quote from: SleepKiller on September 09, 2013, 10:22:26 PM
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.

Look and see the modding I did! I it didn't involve any munging, in fact. I did it on my Mac with not Windows emulator!


Original Map Names (ignore Jai Nollan, still working on that)

[spoiler](https://www.swbfgamers.com/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FsPxcUCo.png&hash=ff0c64cf1d86a8bff47a5756ce7108d423005d0a)[/spoiler]


Note these maps:
ALL of Eddie's maps and Tatooine: Judland Wastes. (that mispelling has bothered me for a long time :happy: )
[spoiler](https://www.swbfgamers.com/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FZIpdEof.png&hash=f62b806f23e512442b01868560530b1636b2b40f)[/spoiler]




I think it's safe to say, yay me! ;)



EDIT: Success!! (Note Jai Nollan and Dantooine) See above picture for before map name change)
[spoiler](https://www.swbfgamers.com/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FNgXpSlR.png&hash=3a6c7474574b06d4b18e6bd4d0bb845c42cae86a)[/spoiler]


Now I have to find a way to change "Tatooine: Jabba" to "Tatooine: Jabba's Palace" ...
Title: Re: [HELP] Change map name on IA list?
Post by: Unit 33 on September 12, 2013, 02:48:03 AM
Quote from: Kit Fisto on September 11, 2013, 06:25:44 PM
Tatooine: Judland Wastes. (that mispelling has bothered me for a long time :happy: )
Well... Wüste is just German for wasteland... because Rends spricht Deutsch!

Good job Kit, I think I'll have a blast at altering my Mac map list in a similar fashion, but with more immature humour.
Title: Re: [HELP] Change map name on IA list?
Post by: Phobos on September 17, 2013, 07:00:26 PM
i have a miniscript munger for this if u need it
EhPortal 1.34 © 2025, WebDev