Jump to content

Recommended Posts

Hi, basicly i want to make a mod similar as better compass, but instead of reveal the map, hide map if you dont equip the compass.

I was looking some way to do it, 2 ways i think should be paths are working with a keyfuntion change (a realy bad idea for modding in any game) the other is get an black overlay over the map screen. Someone knows other better way? block the function of calling the map is mybe a way but i dont know if the script let you block a funtion temporaly (or something similar) some idea?

To temporarily block a function in LUA is pretty easy if you have access to the function.

Hook the function and in the prehook check your toggle variable, local to the player table or something, and if it's on then don't call the original function.

 

Example in LUA:

-- Given:
a = {}
function a:SomeFunction(a, b, c)
  print(self, a, b, c)
end
player = {}

-- Do:
player.blockmap = false
local SomeFunction_old = a.SomeFunction
a.SomeFunction = function(self, a, b, c, ...)
  if player.blockmap == true
  then
    return
  end
  return SomeFunction_old(self, a, b, c, ...)
end

-- Test:
a:SomeFunction("a", "b")

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...