Forum Mod Bakery Docs

LUA Hack Request

Please login to contribute to the conversation.
Could we get a LUA thread that runs independently of file loads with the ability to interact with real-time things such as Hit & Run level, coins, vehicle health, etc.
A useful addition would be event handlers for changes on those variables, rather than having to use a loop to check the values manually.
So at the risk of revealing too much information, this is something that has been worked on. It currently is a shelved project simply because of the complexity of it, but it is something Loren and I have been really pushing for to extend the possibilities in modding.

Right now it is pretty barebones and doesn't exactly support any of the examples you listed. The difficulty of adding and maintaining it is what is holding Lucas back from making it at the moment. There was actually a point where we discussed getting rid of a lot of hacks in favor of making mod counterparts that can be done in Lua.

For example, using this new system, this code right here would spawn in explosions around the player every second.
local NextExplosionTime = Engine.Clock.GetTime()+Engine.Clock.GetFrequency()

Engine.EventSystem.GetEventType("OnProcess"):AddHandler(function (Event)
	local Time = Engine.Clock.GetTime()
	if Time >= NextExplosionTime then
		NextExplosionTime = Time+Engine.Clock.GetFrequency()
		local State = Engine.Game.GetState()
		if State == 4 or State == 7 or State == 9 then
			local X,Y,Z = Engine.Game.GetPlayerPosition()
			X = X+math.random()*20-10
			Z = Z+math.random()*20-10
			Engine.Game.CreateExplosion(24+1,X,Y,Z,0.25)
			Engine.Game.PlaySound("generic_car_explode",1.0,1.0)
		end
	end
end)

An example of this code in action:
Now that looks very promising. I hope that can at least be in a beta phase soon. I'm itching to play with that.
If this were to get released, it would probably make for some really cool mod concepts honestly. I know like practically no LUA but I'm sure some talented people could make some amazing stuff with these kind of powers.

Even just that explosion effect there could probably be used to good effect with some kind of 'attack' thing like missiles are falling from the sky and stuff. Really exiting stuff!
It opens the door for collaborative mods too, I have no talent for story writing, but could definitely assist with things like this