MFK 2 LUA Mod Resource | Updated + Source Code

Posted in Mod Resources
Unsubscribe from this topic
Heres a Quick Little program I have put together as a part of my C.S coursework.

Creating a Lua file from an MFK requires a Few things
  • All "\" need to be "\\"
  • All Commands need to have "Game." before them
  • You cant have ":" at the end of a line
  • All comments ("//") must be ("--")

Now you could do that all manually, but that would be a waste of time and silly wouldnt it...
I am aware that this is possible through NP++ and LUA-ify but this is just a nice little alternative i thought

This program will take an MFK file and Add a LUA file of the same name in the same direcotry it came from. Its Easy to use since it only has one button.

To run it open the download folder and run mfk2lua.exe. Also FYI this was created in python3 and then converted into a .exe which is why there are other files.

If you have any problems just tell me

Known Issues
  • When converting a file that contains dynaloads,the script removes the ";" imbetween them. This problem will hopefully be addressed in a future update however is not major since it only takes 3 seconds to correct

Bug Fix Log
  • I have fixed a bug where in some scenarios a function might have two "Game."'s before it, for example ("Game.Game.AddStageWaypoint"). This problem was caused by me not being specific enough when searching for functions and it saw the AddStage Function inside of the AddStageWaypoint Function . However this is now fixed
  • Added Comment Feature
  • Added the Python source code at the bottom of this thread :)

Download Options
EXE download -- Larger in size (just run mfk2lua.exe)
EXE Download

Python download -- Smaller file size and more reccomended to download however you will need to install the latest version of python 3 or atleast python 3.7.4 onwards
Python Download
Latest Version of Python 3

SOURCE CODE
print("Loading Imports")
from tkinter import *
from tkinter import filedialog

print("Creating window")
root = Tk()
root.title("Stevens100's MFK to LUA converter")

functions="SetMass|SetGasScale|SetHighSpeedGasScale|SetGasScaleSpeedThreshold|SetSlipGasScale|SetBrakeScale|SetTopSpeedKmh|SetMaxWheelTurnAngle|SetHighSpeedSteeringDrop|SetTireGrip|SetNormalSteering|SetSlipSteering|SetEBrakeEffect|SetCMOffsetX|SetCMOffsetY|SetCMOffsetZ|SetSuspensionLimit|SetSpringK|SetDamperC|SetSuspensionYOffset|SetHitPoints|SetBurnoutRange|SetMaxSpeedBurstTime|SetDonutTorque|SetSlipSteeringNoEBrake|SetSlipEffectNoEBrake|SetWeebleOffset|SetWheelieRange|SetWheelieOffsetY|SetWheelieOffsetZ|SetShadowAdjustments|SetShininess|SetDriver|SetGamblingOdds|SetHasDoors|SetCharactersVisible|SetIrisTransition|SetAllowSeatSlide|SetHighRoof|SetCharacterScale|SuppressDriver|InitLevelPlayerVehicle|PlacePlayerCar|AddPurchaseCarReward|SetPostLevelFMV|CreatePedGroup|AddPed|ClosePedGroup|UsePedGroup|BindReward|CreateTrafficGroup|AddTrafficModel|CloseTrafficGroup|SetCarAttributes|SetTotalGags|SetTotalWasps|AddGlobalProp|CreateChaseManager|DisableHitAndRun|EnableHitAndRun|SetHitAndRunMeter|SetNumChaseCars|SetChaseSpawnRate|KillAllChaseAI|ResetHitAndRun|SetHitAndRunDecay|SetHitAndRunDecayInterior|AddMission|AddBonusMission|SetMissionNameIndex|SelectMission|SetMissionResetPlayerInCar|SetMissionResetPlayerOutCar|SetDynaLoadData|AddBonusObjective|SetForcedCar|CloseMission|SetDemoLoopTime|StreetRacePropsLoad|StreetRacePropsUnload|UseElapsedTime|AttachStatePropCollectible|ShowHUD|SetNumValidFailureHints|AddStage|SetStageMessageIndex|SetStageTime|AddStageTime|AddStageVehicle|MoveStageVehicle|ActivateVehicle|AddStageWaypoint|AddStageCharacter|AddStageMusicChange|SetStageMusicAlwaysOn|SetCompletionDialog|StageStartMusicEvent|SetMusicState|SetStageCamera|RESET_TO_HERE|SetMaxTraffic|AddSafeZone|SetBonusMissionStart|ShowStageComplete|SetHUDIcon|SetIrisWipe|SetFadeOut|CloseStage|SetVehicleAIParams|PlacePlayerAtLocatorName|msPlacePlayerCarAtLocatorName|SwapInDefaultCar|SetSwapPlayerLocator|SetSwapDefaultCarLocator|SetSwapForcedCarLocator|NoTrafficForStage|ClearTrafficForStage|SetStageAIRaceCatchupParams|SetStageAIEvadeCatchupParams|SetStageAITargetCatchupParams|SetCharacterToHide|SetLevelOver|SetGameOver|StayInBlack|AllowMissionAbort|SetParTime|SetRaceEnteryFee|PutMFPlayerInCar|SetStatepropShadow|AddObjective|CloseObjective|SetDestination|AddNPC|RemoveNPC|AddDriver|RemoveDriver|SetTalkToTarget|SetDialogueInfo|SetDialoguePositions|SetRaceLaps|TurnGotoDialogOff|MustActionTrigger|SetCoinFee|SetDurationTime|AddCollectible|SetCollectibleEffect|BindCollectibleTo|AllowUserDump|SetVehicleToLoad|SetObjTargetVehicle|SetObjDistance|SetObjTargetBoss|AddCollectibleStateProp|SetPickupTarget|AllowRockOut|AddCondition|CloseCondition|SetFollowDistances|SetCondTargetVehicle|SetConditionPosition|SetCondTime|SetHitNRun|EnableTutorialMode|SetConversationCamName|SetConversationCamPcName|SetConversationCamNpcName|SetConversationCam|SetConversationCamDistance|AmbientAnimationRandomize|ClearAmbientAnimations|AddAmbientPcAnimation|AddAmbientNpcAnimation|CharacterIsChild|SetPresentationBitmap|SetAnimCamMulticontName|SetAnimatedCameraName|SetMissionStartMulticontName|SetMissionStartCameraName|SetCamBestSide|SetFMVInfo|StartCountdown|AddToCountdownSequence|SetCarStartCamera|GoToPsScreenWhenDone|SetPlayerCarName|SetCondMinHealth|LoadP3DFile|LoadDisposableCar|SetRespawnRate|AddCharacter|AddNPCCharacterBonusMission|SetBonusMissionDialoguePos|AddAmbientCharacter|AddBonusMissionNPCWaypoint|AddObjectiveNPCWaypoint|AddAmbientNPCWaypoint|AddPurchaseCarNPCWaypoint|ActivateTrigger|DeactivateTrigger|CreateAnimPhysObject|CreateActionEventTrigger|LinkActionToObjectJoint|LinkActionToObject|SetCoinDrawable|SetParticleTexture|SetCharacterPosition|ResetCharacter|AddTeleportDest|SetInitialWalk|AddVehicleSelectInfo|ClearVehicleSelectInfo|AddFlyingActor|AddFlyingActorByLocator|AddBehaviour|SetCollisionAttributes|AddSpawnPoint|AddSpawnPointByLocatorScript|SetProjectileStats|PreallocateActors|SetActorRotationSpeed|AddShield|ClearGagBindings|AddGagBinding|GagBegin|GagSetInterior|GagSetCycle|GagSetWeight|GagSetSound|GagSetTrigger|GagPlayFMV|GagSetPosition|GagSetRandom|GagSetIntro|GagSetOutro|GagSetCameraShake|GagSetCoins|GagSetSparkle|GagSetAnimCollision|GagEnd|GagSetLoadDistances|GagSetSoundLoadDistances|GagSetPersist|GagCheckCollCards|GagCheckMovie|AddVehicleCharacter|AddVehicleCharacterSuppressionCharacter|SetConditionalParameter|SetVehicleCharacterAnimation|SetVehicleCharacterJumpOut|SetVehicleCharacterScale|SetVehicleCharacterVisible|SetCarChangeHitAndRunChange|SetHitAndRunDecayHitAndRun|SetHitAndRunFine|AddParkedCar|SetHUDMapDrawable|SetParkedCarsEnabled|SetPedsEnabled|UseTrafficGroup|AddStageVehicleCharacter|DisableTrigger|RemoveStageVehicleCharacter|ResetStageHitAndRun|SetNoHitAndRunMusicForStage|SetStageAllowMissionCancel|SetStageCarChangeHitAndRunChange|SetStageCharacterModel|SetStageHitAndRun|SetStageHitAndRunDecay|SetStageHitAndRunDecayHitAndRun|SetStageHitAndRunDecayInterior|SetStageHitAndRunFine|SetStageNumChaseCars|SetStagePayout|SetStageVehicleAllowSeatSlide|SetStageVehicleCharacterAnimation|SetStageVehicleCharacterJumpOut|SetStageVehicleCharacterScale|SetStageVehicleCharacterVisible|SetStageVehicleNoDestroyedJumpOut|SetStageVehicleReset|AddObjTargetModel|SetObjCameraName|SetObjMulticontName|SetObjCanSkip|SetObjDecay|SetObjExplosion|SetObjMessageIndex|SetObjNoLetterbox|SetObjSound|SetObjSpeedKMH|SetObjThreshold|SetObjTotal|SetObjTrigger|SetObjUseCameraPosition|AddCondTargetModel|SetCondDecay|SetCondDelay|SetCondDisplay|SetCondMessageIndex|SetCondSound|SetCondSpeedRangeKMH|SetCondThreshold|SetCondTotal|SetCondTrigger"
functions = functions.split("|")


def openFile():
    Ogfile = filedialog.askopenfile(filetypes=[("MFK Files", "*.mfk")])
    if Ogfile:
        print("\nReading MFK")
        file = Ogfile.read()

        print("Converting MFK features into LUA")
        file = file.replace("\\","\\\\")
        file = file.replace(";","")
        file = file.replace("//","--")

        print("Formatting Functions")
        for each in functions:
            file = file.replace(f"{each}(",f"Game.{each}(")

        print("Creating new file and writing new script\n")
        newFile = Ogfile.name[:-3]+"lua"
        with open(newFile,"w+") as new:
            new.write(file)
        print("Done")



openbutton=Button(root,text="Click Me and Select an MFK",command=openFile,width=50,height=25)
openbutton.pack(side=BOTTOM)

print("Running Window")
root.mainloop()
Unsubscribe from this topic
Please login to contribute to the conversation.