×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Is there a way to prevent some invocations?
Is there a way to prevent some invocations?
Zerquix
« Citoyen »
1443374460000
    • Zerquix#0000
    • Profil
    • Derniers messages
#1
  0
Hi guys! Today I'm making a LUA script and I'd like to know if there's a way to prevent some invocations. I've tried 2 methods and they didn't work. I'm testing with the cannons, which id is 17:

First one: Trying to return false with the function 'eventSummoningStart':
a dit :

function eventSummoningStart(name, object, x, y, angle)
if object == 17 then
return false
end
end

Since that didn't work I tried to remove the object after it's invocated, but it neither worked

a dit :

function eventSummoningEnd(name, object, x, y, angle, speedx, speedy, object2, table)
if object == 17 then
tfm.exec.removePhysicObject(object)
tfm.exec.removeObject(object)
return false
end
end

Do you have any idea? Or maybe an alternative.
Shamousey
« Consul »
1443375480000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#2
  0
The API's events are independently called from the game's, returning something in them serves no purpose making your first example a bit useless.


As for your second script, it could work but there's a couple of things wrong with it. The second argument which you've named "object" is just the type of object (in this case you're detecting if the type is cannon).

The ID of the spawned object you use to remove it is separate from that though, in this case it's located with the key "id" in the last argument of the function, which you've named "table". Since "table" is already a variable name in Lua it'd be best to avoid calling it that in any scope, so I'll change the name here to "other".

Since returning any values through events are useless and physic objects are grounds (not shaman objects), those two lines can be removed too.

a dit :
function eventSummoningEnd(name, object, x, y, angle, speedx, speedy, object2, other)
if object == 17 then
tfm.exec.removeObject(other.id)
end
end

It's still not a perfect solution, as there's a bit of delay before the object is removed, which means you can still use the momentum from it briefly as it's spawned, but it's the best you'll get unless you consider other solutions such as killing the shaman on eventSummoningStart.
Velspar
« Citoyen »
1443375960000
    • Velspar#0000
    • Profil
    • Derniers messages
    • Tribu
#3
  0
Nvm Im too slow xP -hides-

Also, there is no 'object2' argument.
a dit :
function eventSummoningEnd(name, object, x, y, angle, speedx, speedy, other)
if object == 17 then
tfm.exec.removeObject(other.id)
end
end

Dernière modification le 1443376740000
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Is there a way to prevent some invocations?
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27