New Screens through Addon

Started by Dark_Phantom, September 07, 2021, 07:21:03 AM

Previous topic - Next topic

Dark_Phantom

Ok, we've been down this road before, and it's probably about 10 years too late, but I'm here to tell you how to add NEW screens through the addon folder.

I have attached the demo in the attachments on this post.  This is what we are using for "Week 1" of the SWBF1 Speedruns challenges.


  • You need to modify how the ifs_movietrans_PushScreen() function works.
  • You need to define a new screen in the addme.lua file
--Original concept by BAD_AL, modified by Dark_Phantom
--This modifies the ifs_movietrans_PushScreen function, or more accurately, catches one situation where we want to switch the screen.
origMovieTrans = ifs_movietrans_PushScreen
ifs_movietrans_PushScreen = function(screenName)
    if( screenName == ifs_sp ) then --THIS IS NOT A STRING
        --ScriptCB_PushScreen("ifs_sp2") --you can use this to just push the new screen if you don't have a movie transition
        origMovieTrans(ifs_sp2)
    else
        origMovieTrans(screenName)
    end
end

--Now we add the new screen...
ifs_sp2_vbutton_layout = {
--...
}

ifs_sp2 = NewIFShellScreen {
--...
}
ifs_sp2.CurButton = AddVerticalButtons(ifs_sp2.buttons,ifs_sp2_vbutton_layout)
AddIFScreen(ifs_sp2,"ifs_sp2")

I didn't copy my code straight up but you can copy that section from ifs_sp, and then modify one of the fields, like add a button to the list, you should be able to modify the screen accordingly.

After this, you can then save and munge your addme.lua file.
You're then going to create a folder in addon (I use challenge) then just drop it in there.
There's plenty of extensibility too... obviously I wouldn't recommend locking people out of screens, but using it for modification.  It's a much slimmer way to modify (or create new) screens we already have WITHOUT a total conversion mod.  As you can see from my attachment, it's 3 KB to add A WHOLE NEW (very basic) MODE

In a future episode, we will be talking about how to tie more screens together and make the script extremely generic for your purposes.  This way is the "hard-coded way" which is really convenient for one or two screens, but we can leverage some ScriptCB_SetDCMap() calls to go even further.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM
'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

wsa30h

i dont know what am doing wrong but no matter what i do it doesent work for me. i followed the tutorial by copying the piece of code here. then copying the respective sections from ifs sp into the addme but i still get a stack overflow. stack traceback:
   1:  function `origMovieTrans' [(none)]
   2:  function `origMovieTrans' [(none)]
   3:  function `origMovieTrans' [(none)]
   4:  function `origMovieTrans' [(none)]
   5:  function `origMovieTrans' [(none)]
   6:  function `origMovieTrans' [(none)]
   7:  function `origMovieTrans' [(none)]
   8:  function `origMovieTrans' [(none)]
   9:  function `origMovieTrans' [(none)]
  10:  function `origMovieTrans' [(none)]
  11:  function `origMovieTrans' [(none)]
       ...
 122:  function `origMovieTrans' [(none)]
 123:  function `origMovieTrans' [(none)]
 124:  function `origMovieTrans' [(none)]
 125:  function `origMovieTrans' [(none)]
 126:  function `origMovieTrans' [(none)]
 127:  function `origMovieTrans' [(none)]
 128:  function `origMovieTrans' [(none)]
 129:  function `origMovieTrans' [(none)]
 130:  function `ifs_movietrans_PushScreen' [(none)]
 131:  function <23:(none)>
mods and maps in progress:<br />--Bf1 expanded edition 3.0 version
-- bf1 tcw battles
-- bf1 seasons mod season 1
-- bf2 expanded edition tbh