1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Tutorial How to write a Game Plugin for SimTools 1.0 - API documentation

Discussion in 'SimTools Plugins' started by yobuddy, Aug 6, 2013.

  1. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,751Coins
    Ratings:
    +3,322 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Game documentation, game support forum, contact with the developer, published literature, Google, monitoring known API calls, trial-and-error, previously published titles, etc…
    • Informative Informative x 2
    • Creative Creative x 1
  2. Boomslangnz

    Boomslangnz Active Member SimAxe Beta Tester Gold Contributor

    Joined:
    Oct 26, 2014
    Messages:
    346
    Balance:
    4,166Coins
    Ratings:
    +243 / 1 / -0
    My Motion Simulator:
    2DOF
    Sorry for not fully understanding but when it comes to memory hooks with

    Memory Hook Variables _Is_MemoryHook – if it is a memory hook game set to true. (See example plugin)
    _MemoryHook_Roll – if it is a memory hook game; enter the memory location for roll.
    _MemoryHook_Pitch – if it is a memory hook game; enter the memory location for pitch.
    _MemoryHook_Heave – if it is a memory hook game; enter the memory location for heave.
    _MemoryHook_Yaw – if it is a memory hook game; enter the memory location for yaw.
    _MemoryHook_Sway – if it is a memory hook game; enter the memory location for sway.
    _MemoryHook_Surge – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra1 – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra2 – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra3 – if it is a memory hook game; enter the memory location for surge.


    If I have a game which has Roll for instance at memory location Example.exe+3806A4 and Pitch at Example.exe+557F68 would I enter it like this?

    PrivateConst _Is_MemoryHook AsBoolean = True 'Is a Memory Hook Required for this game?
    PrivateConst _MemHook_Roll AsUInteger = &3806A4
    PrivateConst _MemHook_Pitch AsUInteger = &557F68
    PrivateConst _MemHook_Heave AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Yaw AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Sway AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Surge AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Extra1 AsUInteger = 0
    PrivateConst _MemHook_Extra2 AsUInteger = 0
    PrivateConst _MemHook_Extra3 AsUInteger = 0
    • Like Like x 1
  3. cabexaz

    cabexaz cabexaz colombia

    Joined:
    Jul 11, 2015
    Messages:
    17
    Occupation:
    profesor
    Location:
    Calima
    Balance:
    180Coins
    Ratings:
    +15 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, Joyrider, SimforceGT, Motion platform, 4DOF, 6DOF
    The pluguins soport dk2 To No Limits Rollercoaster Simulation 2.0.3
  4. Boomslangnz

    Boomslangnz Active Member SimAxe Beta Tester Gold Contributor

    Joined:
    Oct 26, 2014
    Messages:
    346
    Balance:
    4,166Coins
    Ratings:
    +243 / 1 / -0
    My Motion Simulator:
    2DOF
    I'll ask again as i didnt get an answer. I know im pretty stupid

    I'll slightly change my question

    Memory Hook Variables _Is_MemoryHook – if it is a memory hook game set to true. (See example plugin)
    _MemoryHook_Roll – if it is a memory hook game; enter the memory location for roll.
    _MemoryHook_Pitch – if it is a memory hook game; enter the memory location for pitch.
    _MemoryHook_Heave – if it is a memory hook game; enter the memory location for heave.
    _MemoryHook_Yaw – if it is a memory hook game; enter the memory location for yaw.
    _MemoryHook_Sway – if it is a memory hook game; enter the memory location for sway.
    _MemoryHook_Surge – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra1 – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra2 – if it is a memory hook game; enter the memory location for surge.
    _MemoryHook_Extra3 – if it is a memory hook game; enter the memory location for surge.


    If I have a game which has Roll for instance at memory location 230654 and Pitch at 230543 would I enter it like this?

    PrivateConst _Is_MemoryHook AsBoolean = True 'Is a Memory Hook Required for this game?
    PrivateConst _MemHook_Roll AsUInteger = 230654
    PrivateConst _MemHook_Pitch AsUInteger = 230543
    PrivateConst _MemHook_Heave AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Yaw AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Sway AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Surge AsUInteger = 0 'Not Used = 0
    PrivateConst _MemHook_Extra1 AsUInteger = 0
    PrivateConst _MemHook_Extra2 AsUInteger = 0
    PrivateConst _MemHook_Extra3 AsUInteger = 0

    Pretty please can I get some help here :)
  5. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,751Coins
    Ratings:
    +3,322 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Essentially yes.
    • Like Like x 1
  6. Boomslangnz

    Boomslangnz Active Member SimAxe Beta Tester Gold Contributor

    Joined:
    Oct 26, 2014
    Messages:
    346
    Balance:
    4,166Coins
    Ratings:
    +243 / 1 / -0
    My Motion Simulator:
    2DOF
    Ok cool thanks

    Gives me something to try tonight then
  7. Boomslangnz

    Boomslangnz Active Member SimAxe Beta Tester Gold Contributor

    Joined:
    Oct 26, 2014
    Messages:
    346
    Balance:
    4,166Coins
    Ratings:
    +243 / 1 / -0
    My Motion Simulator:
    2DOF
    well I tried and it doesn't work for me, I added 3 different addresses to 3 different forces but when I try to compile it gives an error

    PrivateConst _MemHook_Roll AsUInteger = 206ECB30

    is what I posted but it says Exponent is not valid

    any ideas please
  8. Vef445

    Vef445 Active Member

    Joined:
    Jul 13, 2015
    Messages:
    125
    Location:
    Denmark
    Balance:
    597Coins
    Ratings:
    +73 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Looks like your variable is recognised as a number, you may want to use quotes around?
  9. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,751Coins
    Ratings:
    +3,322 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    When you write hex numbers you must write
    PrivateConst _MemHook_Roll AsUInteger = &H206ECB30
    • Like Like x 3
    • Winner Winner x 1
  10. Boomslangnz

    Boomslangnz Active Member SimAxe Beta Tester Gold Contributor

    Joined:
    Oct 26, 2014
    Messages:
    346
    Balance:
    4,166Coins
    Ratings:
    +243 / 1 / -0
    My Motion Simulator:
    2DOF
    Yep sorry I got it sorted earlier
  11. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Sooooooooo ..... after the annoucement of PS4 UDP telemetry on Projet Cars, I'm now onto plugin development :)
    I'm starting to study the LFS, which is UDP based.
    Expect some stupid/dummy questions from me soon :p
    First stupid question: as the PS4 is a remote system, with no simengine running on it, what shall I put on the process trigger ? "notepad.exe" so the Simengine becomes active when I fire-up a notepad ?
    • Like Like x 1
  12. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Starting to get mad :confused:

    When I build and run the plugin in debug , I get the OK window.
    upload_2015-11-25_22-44-18.png

    If I add the DLL using game plugin updater (just drag/drop the DLL on the icon), it looks good:
    upload_2015-11-25_22-45-47.png

    Now, I start Game Engine and select my plugin, "et là, c'est le drame" :

    upload_2015-11-25_22-47-52.png



    upload_2015-11-25_22-48-15.png

    unable to load file or assembly blabla.dll or one of its dependencies. Specified file is not found.

    Then gameengine and game manager are crashing.

    When switchinf to "release" build, same error. But whan clicking start, it triggers an error :
    upload_2015-11-25_22-50-18.png

    Is there an issue with my environment ?
    What have I missed ?

    Thanks for your help.
  13. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,282
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    49,201Coins
    Ratings:
    +5,093 / 18 / -0
    It looks like you just have a naming problem.
    In the pic above the name of the DLL is "PCARSUDP_Plugin"
    But the displayed name is Project CARS USP.

    Lets try this,
    If the GameName = "Project CARS USD"
    The DLL should be called "ProjectCARSUSD_Plugin.dll"
    And both the Assembly Name and the Root Namespace should be "ProjectCARSUSD_Plugin" for this plugin.
    check this and compile and re-install the new dll
    let me know how it goes!

    Sorry buddy, just a bit under the weather here.
    So I'm a bit slow at getting back to everyone!
    yobuddy
    • Informative Informative x 2
  14. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    We all have our busy time, including me ;)
    Thanks ! You were right, I had a name mismatch. It works now. Can the debug DLL be used, or should it be the release DLL (which cant be run from visual studio)

    Here is my roadmap:
    - Make a VB UDP receiver that output decoded data to a flat file
    - Integrate the UDP receiver in the plugin
    - Test/Test/Test

    If I understand correctly, the UDP listener is already included in the plugin:
    Sub Process_PacketRecieved(Text As String) Implements IPlugin.Process_PacketRecieved

    So when I get my simple code working, I would just have to integrate the decoding based on the Text variable of the Sub; that is this block code mainly :

    With MyOutsim_Internal
    Roll_Output = (.sngOrientation2 * 180 / 3.14159)
    Pitch_Output = (.sngOrientation1 * 180 / 3.14159) * -1
    Yaw_Output = (.sngOrientation0 * 180 / 3.14159)
    Heave_Output = (System.Math.Cos(.sngOrientation2) * .sngAcceleration2)
    Sway_Output = ((System.Math.Cos(.sngOrientation0) * .sngAcceleration0) + (System.Math.Sin(.sngOrientation0) * .sngAcceleration1))
    Surge_Output = ((-System.Math.Sin(.sngOrientation0) * .sngAcceleration0) + (System.Math.Cos(.sngOrientation0) * .sngAcceleration1))
    Extra1_Output = (((System.Math.Sin(.sngOrientation0) * .sngAcceleration0) + (System.Math.Sin(.sngOrientation0) * .sngAcceleration1)) * -1)
    End With


    Correct ?
  15. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Having crash issues with my plugin, I took the LFS sample, compiled it (without changing anything) and I get the same crash problem as soon as I send a UDP packet :confused:
    I'm using Visual Studio Community 2015
    The app is as follow:

    upload_2015-12-14_22-29-28.png

    Tried debug/release : same problem.
    To install the game plugin, only the DLL needs to be dragged/dropped or should the whole directory be zipped and dragged/dropped onto the game plugin updater ?

    Thanks for your help.
  16. hb kim

    hb kim Member

    Joined:
    Nov 12, 2015
    Messages:
    46
    Location:
    incheon, korea
    Balance:
    602Coins
    Ratings:
    +10 / 1 / -0
    My Motion Simulator:
    2DOF, SCN5
    I like to study to make a plugin for gta5...
    What kind of way does gta5 give its telemetry??
    Last edited: Dec 25, 2015
  17. hb kim

    hb kim Member

    Joined:
    Nov 12, 2015
    Messages:
    46
    Location:
    incheon, korea
    Balance:
    602Coins
    Ratings:
    +10 / 1 / -0
    My Motion Simulator:
    2DOF, SCN5
    I read the post thoroughly.. but still don't know how to write a plugin... hahahahaha.. uhm.. I am so sad that I cannot understand it at all... so... could I get more tutorial or..explanation for code..line by line???
    • Agree Agree x 1
  18. IJOJOI

    IJOJOI Member

    Joined:
    Oct 20, 2015
    Messages:
    46
    Location:
    Austria
    Balance:
    523Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    SCN5
    Hallo, very nice Tutorial, it really helped a lot.

    I somehow cant compile it however, I get this:
    asdf.jpg
  19. Dave Berry

    Dave Berry New Member

    Joined:
    Dec 2, 2015
    Messages:
    11
    Location:
    Burton on Trent, UK
    Balance:
    263Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, SCN5, SCN6, Motion platform
    Hi folks.

    I'm looking for a bit (a lot) of programming help here please! I'm building a sim with four actuators similar to a D-Box system. I'm hoping to get a direct translation of the individual suspension travel for each of the actuators to more accurately model the movement of the car (my theory is that for motion cueing, rather than g-force simulation, this will give a more realistic feel to the drive of the vehicle).

    I know that F1 2015 has data in its API showing the suspension position and velocity, but I'm struggling to work out how to access the UDP data within the sample plugin for LFS. I think I have found the variables I need to alter, but any help on where / how I should do this would be greatly appreciated!

    Cheers,

    Dave
  20. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    SimEngine works with position (yaw/pitch/roll) and forces (heave/sway/surge).
    So you will have to convert the suspension position to yaw/pitch/roll (which can make sense but you should endup with the same results given by the telemetry data ayway) , and do again some funny match to compute some heave/sway/surge (which can be strange for surge as suspension shouldnt show a great amount of surge for example). A sim with no forces will defenetly lack something (gear change, acceleration,....) and suspension will not give you accurate forces I think.
    Back to your question now. I was in the same situation a couple of month ago. I finally ended by making a standalone app in VB that receives and parses the received UDP data. It is much more easy to dev/test a small standalone app in a console than going for the big picture. Learn to walk (even stand-up) before you run :D
    This small UDP app will also speed-up the dev of new plugins. Once you small app gives the result you want, integrate it into the plugin
    Code:
    Imports System.Xml.Serialization
    Imports System.Runtime.InteropServices
    Imports System.IO
    Imports System.Net.Sockets
    Imports System.Net
    Imports System.Text
    
    Module Module1
    Sub Main()
    Dim UDPlistener As New UdpClient(5606)
    Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
    Dim UDPBytes As Byte()
    Dim UDPSize As Int32
    'File output handler
    Dim oFileStream As System.IO.FileStream
    oFileStream = New System.IO.FileStream("d:\bytes.bin", System.IO.FileMode.Append)
    While (True)
    If (UDPlistener.Available > 0) Then
    Try
    UDPBytes = UDPlistener.Receive(RemoteIpEndPoint)
    oFileStream.Write(UDPBytes, 0, UDPBytes.Length)
    oFileStream.Flush()
    UDPSize = UDPBytes.Length
    Console.WriteLine(("UDP message sent from " + RemoteIpEndPoint.Address.ToString() + " on their port number " + RemoteIpEndPoint.Port.ToString()))
    For Each UDPbyte As Byte In UDPBytes
    Console.Write(Hex(UDPbyte))
    Console.Write(" ")
    Next
    Catch e As Exception
    Console.WriteLine(e.ToString())
    End Try
    End If
    End While
    oFileStream.Close()
    End Sub
    End Module
    • Informative Informative x 2
    • Like Like x 1
    • Agree Agree x 1
    • Friendly Friendly x 1