Announcement

Collapse
No announcement yet.

NPC scripting on Avalonia?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • NPC scripting on Avalonia?

    Does it work. Like can you put this to a NPC
    function onCreated () ;
    this.chat ("HELLO AVALONIA!") ;
    will it work?
    Level Artist.

  • #2
    Originally posted by CHASE* View Post
    Does it work. Like can you put this to a NPC
    function onCreated () ;
    this.chat ("HELLO AVALONIA!") ;
    will it work?
    I'm not sure. Because those functions must be defined, I believe? I'll ask Stefan or Deas to be sure and give you a 100% sure reply - in case none of those two checks this thread.

    Comment


    • #3
      Originally posted by CHASE* View Post
      Does it work. Like can you put this to a NPC
      function onCreated () ;
      this.chat ("HELLO AVALONIA!") ;
      will it work?
      its not like that, its a whole different command and way of doing it:P
      Last edited by Sp2k; 01-25-2017, 10:50 PM.

      Comment


      • #4
        Originally posted by Sp2k View Post

        its not like that, its a whole different command and way of doing it:P
        Javascript?
        Level Artist.

        Comment


        • #5
          Originally posted by CHASE* View Post

          Javascript?
          Yes, JavaScript.

          Comment


          • #6
            Short answer is No.

            The long answer is that the game is web-based, and because of that, Javascript is everywhere;
            the even further longer answer is sort of yes but still no- in the future there might be a implementation of a custom or near-javascript ability to make your own npc's live inside the game. this is not set in stone and very little to no work has been put into this.
            Ditto Loves you.

            Comment


            • #7
              Avalonia uses classes for NPCs.
              An example script:

              PHP Code:
              Peg Newnpc.extend({
                  
              initAfterLoad: function() {
                  },

                  
              onClientTrigger: function(playeractiondata) {
                      if (
              action == "activate")
                          
              this.onPegActivate(playerdata.type);
                  },

                  
              onPegActivate: function(playeractivatetype) {
                      if (
              activatetype != "hammer") {
                          
              this.showChatToPlayer(player5"Get a hammer to open this!");
                          return;
                      }
                      if (
              this.image != "bbuilder_peg.png")
                          return;

                      
              this.sendObjectData({image:"bbuilder_peg_down.png"drawunder1nonblocking1});
                      var 
              self this;
                      
              this.respawntimeout setTimeout(function() {
                          
              self.sendObjectData({image:"bbuilder_peg.png"drawunder0nonblocking0});
                      }, 
              10 1000);
                  }
              }); 
              Also known as Daddy and bomber

              Comment


              • #8
                We should add a scripting development forum section ☺️
                Also known as Daddy and bomber

                Comment


                • #9
                  Originally posted by Stefan View Post
                  Avalonia uses classes for NPCs.
                  An example script:

                  PHP Code:
                  Peg Newnpc.extend({
                  initAfterLoad: function() {
                  },

                  onClientTrigger: function(playeractiondata) {
                  if (
                  action == "activate")
                  this.onPegActivate(playerdata.type);
                  },

                  onPegActivate: function(playeractivatetype) {
                  if (
                  activatetype != "hammer") {
                  this.showChatToPlayer(player5"Get a hammer to open this!");
                  return;
                  }
                  if (
                  this.image != "bbuilder_peg.png")
                  return;

                  this.sendObjectData({image:"bbuilder_peg_down.png"drawunder1nonblocking1});
                  var 
                  self this;
                  this.respawntimeout setTimeout(function() {
                  self.sendObjectData({image:"bbuilder_peg.png"drawunder0nonblocking0});
                  }, 
                  10 1000);
                  }
                  }); 
                  What about ES6 / Babel class syntax? - Codein
                  a.k.a Codein, jwd, etc

                  Comment


                  • #10
                    On server you can use the latest nodejs stuff
                    Also known as Daddy and bomber

                    Comment


                    • #11
                      Oh wow this is awesome. It'd be interesting to see if rxjs has uses here.
                      a.k.a Codein, jwd, etc

                      Comment


                      • #12
                        I have no idea what is going on so I'm just say seems cool lol

                        Comment

                        Working...
                        X