Coder Social home page Coder Social logo

dual-universe / lua-examples Goto Github PK

View Code? Open in Web Editor NEW
59.0 11.0 19.0 13.5 MB

This repository has been created to serve as a sharing and learning platform for the Dual Universe community and the development of simple and complex Lua applications. You will find on this repo the examples released by Novaquark during the devblog and thread.

Home Page: https://www.dualuniverse.game

License: GNU General Public License v3.0

Lua 100.00%
dual-universe lua scripting

lua-examples's Introduction

02

Official Dual Universe Lua Repository

What is Dual Universe

Dual Universe is a sci-fi MMORPG that takes place in a continuous, single-shard world. Players can freely modify the world by creating structures, spaceships, and even orbital stations, giving birth to empires and civilizations. It features a player-driven economy, politics, trade, and warfare.

Dual Universe is currently in open Beta, with a final release planned for 2022.

Official website: https://www.dualuniverse.game

About this repository

This repository has been created to serve as a sharing and learning platform for the Dual Universe community and the development of simple and complex Lua applications.

You will find on this repo the examples released by Novaquark in devblogs and other announcements of features along with other snippets we deem useful for the community.

Reminder: As the Lua feature evolves regularly, it is possible that a script or system may be broken or contain bugs. We will try to update the relevant examples if this is the case, but no guarantee of functionality can be given.

How to use it ?

Each example provided here consists of the following:

  • A description of the example.
  • An image representing the result (if possible).
  • A list of requirements (which elements/links are needed to use the system).
  • Installation instructions.

In order to ensure the readability of the code, and to cover as many cases as possible, we have decided to organise the code into files by filters. Also in some cases, when the examples are simple and small, we have decided to group them together to reduce clutter.

Thus you will find in the examples folder Lua files named according to the convention <slot>_<filter><index>.

For example:

  • render.lua : code for the Lua screen's renderscript.
  • controlunit.json : string for use with control units using the Paste Lua configuration from clipboard functionality in game.
  • system_onStart.lua : code for the onStart filter of the system slot
  • system_onUpdate.lua: code for the onUpdate filter in the system slot
  • unit_onTimer1.lua : code for the first onTimer filter in the unit slot
  • ...etc

Then, by following the instructions given, you can install these as required.

lua-examples's People

Contributors

jericho1060 avatar kleincrafter avatar leniver avatar matpratta avatar nq-deckard avatar nq-ligo avatar nq-silent avatar permalmberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lua-examples's Issues

core.getWorldVertical misleading

core.getWorldVertical actually points downwards, ie same direction as gravity. There should be documentation specifying the direction.

Documentation error

---@return number value The maximum hitpoints of the Element

This snippet of code.

    --- Returns the mass of the Element, identified by its local ID
    ---@param localId integer The local ID of the Element
    ---@return number value The maximum hitpoints of the Element
    function self.getElementMassById(localId) end

The ---@return number value The maximum hitpoints of the Element should not be about maximum hitpoints but the mass of the element.

Issues with the Atlas screen example

Hi
Not sure if it is me or an update but for some reason when I paste the render.lua code into the screen I get a script error:

attempt to index a number value(local 'v').
image

Request for new function - Render script get player

Is there any chance we could get a function in the render script that makes screens aware on whoms player client it runs, returning the player id/name?
That would be usefull to design screens used by multiple users simultanous and distinguish between their inputs.

getHeliosPosition()

I need a variable of the actual position of helios to calculate the sunrise of the actual player position.
Or something else thats let me calculate the start/end of the day/night-cycle at the player-position.

Gunner Seat Radar Issues

Hello,

I am not sure where the issue lies here. When I apply my custom gunner seat script to my chair, I see this in the gunner periscope view.

image


However, when I apply the default PvP gun script I see this

image


I at first assumed it was the data I was sending into the radar widget (either incomplete or something else going on). But upon inspecting the json output of the radar (radar_1.getWidgetData()) from the default script and the radar data fed into the radar widget using my script, I did not find any substantial differences that would account for this behavior.

Default Data
{
    "constructsList": [
        {
            "constructId": "5741688",
            "distance": 11.509540326447041,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "CargoBox",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5411110",
            "distance": 10126.263601605886,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "N299 Mule the Man",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5719823",
            "distance": 10380.199691765596,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "PT01",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5638631",
            "distance": 10544.990016054106,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "OMEGA",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5567993",
            "distance": 10649.402865996866,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "Sava Yesh II",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5658583",
            "distance": 10926.713352488552,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "IC Navis",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5711924",
            "distance": 10927.432673085657,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "Twintania Base",
            "size": "M",
            "targetThreatState": 0
        },
        {
            "constructId": "5690586",
            "distance": 10928.499615752093,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "IC Navis Node",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5277227",
            "distance": 127134.15874474417,
            "inIdentifyRange": false,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "Hope II",
            "size": "S",
            "targetThreatState": 0
        }
    ],
    "currentTargetId": "0",
    "elementId": "2753861252",
    "helperId": "radar",
    "name": "Advanced Phased-Array Space Radar s [54]",
    "properties": {
        "broken": false,
        "errorMessage": "",
        "identifiedConstructs": [],
        "identifyConstructs": {},
        "radarStatus": 1,
        "selectedConstruct": "0",
        "sortMethod": 0,
        "worksInEnvironment": true
    },
    "staticProperties": {
        "maxIdentifiedTargets": 7,
        "ranges": {
            "identify128m": 123750.0,
            "identify16m": 123750.0,
            "identify32m": 123750.0,
            "identify64m": 123750.0,
            "scan": 400000
        },
        "worksInAtmosphere": false,
        "worksInSpace": true
    },
    "type": "radar"
}

Custom Data
{
    "constructsList": [
        {
            "constructId": "5741688",
            "distance": 11.497139005740145,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[688] CargoBox",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5411110",
            "distance": 10099.410522447579,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[110] N299 Mule the Man",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5719823",
            "distance": 10353.233454707668,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[823] PT01",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5638631",
            "distance": 10518.049976234788,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[631] OMEGA",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5567993",
            "distance": 10622.460439595419,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[993] Sava Yesh II",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5658583",
            "distance": 10899.80712623914,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[583] IC Navis",
            "size": "S",
            "targetThreatState": 0
        },
        {
            "constructId": "5711924",
            "distance": 10900.499892057502,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[924] Twintania Base",
            "size": "M",
            "targetThreatState": 0
        },
        {
            "constructId": "5690586",
            "distance": 10901.593723635093,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[586] IC Navis Node",
            "size": "XS",
            "targetThreatState": 0
        },
        {
            "constructId": "5301571",
            "distance": 43194.568586788686,
            "inIdentifyRange": true,
            "info": {},
            "isIdentified": false,
            "myThreatStateToTarget": 0,
            "name": "[571] Baby Bull",
            "size": "XS",
            "targetThreatState": 0
        }
    ],
    "currentTargetId": "0",
    "elementId": "2753861252",
    "helperId": "radar",
    "name": "Advanced Phased-Array Space Radar s [54]",
    "properties": {
        "broken": false,
        "errorMessage": "All-Distance",
        "identifiedConstructs": [],
        "identifyConstructs": {},
        "radarStatus": 1,
        "selectedConstruct": "0",
        "sortMethod": 0,
        "worksInEnvironment": true
    },
    "staticProperties": {
        "maxIdentifiedTargets": 7,
        "ranges": {
            "identify128m": 123750.0,
            "identify16m": 123750.0,
            "identify32m": 123750.0,
            "identify64m": 123750.0,
            "scan": 400000
        },
        "worksInAtmosphere": false,
        "worksInSpace": true
    },
    "type": "radar"
}

Would anyone be able to assist and help me determine what is going on? My custom script is open source and I can link it if it would help with the review. I also tried using and older version of my script (from near the end of Beta) which I 100% know was working properly and it still has this same behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.