Thread Status:
Not open for further replies.
  1. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    The Oxide project has come a long way over the past year, growing into one of the most popular mod frameworks for Rust! With the release of Oxide 2 alpha builds, the Oxide project took it a step further by providing a modular platform that could potentially be used on any .NET or Unity game! Currently it only supports Rust Experimental, but games such as The Forest, 7 Days to Die, and more could be making an appearance in the Oxide community in the near future...

    The progress can't be credited to a single person though; many of the dedicated community members have been actively helping push development forward, despite @thomasfn being away. Members such as @Reneb, @Hatemail, @Mughisi, and @bawNg have spend numerous hours pouring through code to develop plugins and contribute toward the project. One member, @Nogrod, has recently created a couple extensions to expand the language options for plugins, as well as improve on the existing option.

    So without further ado, I give you the first LuaJIT, JavaScript, and Python release build! It introduces support for JavaScript plugins, Python plugins, as well as adding LuaJIT for vastly improved Lua plugin performance. We'd love for you to test the JavaScript and Python support, but keep in mind that the JavaScript and Python support is new, so there may still be a few issues with them. If you want the best performance though, we would recommend sticking to Lua plugins for now. The JavaScript extension may receive a bit of a boost with the Google V8 engine, but we'll see! Enjoy, and thanks for being part of the Oxide community!

    Download: http://oxidemod.org/downloads/oxide-2-for-rust-experimental.714/

    I've also provided a couple example plugins below, courtesy of @Nogrod.

    Basic JavaScript plugin example (JsTest.js):
    Code (Javascript):
    var JsTest = {
        Title : "Javascript Test",
        Author : "Nogrod",
        Version : V(1, 0, 0),
        HasConfig : true,
        Init : function () {
            print("JavaScript: Init");
        },
        OnServerInitialized : function () {
            globalVar = "moep";
            print("JavaScript: OnServerInitialized");
            command.AddConsoleCommand("server.jshi", this.Plugin, "sayhi");
        },
        LoadDefaultConfig : function () {
            print("JavaScript: LoadDefaultConfig");
            this.Config.authLevel = 1;
            this.Config.Data = ["blubb1", "blubb2"];
            this.Config.Extra = { "oink" : "moep" };
        },
        RequestResult : function (code, response) {
            print(this.Title+"|"+code+"|----|"+response);
        },
        sayhi : function () {
            print("JavaScript: sayhi");
            print(globalVar);
            var global = importNamespace("");
            print(global.BasePlayer.activePlayerList.Count);
            var url = "http://loripsum.net/generate.php?p=1&l=short";
            webrequests.EnqueueGetHook(url, "RequestResult",  this.Plugin);
            webrequests.EnqueueGet(url, this.RequestResult.bind(this),  this.Plugin);
            webrequests.EnqueueGet(url, function(code, response) { print(code+"|----|"+response); },  this.Plugin);
            webrequests.EnqueueGet(url, function(code, response) { print(this.Title + "|" + code+"|----|"+response); }.bind(this),  this.Plugin);
            dataObj = data.GetData("jstest");
            dataObj.oink = "walla";
            dataObj.moep = [{}, "oink", 12345];
            data.SaveData("jstest");
            print("hi from js!" + dataObj.oink);
            var Rust = importNamespace("Rust");
            var obj = new Rust.DamageTypeList();
            print("obj created");
            try {
                print("total: " + obj.Total());
                print("total: " + obj.total());
            } catch (e) {
                print(e.message.toString());
            }
            print(Object.keys(obj).join());
        }
    }
    Basic Python plugin example (PyTest.py):
    Code (Python):
    import Rust
    class PyTest:
        def __init__(self):
            self.Title = "Test Plugin"
            self.Author = "Nogrod"
            self.Version = V(1, 0, 0)
            self.HasConfig = True
        def OnServerInitialized(self):
            command.AddConsoleCommand("server.sayhi", self.Plugin, "sayhi")
            print "server init"
            print self.Plugin.Title
        def LoadDefaultConfig(self):
            self.Config["authLevel"] = 1
            self.Config["moep"] = (1, 0, 1)
            self.Config["narf"] = { "entry1" : "oink", "entry2" : "blubb" }
        def sayhi(self, arg):
            self.Config["authLevel"] = 2
            self.SaveConfig()
            dataObj = data.GetData("Test")
            dataObj["oink"] = "walla"
            dataObj["moep"] = { "blubb" : 12232 }
            dataObj["narf"] = (1, "moep", {})
            data.SaveData("Test")
            print "hi"
            obj = Rust.DamageTypeList()
            print obj.Total()
     
  2. Upperking

    Upperking Master Researcher Server Owner

    Wheres the folders on the server to put the javascripts?
    just use the plugins folder?
     
  3. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    All plugins go in the same folder, yes.
     
    LEO318x likes this.
  4. ColonelAngus

    ColonelAngus Wood Hoarder Plugin Developer

    Is there an API we can view for javascript? Online preferably
     
  5. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    The Oxide hooks used for JavaScript are the same as with Lua. The only examples are from currently available plugins right now.
     
  6. SkinN õ.Õ'.|.

    SkinN õ.Õ'.|. Grenade Master Plugin Developer

    What about Python? Where can I see what libraries I can use?
    Cuz if we had access to the libraries files would be very cool.

    SkinN!
     
  7. Wulf

    Wulf Community Admin Community Admin Oxide Developer

  8. ColonelAngus

    ColonelAngus Wood Hoarder Plugin Developer

    Is there an API for any of the languages we can use? Not knowing what methods we can call on anything makes this pretty tough
     
  9. Wulf

    Wulf Community Admin Community Admin Oxide Developer

  10. SPooCK

    SPooCK Wood Hoarder Plugin Developer

    So can you give some example for a Init() hook with JS without putting all the stuffs in var or it have to be in var ? Just can't get the hang of it the Syntax is confusing me...
     
  11. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    It has to be in the var. The Init() hook is the same as any other, and is shown in the example.
     
  12. SPooCK

    SPooCK Wood Hoarder Plugin Developer

    Well i think putting in var means it can't be called out from any other plugin ? Because as far as i know var is like a local and if i'm in a mistake can you give example calling a hook from one JS plugin to another ?
    --- Double Post Merged, Feb 5, 2015 ---
    Or can you atleast explain how i can call a normal chat cmd because seems this won't work for me... I really like JS above all other languages and just can't get the hang of it right now...
    Code (Javascript):
    var jstest = {
       
    Title:"Javascript Test",
    Author:"SPooCK",
    Version:V(1, 0, 0),
    HasConfig:false,
       
    Init:function() {
        command.AddChatCommand("test", this.Plugin, "Test");
    },

    Test:function(player, cmd, args) {
        rust.SendChatMessage(player, "TEST", "WORKING");
    }
    }
     
  13. Nogrod

    Nogrod Shotgun Ace Oxide Developer

    hopefully all you requested ;)
    Code (Javascript):
    var jstestone = {
        Title : "Javascript Test One",
        Author : "Nogrod",
        Version : V(1, 0, 0),
        Init : function () {
            print("JavaScriptOne: Init");
        },
        OnServerInitialized : function () {
            print("JavaScriptOne: OnServerInitialized");
        },
        SomeMethod : function (arg1, arg2) {
            print("JavaScriptOne: SomeMethod: arg1: " + arg1 + " arg2: " + arg2);
        }
    }
    Code (Javascript):
    var jstesttwo = {
        Title : "Javascript Test Two",
        Author : "Nogrod",
        Version : V(1, 0, 0),
        Init : function () {
            print("JavaScriptTwo: Init");
        },
        OnServerInitialized : function () {
            print("JavaScriptTwo: OnServerInitialized");
            var jsTestOne = plugins.Find("jstestone");
            jsTestOne.Plugin.CallHook("SomeMethod", [10, "hi first"]);
            jsTestOne.SomeMethod(10, "hi two");
            command.AddChatCommand("jstest", this.Plugin, "cmdTest");
        },
        cmdTest : function(player, cmd, args) {
            rust.SendChatMessage(player, "TEST", "WORKING", "0");
        }
    }
     
  14. SPooCK

    SPooCK Wood Hoarder Plugin Developer

    Tnx that gived me the basic i needed ! Now i can do all the rest by myself :) And the hell didnt know i need to put "0" in the end here rust.SendChatMessage(player, "TEST", "WORKING", "0"); :D
     
  15. Risin

    Risin Naked Wanderer Plugin Developer

    How does the config file work....I dont see your changes actually being saved after intial write.
     
  16. Hatemail

    Hatemail Shotgun Ace Plugin Developer

    The saving after initial write is automatically done by Oxide.Core
    If you want to save it after a change call the SaveConfig function.
     
  17. Shotgun Teddy

    Shotgun Teddy Wood Hoarder

    File no longer exists on Github wulf.
    Trying to get Visual Studio setup properly to begin developing some plugins for Rust. Checked out Docs and Rust API, don't know where to find Python related libraries for Rust. A good step-by-step tutorial somewhere on the forums for new Oxide developers would be much appreciated. Not sure if I have everything I need already, or missing everything.
     
  18. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Oxide/PythonExtension.cs at master · OxideMod/Oxide · GitHub

    I'm not really a Python guy, so someone familiar with that would have to contribute it.
     
  19. Shotgun Teddy

    Shotgun Teddy Wood Hoarder

    Last edited: Jul 14, 2016
  20. gipsun-van(27 Reg)

    gipsun-van(27 Reg) Naked Wanderer

    Dear Wulf, hello! It would be desirable to learn whether it is possible to find and download OXIDE v2.0.1540 for Rust v1336 dev 85. If I addressed not in that subject that prompt, where can I receive the answer to the matter? It is necessary very much!The last version which has found on this website is History for Oxide-Rust.zip - OxideMod/Snapshots · GitHub page=10 1643, and I haven't found 1540 there, perhaps you will help me
     
Thread Status:
Not open for further replies.