Announcement

Collapse
No announcement yet.

Script Docu v1

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Added player.weapondata, this.weapondata, Server.getconfig, added the description in the first post :-)
    Also known as Daddy and bomber
    Avalonia Facebook Avalonia iOS Avalonia Android
    Corleone Facebook Corleone Online Download

    Comment


    • #17
      Testing the new functions 😁
       

      Comment


      • #18
        Client-Scripting It cannot do a lot yet, but you can open popups and check which button the user has clicked and send it to the server :-)

        Click image for larger version  Name:	Bildschirmfoto 2018-10-21 um 21.32.17.png Views:	1 Size:	278.2 KB ID:	4594Click image for larger version  Name:	clientscripting_small.png Views:	1 Size:	827.2 KB ID:	4595

        Client:
        PHP Code:
        function onPlayerTouchsMe(pl) {
        //    play("cry");
            
        var popup GUI.showpopup({
                
        title"Welcome to " Server.getconfig().gamename "!",
                
        width400,
                
        height300
            
        });
            
        popup.innerHTML '<br><center>Hmmm cool!</center>' +
                
        '<img src="../files/icons/corleone_icon_spar.png">' +
                
        '<input id="actionbutton1" type="submit" class="button" style="left:100px;top:160px;width:200px;height:40px;" value="Button 1!"></input>' +
                
        '<input id="actionbutton2" type="submit" class="button" style="left:100px;top:220px;width:200px;height:40px;" value="Button 2!"></input>';

            var 
        self this;
            
        GUI.onclick("actionbutton1", function(event) {
                
        GUI.hidepopup();
                
        self.triggerserver("clicked""button1");
            });
            
        GUI.onclick("actionbutton2", function(event) {
                
        GUI.hidepopup();
                
        self.triggerserver("clicked""button2");
            });

        Server:
        PHP Code:
        function onClientClicked(plbuttonname) {
            
        this.say(pl.name " clicked on " buttonname);

        Last edited by Stefan; 11-18-2018, 09:33 PM.
        Also known as Daddy and bomber
        Avalonia Facebook Avalonia iOS Avalonia Android
        Corleone Facebook Corleone Online Download

        Comment


        • #19
          New functionality:
          - this.shoot([weaponitemid]) - shoots with the current weapon or the specified weapon item
          - this.dir = dir / this.setdir(dir) - you can now change the direction (1..4)
          - this.triggerclient(player or id, action [, ...params]) - sends a trigger to the client script of the NPC

          Example:
          PHP Code:
          function onPlayerTouchsMe(pl) {
              
          this.triggerclient(pl"showgui""Hello 123");

          Client-Script:
          PHP Code:
          function onServerShowGUI(pltext) {
              echo(
          "trigger: " text);


          - Clientside:
          - this.image = image / this.setimg(image)
          - this.head, this.body, this.hat can be changed
          - this.chat and player.chat can be changed (not sent to the server, not seen by other players)
          - this.color = [1,1,1,0.5] -> set the color of NPCs or players on client-side, it's [red, green, blue, alpha] in a range from 0 to 1
          - this.nonblocking, this.drawunder
          - this.settimeout and this.scheduleevent are also working on clientside now
          Last edited by Stefan; 11-01-2018, 11:05 PM.
          Also known as Daddy and bomber
          Avalonia Facebook Avalonia iOS Avalonia Android
          Corleone Facebook Corleone Online Download

          Comment


          • #20
            New script events on both server and client:
            - onPlayerAttacks(player) - Player uses a melee attack on the NPC
            - onPlayerHammers(player) - Player uses a hammer or pick axe on the NPC
            - onPlayerPicks(player) - Player uses the trashpick on the NPC
            - onMouseDown(player) - Player clicks on the NPC (now only mouse clicks or tap, previously this event was also fire when attacking with melee weapon)
            Also known as Daddy and bomber
            Avalonia Facebook Avalonia iOS Avalonia Android
            Corleone Facebook Corleone Online Download

            Comment


            • #21
              Great!! Thank you 🤗

              Comment


              • #22
                Another big script update:
                Some weirdness when calling other functions have been fixed: you can now access the this. object correctly and also call functions by this.functionname.
                Additionally you can now change this.hp and this.maxhp. Once you set this.hp, the object can be attacked by player, it's automatically calculating the damage based on the players weapon, the NPC hp and the NPC armor/body level as defined in items.json. An example of a barrel which can be shot:

                PHP Code:
                function onUpdated() {
                    
                this.onRespawn();
                }
                function 
                onMouseDown() {
                    
                this.say("HP: " this.hp "/" this.maxhp3);
                }
                function 
                onDeath(pl) {
                    
                this.chat "killed by " pl;
                    
                this.ani "explode";
                    
                this.scheduleevent(1"respawn");
                }
                function 
                onRespawn() {
                    
                this.image "barrel.png";
                    
                this.chat "";
                    
                this.hp this.maxhp 50;

                Also known as Daddy and bomber
                Avalonia Facebook Avalonia iOS Avalonia Android
                Corleone Facebook Corleone Online Download

                Comment


                • #23
                  Awesomee Idk whatz this

                  Comment


                  • #24
                    Some GUI tricks:
                    NPC opens a menu with text input and select box when grabbing:

                    PHP Code:
                    function onPlayerGrabs(pl) {
                        var 
                    popup GUI.showpopup({
                            
                    title"Welcome to " Server.getconfig().gamename "!",
                            
                    width400,
                            
                    height300
                        
                    });
                        
                    popup.innerHTML '<br><center>Enter text:</center>' +
                            
                    '<input id="textfield" type="text" style="position:absolute;left:80px;top:100px;width:300px;height:30px;" value="Texttt"></input>' +
                            
                    '<select id="selectfield" style="position:absolute;left:80px;top:140px;width:300px;height:40px;font-size:24px;">' +
                            
                    '  <option>SWORD</option>' +
                            
                    '  <option selected>HEAD</option>' +
                            
                    '  <option>BODY</option>' +
                            
                    '</select>' +
                            
                    '<input id="actionbutton1" type="submit" class="button" style="left:132px;top:250px;width:200px;height:40px;" value="Finish"></input>';

                        var 
                    self this;
                        
                    GUI.onclick("actionbutton1", function(event) {
                            
                    pl.chat "text: " GUI.get("textfield").value " - " GUI.get("selectfield").value;
                            
                    GUI.hidepopup();
                        });

                    Click image for larger version  Name:	Bildschirmfoto 2018-11-18 um 23.08.31.png Views:	1 Size:	574.5 KB ID:	4647

                    Using the GUI object you can access GUI (HTML Dom objects):

                    GUI.showpopup({title:string, width:integer, height:integer}) - shows a popup
                    GUI.hidepopup() - hides a popup
                    GUI.get("id") - finds the GUI/dom object
                    GUI.exists("id") - checks if a GUI object exists
                    GUI.show("id" or object) - shows an object
                    GUI.hide("id" or object) - hides an object
                    GUI.onclick("id", function(event) { }) - catches the click event

                    Examples:
                    PHP Code:
                    // Hide button by id
                    GUI.hide("actionbutton1");

                    // Hide button by object
                    let button GUI.get("actionbutton1");
                    GUI.hide(button);

                    // Get current value of text inputs or select fields
                    let value GUI.get("textfield").value;
                    echo(
                    "value: " value); // prints it on browser developer console

                    // Change the text of a text input
                    GUI.get("textfield").value "hmmm"
                    Last edited by Stefan; 11-18-2018, 10:13 PM.
                    Also known as Daddy and bomber
                    Avalonia Facebook Avalonia iOS Avalonia Android
                    Corleone Facebook Corleone Online Download

                    Comment


                    • #25
                      The Legend of Programming. 😊👌

                      Comment


                      • #26
                        Awesome. Keep up the work Stefan!

                        Comment


                        • #27
                          Added some more variables and functions (on testbed):
                          - player.isdead, npc.isdead
                          - this.map.iswater(x, y), this.map.iswall(x, y), this.map.iswall(x, y, true) -> only checks tiles
                          - Server.searchnpcs({map, area:{x,y,w,h}})
                          Example triggering other NPCs:
                          PHP Code:
                          function onUpdated(pl) {
                              
                          let npcs Server.searchnpcs({
                                  
                          mapthis.map,
                                  
                          area:{x:this.x-20y:this.y-20w:40h:40}
                              });
                              for (
                          let i in npcs)
                                  
                          npcs[i].scheduleevent(0"otherevent"this);
                          }
                          function 
                          onOtherEvent(caller) {
                              echo(
                          "called NPC: " this.id " from " caller.id);

                          Add the onOtherEvent function to the other NPCs to see them triggered.
                          Also known as Daddy and bomber
                          Avalonia Facebook Avalonia iOS Avalonia Android
                          Corleone Facebook Corleone Online Download

                          Comment


                          • #28
                            perfect!!

                            Comment


                            • #29
                              hola soy nuevo necesito que e ayudo para ser admin

                              Comment

                              Working...
                              X