How to make the simplest of Plugins... just a button press...?

Discussion in 'Plugins' started by GCCRacer, Jan 8, 2015.

  1. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Hi all,

    I'm looking for a very simple, basic plugin. If someone gives me a pointer where to start, I might try making it myself.

    What I currently do is I have the MFD either in "Rankings" mode or showing my Split times. I hate floaty stuff/overlays on screen, it distracts me, so I toggle it on and off again on the start/finish straight, simulating a pit board.

    Thus, what would be a great help is a plugin that simple toggles the MFD visible on finish line, and toggles it off five seconds later. If it could do that for every sector line, that'd be a big bonus.

    How hard can it be... appreciate any help.

    Thanks, regards
     
  2. MerlinC

    MerlinC Registered

    Joined:
    Nov 3, 2012
    Messages:
    282
    Likes Received:
    1
    Assuming that you have an C++ Compiler installed and running you can download the example (http://downloads.imagespaceinc.com/rf2/plugin/InternalsPlugin6.zip ) compile it to ensure your compiler settings are correct.

    If you want to switch on the Pit Board on the start/finish line I would suggest using the following methods (just quickly copied the declaration from ini file)

    Code:
    virtual bool WantsScoringUpdates() { return( false ); }      // whether we want scoring updates
    virtual void UpdateScoring( const ScoringInfoV01 &info ) {}  // update plugin with scoring info (approximately five times per second)
    I assume - haven't used this parameters in person - that in the ScoringInfoV01 struct you should find the necessary information where on track your vehicle is and how long the track is. Thus you could show your Pit-Board ## m before you cross start/finish line.

    Code:
    ScoringInfoV01.mLapDist                                                      // distance around track
    ScoringInfoV01.mLapDis->mVehicle.double mLapDist;               // current distance around track

    Hope this helps. If you need more information please be a little more specific what you are asking for.

    P.S.: How to get the debugger running you can get some advise here http://isiforums.net/f/showthread.p...-Debugger-to-debug-code-of-PlugIns?highlight=
     
  3. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,353
    Likes Received:
    3,059
    UpdateScoring() is called at 5Hz, and it will give you the current sector (use the VehicleScoringInfoV01.mSector of the player vehicle). So every time that changes you know a sector line has been passed.

    Once you set up the logic for checking that, you need to be able to switch the MFD on and off. I haven't logged the controls directly available in rF2 but in rF1 there is "ToggleHUDMFD" which I think does exactly what you're looking for. If you print out the incoming controlName within CheckHWControl() you can get a full list of control names.

    So then you should be able to do everything within UpdateScoring() :

    - check for a sector change
    - if changed, 'press' ToggleHUDMUD or its equivalent
    - set a variable so you know you've toggled it, and/or store the elapsed time (ScoringInfoV01.mCurrentET) so you know when you turned the MFD on (you could use a positive value [the retrieved ET] to indicate it's on, and a negative value otherwise; or just a separate variable like bool isMFDDisplayed)

    Separately, on every UpdateScoring(), :
    - if you know the MFD is currently displayed, then
    - if currentET - MFDonET > 5.0, then
    - 'press' ToggleHUDMFD

    So each time you pass a sector point you turn the mfd on, and then each time the mfd has been on for 5 seconds you switch it off again.

    You would want to refine this a bit. For example, work out when you're on an outlap and don't show the MFD in that case. You could even consider using ScoringInfoV01.mLapDist in combination with your vehicle's VehicleScoringInfoV01.mLapDist so you show the MFD before you reach the start/finish line, more like a pitboard (of course that means you're seeing your previous lap then your new laptime as you cross the line - but a real pitboard can't show your just-completed laptime anyway, so none of it's real ;))

    Oh, and the other thing is knowing that you're in realtime. A variable like isRealtime, which you set to true in EnterRealtime() and false in ExitRealtime() would do the job there. No point 'pressing' any keys if you're at the monitor!

    Jeez, beaten to it by Merlin... ah well lol
     
  4. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Thanks to both of you for the detailed explanation.

    I guess that's a bit beyond my skill level then, I was hoping for a more "LUA-script" or similar language.
     
  5. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,353
    Likes Received:
    3,059
    Hi again,

    Sorry to take so long, meant to get something going after you indicated you weren't quite the budding and enthusiastic programmer you sounded like in your first post ;)

    Wrestled a little with the logic but I think this does what you asked:

    View attachment rF2PitBoard.zip

    It creates an .ini file in your data path folder, and that lets you set the display time (5s default) and whether to show the 'board' on sector splits (1, on, is default; 0 is off) as well. Seems to work for me after a few tests.

    If you want it further customised or flexible or something just shout.

    One note: plugins can't tell whether the HUD is being shown or not, but they can toggle it. So it assumes the HUD is off when you start rF2 - if you have it displayed, and it's switching it off (and back on) each time, you just need to toggle it yourself so it's doing it the right way around ;)
     
  6. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Awesome! Will try it tonight if I can get some time in front of the PC.

    Many, many thanks for taking the time to prepare this :)
     
  7. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Hi Lazza,

    Works beautiful, many thanks! Exactly what I needed.

    Now the only improvement suggestion I have would be to maybe add a keycombo (CTRL+P or similar) for the player to switch modes on the fly: Show on every sector line, only show on finish line, disable.

    And maybe write the .ini to the UserData folder, that would be a tad neater (but that's a very, very minor point).

    Awesome, thanks!
     
  8. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,353
    Likes Received:
    3,059
    Ok, try this one :D

    View attachment rF2PitBoard_V2.zip

    I put in a keypress handler with the keycode and modifier in the .ini... and then I decided to try the built-in plugin controls thing. So with the plugin installed, if you go into settings, controls, and the Devices tab, you'll see a PitBoard entry there (hmm... think I left the old name in... no longer just turns sectors on and off... oh well). So you can assign whatever key you want in the game, and the plugin will pick it up. Can go back to the old way if you'd prefer, it's more difficult to set in the .ini but may be more flexible (able to specify ctrl/shift/alt, and won't be adding to what looks like a limited number of plugin inputs).

    .ini has moved to the player folder as well.

    *PS For anyone coming in late... all this does is switch the HUD on at certain times. There's no new pitboard or anything being drawn. Sorry :eek:
     
    Last edited by a moderator: Feb 11, 2015
  9. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Hi, thanks!

    So this key assigned in game controls will toggle trough sectors, lap and off?

    Will test it in the evening!
     
  10. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,353
    Likes Received:
    3,059
    Yep, cycles through the 3 states. It uses the message centre to show you what you're selecting, but keep in mind if you press it a few times quickly the message centre sort of gives up and won't display anything new for a few seconds. I've seen the same with some other things so it's just a quirk of it... lucky there's only 3 options here ;)
     
  11. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,318
    Likes Received:
    1
    Works beautifully! Perfectly easy to hit the toggle and see what mode you are selecting.

    Like I said in the PM, I think for plugins a CTRL+ something makes a lot of sense... weird that ISI doesn't allow modifier keystrokes on the in-game mapping, because the Plugin keyset OTOH makes a lot of sense too.

    You're not storing the last state in the .ini, are you?

    I really don't want to occupy your time any further, it's a great plugin and many thanks for all that effort! I think it's a neat solution, whereas the trackmap or similar stuff just overload my screen this is minimalist as needs be.
     
    Last edited by a moderator: Feb 11, 2015
  12. P.S.R.

    P.S.R. Registered

    Joined:
    Jun 15, 2014
    Messages:
    1,795
    Likes Received:
    3
    @Lazza, great plugin! Thanks!!!! :D:D:D

    ...and @GCCRacer, great idea! I always loved how GTR2 et al did this, especially since I specialize in historic vehicles. GREAT! :D
     

Share This Page