×

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
  • /
  • NPC Handler Class
NPC Handler Class
Bolodefchoco
« Sénateur »
1529944260000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#1
  7
  • NPC
  • Tree
  • Fields
  • Functions
  • Frame collections
https://github.com/Lautenschlager-id/Transformice/blob/master/Others/NPC%20class.lua
A class to manipulate animation and callbacks of NPCs.

What can you do with this?

https://i.gyazo.com/efbd6a89387eadf03a9c5e59b453b521.gif



Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
local bot = npc("Wu", {	
sit = { "164c8600043" },
run = { "164c85b34f5", "164c85b4cd1", "164c85b6580", "164c85bc5d0", "164c85bddac" }
}, "!0"):setPosition(-30, 310):setState("run")

bot:setAction(function(i)
bot.x = bot.x + 10

if bot.x >= 430 then
bot.x = bot.x + 30
bot:setState("sit"):static()
end
end)

https://github.com/Lautenschlager-id/Transformice/blob/master/Others/NPC%20class.lua
npc
    :deleteCallback
    :destroy
    :getAction
    :getCollection
    :getId
    :getLayer
    :getName
    :getState
    :removeAction
    :removeName
    :setAction
    :setCallback
    :setDimension
    :setPosition
    :setState
    :static

    x
    y
    w
    h
https://github.com/Lautenschlager-id/Transformice/blob/master/Others/NPC%20class.lua
• npc.data
 The table containing all the frame collections of the NPC.

• npc.x
 The horizontal position of the NPC.

• npc.y
 The vertical position of the NPC.

• npc.w
 The NPC's width.

• npc.h
 The NPC's height.
https://github.com/Lautenschlager-id/Transformice/blob/master/Others/NPC%20class.lua
• npc ( name, collection, layer )
 Creates a NPC instance.
 Parameters:
  - data (string) : the name of the NPC.
  - collection (table) : the frame collections of the NPC.
  - layer (string) : the target of the frames of the NPC.
 Returns: (npc) self


• npc:deleteCallback ( [ playerName ] )
 Removes the callback of the NPC, if set.
 Parameters:
  - playerName (string) : the name of the player that won't see the callback anymore
 Returns: (npc) self


• npc:destroy ( super )
 Removes the NPC.
 Parameters:
  - super (boolean) : if the name must be removed too
 Returns: (npc) self


• npc:getAction ( )
 Gets the action/animation of the NPC.
 Returns: (function | nil) the NPC's action


• npc:getCollection ( )
 Gets the frame collections of the NPC.
 Returns: (table) the frame collections of the NPC


• npc:getId ( )
 Gets the ID of the NPC.
 Returns: (int) the NPC's ID


• npc:getLayer ( )
 Gets the layer / target of the NPC.
 Returns: (string) the NPC's target


• npc:getName ( )
 Gets the name of the NPC.
 Returns: (string | nil) the NPC's name


• npc:getState ( )
 Gets the current frame collection of the NPC.
 Returns: (table) the current frame collection of the NPC


• npc:removeAction ( )
 Destroyes the action/animation of the NPC, if set.
 Returns: (npc) self


• npc:removeName ( [ playerName ] )
 Removes the name of the NPC.
 Parameters:
  - playerName (string) : the name of the player that won't see its name anymore
 Returns: (npc) self


• npc:setAction ( [ event[, static] ] )
 Sets the action/animation of the NPC.
 Parameters:
  - event (function) : the function to be executed in/for each frame. Receives the current frame, mutable with a return
  - static (boolean) : whether the NPC will be static or not
 Returns: (npc) self


• npc:setCallback ( eventName[, event] )
 Sets the callback of the NPC, so it triggers the callback when the image is clicked.
 Parameters:
  - eventName (string) : callback's name
  - event (function) : function triggered when the callback is called
 Returns: (npc) self


• npc:setDimension ( width, height )
 Sets the NPC size/dimension (for callbacks, only).
 Parameters:
  - width (int) : the NPC's width. (default = 1)
  - height (int) : the NPC's height. (default = 1)
 Returns: (npc) self


• npc:setPosition ( x, y )
 Sets the NPC's position.
 Parameters:
  - x (int) : the horizontal position of the NPC. (default = 0)
  - y (int) : the vertical position of the NPC. (default = 0)
 Returns: (npc) self


• npc:setState ( newState )
 Defines the current frame collection of the NPC.
 Parameters:
  - newState (string) : the name of the frame collection.
 Returns: (npc) self


• npc:static ( )
 Sets the NPC as static (that doesn't move) and ends all the actions.
 Returns: (npc) self

https://github.com/Lautenschlager-id/Transformice/blob/master/Others/NPC%20class.lua
To initialize your NPC, create a new instance of npc with a frame collection.
Each collection is a table, containing its name and the images.

Code Lua

1
2
3
4
5
6
{ -- Collections
sit = { -- Collection name
"164c8600043" -- Collection images, in order
},
run = { "164c85b34f5", "164c85b4cd1", "164c85b6580", "164c85bc5d0", "164c85bddac" }
}


Dernière modification le 1566684600000
Massi
« Consul »
1529944500000
    • Massi#0095
    • Profil
    • Derniers messages
    • Tribu
#2
  1
Nice job Bolo !!! <3
Ace
« Consul »
1529949720000
    • Ace#1270
    • Profil
    • Derniers messages
#3
  1
Good job. !:)
Honorabilis
« Consul »
1530001920000
    • Honorabilis#0000
    • Profil
    • Derniers messages
    • Tribu
#4
  1
Good job!
Bishomilad
« Citoyen »
1531140900000
    • Bishomilad#0000
    • Profil
    • Derniers messages
#5
  1
it's perfect bolo
Bolodefchoco
« Sénateur »
1532904480000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#6
  0
Thread updated. New functions and bug fixes!
Sebafrancuz
« Consul »
1532950620000
    • Sebafrancuz#0000
    • Profil
    • Derniers messages
    • Tribu
#7
  1
Good job
Ae_86
« Consul »
1535339820000
    • Ae_86#5182
    • Profil
    • Derniers messages
    • Tribu
#8
  1
OP as usual
Omarpasha
« Citoyen »
1536364740000
    • Omarpasha#9629
    • Profil
    • Derniers messages
    • Tribu
#9
  1
Is that work out of tribehouse only ? there is an "addImage" on code.
Sebafrancuz
« Consul »
1536406740000
    • Sebafrancuz#0000
    • Profil
    • Derniers messages
    • Tribu
#10
  2
Omarpasha a dit :
Is that work out of tribehouse only ? there is an "addImage" on code.

No, it doesn't work in tribehouse, you can ask anyone from Module Team to launch code for you.
Flasher
« Citoyen »
1546027440000
    • Flasher#4080
    • Profil
    • Derniers messages
    • Tribu
#11
  0
not working !
Bolodefchoco
« Sénateur »
1546030140000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#12
  0
Flasher a dit :
not working !

You have to be a module team member in order to test it correctly, since it uses images and timers.
Flasher
« Citoyen »
1546432440000
    • Flasher#4080
    • Profil
    • Derniers messages
    • Tribu
#13
  0
• # [*SomeReach] Init Error : [string "Flasher#4080.lua"]:13: unfinished string
Bolodefchoco
« Sénateur »
1546433460000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#14
  0
Flasher a dit :
• # [*SomeReach] Init Error : [string "Flasher#4080.lua"]:13: unfinished string

it's your script then, cuz line 13 there's not a string in the source
Ahmadmide
« Consul »
1546500180000
    • Ahmadmide#0000
    • Profil
    • Derniers messages
    • Tribu
#15
  0
Good job. !:
Mikou20
« Citoyen »
1680811920000
    • Mikou20#6075
    • Profil
    • Derniers messages
    • Tribu
#16
  0
... not working :/
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • NPC Handler Class
© Atelier801 2018

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

Version 1.27