Greasy Fork is available in English.

Woomy Modding Api

A modding api for woomy.surge.sh

Forfatter
Drako Hyena
Daglige installasjoner
0
Totale installasjoner
0
Vurderinger
0 0 0
Versjon
1.8
Lagd
03.08.2022
Oppdatert
24.08.2022
Lisens
I/T
Gjelder

Intro

This is a modding api for Oblivion's version of woomy. Most of the API is in window.WMA


Methods

window.WMALoadqueue

The WMALoadQueue will call all functions inside it once WMA has been loaded. This is a vital bit of code that will be included in every example.

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}
function run(){
  console.log("The API "+window.WMA.loaded?"has":"hasnt"+" loaded") // Logs "The API has loaded" every time
}

window.WMA.packets

window.WMA.packets is an object that has a few things in it, this object is used to use packets. Theres two categories window.WMA.packets.send and window.WMA.packets.receive send are the packets that are sent from the client and receive are the packets sent to the client, Everything after this applies to both. The first thing in it is an array called subscriptions where it stores all the subscribed functions. The next thing in it is a sub(<function>) function which adds a function to the subscriptions list and returns its ID. Lastly is an unsub(<subscriptionID>) function which uses an id from sub to delete a function in the subscriptions list.

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}

// Once the api is loaded run this function
function run(){
    let subscribeId = window.WMA.packets.send.sub(packetLogger)// Start the logger
    let subscribeId2 = window.WMa.packets.receive.sub(packetLogger)

    function packetLogger(type, data){
        console.log(type, data)
    }

    setTimeout(()=>{
        window.WMA.packets.send.unsub(subscribeId)// After 30 seconds stop the logger
        window.WMA.packets.receive.sub(subscribeId2)
    }, 30000)
}

window.WMA.entities

window.WMA.entities is another object that has a few things in it, this object is used to get the current entities on screen. The first thing in it is an array called subscriptions where it stores all the subscribed functions. After that is a sub(<function>) function which adds a function to the subscriptions list and returns its ID. Lastly is an unsub(<subscriptionID>) function which uses an id from sub to delete a function in the subscriptions list.

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}
window.WMA.entities.sub((entities)=>{
    console.log(entities)
})

window.WMA.createButton(<name>, <otherinfo>, <onclick>)

window.WMA.createButton creates a button for you in the Mod Menu

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}

// Once the api is loaded run this function
function run(){
    let subscribeId = null;
    function packetSendLogger(type, data){
        console.log(data)
    }

    // Make the button
    let button = window.WMA.createButton("Log Send packets", "disabled", () => {
        // On click run this
        let moreInfo = button.children[1]
        if(moreInfo.innerHTML === "disabled"){// Turn the send logger on
            subscribeId = window.WMA.packets.send.sub(packetSendLogger)
            moreInfo.innerHTML = "enabled"
        }else if(moreInfo.innerHTML === "enabled"){// Turn the send logger off
            window.WMA.packets.send.unsub(subscribeId)
            moreInfo.innerHTML = "disabled"
        }
    })
}

window.WMA.socket

window.WMA.socket is the websocket connected to the server. Its recommended that you dont edit anything in this object. To make full use of this object youll need to look at the client code and find out where it sends packets. The example below is a spawn packet, you can change your name each time you spawn. The example below will not work as is because it requires you to be dead.

let name = "A new name!".split("")
for (let i = 0; i < name.length; i++){
    name[i] = name[i].charCodeAt();// Convert each char into a charcode
}
window.WMA.socket.talk("s", window.WMA.global.party||0, name.toString(), 0)// Send a spawn request with out new name

window.WMA.global

window.WMA.global is a very powerful part of the API. Its the global object where most things are stored for the client. I recommend doing console.log(window.WMA.global) and looking at everything in it. The example below will give you a new name each time you respawn.

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}

// Once the api is loaded run this function
function run(){
    // Every 5 seconds to change my name
    // NOTE: name only updates on respawns
    setInterval(()=>{
        window.WMA.global.playerName = Math.random().toString()
    }, 5000)
}

window.WMA.log([<names>, <string>])

This is an API and its very likely to have multiple scripts running off it. To sort out conflicts between scripts faster its recommended you use this. Below is an example on how to use this.

// Wait for the api to load
if(window.WMA&&window.WMA.loaded){
    run()
}else{
    if(window.WMALoadQueue){
        window.WMALoadQueue.push(run)
    }else{
        window.WMALoadQueue = [run]
    }
}

// Once the api is loaded run this function
function run(){
    window.WMA.log(["NothingScript","Loading"], "loaded with no issues!")
    // OUTPUT
    // [NothingScript][Loading] - loaded with no issues!
}// Wait for the api to load
if(!window.WMA){
    window.WMALoadQueue = [run]
}else{
    run()
}

// Once the api is loaded run this function
function run(){
    window.WMA.log(["NothingScript","Loading"], "loaded with no issues!")
    // OUTPUT
    // [NothingScript][Loading] - loaded with no issues!
}

window.WMA.refreshInputs()

window.WMA.refreshInputs is a great function. It refreshes all the players inputs and focuses on canvas. Due to the ingame settings menu and the mod menu being in html and not part of the canvas youll be focused on them meaning you trying to move your player ingame wont work till you click back on the canvas. Clicking on a menu while moving might make you keep moving in that direction. This function solves all of those problems!

window.WMA.move

window.WMA.move allows you to move your player in that direction. move.up() move.down() move.left() move.right() move.to(x,y,<duration in ms spent moving to there>) move.away(x,y,<duration in ms spent moving to there>) all exist. To stop movement use window.WMA.move.stop() or window.WMA.refreshInputs()

window.WMA.upgradeStat(<stat>)

window.WMA.upgradeStat allows you to upgrade the inputted stat if possible. The stats are "Body Damage", "Max Health", "Bullet Speed", "Bullet Health", "Bullet Penetration", "Bullet Damage", "Reload", "Movement Speed", "Shield Regeneration", and "Shield Capacity"

window.WMA.yourPlayer

window.WMA.yourPlayer is another very powerful part of the API. It contains your players position, your players target (mouse pos), your players entity. They are all accessible via window.WMA.yourPlayer.position, window.WMA.yourPlayer.target, window.WMA.yourPlayer.entity

window.WMA.global.globalArray

global but in the form of an array rather than object