Jump to content

hdparm

Alpha Team Vanguard
  • Posts

    340
  • Joined

Posts posted by hdparm

  1. On 10/11/2022 at 1:30 PM, AtroKahn said:

    My favorite AP... Does this work with the release version of DU?

    It should still work, but not well. There have been many DU changes since the last script update. Speed limit now varies with construct mass, construct mass is no longer relativistic, planets are different. I plan to update the script this week or next.

     

    EDIT: script update will take somewhat longer than expected.

  2. 8 hours ago, Serula said:

    Whenever you place an industry element you have to choose what it will produce and pay x amount of quanta to "repurpose" the unit to produce exactly that.

    In a game that's described as "the space MMO entirely built and driven by the players", a currency issued by NPCs (quanta) should not be required for anything. Not for unlocking or changes recipes, not for territory upkeep, not for anything else. Quanta should only be used to optionally trade on NPC markets.

  3. Harvesting ore stones (that are spawned after calibrating mining units) requires players to hold the left mouse button a lot. For some players this causes wrist and/or finger pain/discomfort. Could surface ore harvesting be made more ergonomic? Mining tool had an auto-mine mode (toggled with the middle mouse button). Perhaps the harvest tool could have this mode too?

  4. Quote

    LUA ATLAS ADDITION

    The Lua atlas will be useful. But, is it a just a .lua file in Game/data/lua, which has to be updated manually (or with a script) by someone from NQ? It may be better (more future-proof) to have a system function that would generate the atlas at runtime from game data.  system.getPlanetAtlas() could even return a JSON string, as the scripts would only need to parse it once.

  5. Quote

    <vec3> radar.getConstructWorldPos(<int> cid) : Returns the position of the given construct in world coordinates if in range and if the active transponder tags match.

    Could radar.getConstructWorldPos(id) be extended to return position of any static (or stationary) construct in range? Popular flight scripts are already trilaterating construct positions based on distance (for collision avoidance), so it would mainly improve code efficiency/complexity.

  6. 22 hours ago, NQ-Ligo said:

    Even though we know you would like more access to the player's camera.

     

    What about adding a single function that would take 3D world (or construct) coordinates and project them into 2D screen coordinates? It would cover most use cases (AR HUDs, custom location markers), and would also be faster than doing 3D projection math in Lua.
     

    4 hours ago, Samedi said:

    Sorry, but you can, you just need to add a versioning scheme to the API.

    All existing scripts use v1. You could add a completely rewritten v2, and have a setting on the controllers where script authors can opt into v2.

     

    Agreed. There are already at least 3 separate Lua APIs: 1) the control unit API, 2) the screen (render script) API, 3) the internal tutorial & achievement API. Adding one more (control unit API v2) shouldn't be impossible ;)

     

    Quote
    • <vec3> core.getWorldVelocity(): Returns the construct's linear velocity, relative to its parent, in world coordinates.
    • <vec3> core.getWorldAbsoluteVelocity(): Returns the construct's absolute linear velocity in world coordinates.

     

    For compatibility with existing scripts (and consistency with other core.getParent* functions), could core.getWorldVelocity() always return absolute linear velocity, and velocity relative to parent be returned by a new function core.getParentRelativeWorldVelocity()? Same for core.getVelocity().

  7. 1 hour ago, HypershotJ said:

    I am having the issue with map marker not placed where my mouse pointer is..  ill click in the center of the planet and my marker is either way north or way south of where my mouse is.

    This bug happens when graphics mode is set to OpenGL instead of DirectX.  If you're not on Windows 7 (which only supports OpenGL with DU), set graphics to DirectX and restart the game before using the map heavily (scanning territories, etc).

  8. @KuntChopsMcFrontButt Try this:

    local rgbColor = vec3(light.getRGBColor())
    local r = rgbColor.x -- rgbColor["x"] would also work
    system.print(r)

    But, you don't really need vec3 here. When the codex says "vec3", it means an array-like table with 3 elements, not a cpml.vec3 instance. This should also work:

    local rgbColor = light.getRGBColor()
    local r = rgbColor[1]
    system.print(r)

     

  9. 1 hour ago, Umibozu said:

    I would like to point out, that schematic prices have been readjusted, and as it stand now, prices are affordable to everyone.

    T4 and T5 schematic prices are still too high.

    For example, Warp Beacon schematic costs 841 292 033 quanta. Assuming an average miner can mine meganodes at 200 000 liters per hour and ore can be sold at 25 quanta per liter, it's 168 hours of non-stop mining.

  10. 8 hours ago, Keimond said:

    do you think it's possible to make this work with a gravity engine ?

    This script stops your construct 80 km above a planet and holds it there with brakes. You lose less than 0.3 km of altitude per hour, so you can AFK for a day or two :) The script could be modified to use an AGG, but would it be useful?

  11. Dual_2020_09_16_19_57_03_204_-_Lua_basic_space_autopilot_to_Alioth.png

     

    About

    This is a basic autopilot script that can accelerate your construct towards a planet and later apply brakes to stop. Vertical space engines are used to control drift.

     

    Requirements

    • Space brakes, 1.5+ g.
    • Vertical space engines (pointing down), 0.3+ g.
    • A remote controller or a separate hovercraft seat.

    Limitations

    • No manual piloting. Use another script to get to space and to land.
    • No collision avoidance. Make sure there are no planets, moons, asteroids, space stations or pirates between you and the destination.
    • Planet positions are stored in the script. If NQ moves the planets, the script will have to be updated.

    Set-up

    With an auto-configuration schema (recommended)

    1. Download this file to Game\data\lua\autoconf\custom in your Dual Universe installation directory. By default it's C:\ProgramData\Dual Universe\Game\data\lua\autoconf\custom
    2. Right-click the control unit (a remote controller or a hovercraft seat) and select "Update custom autoconf list". This needs to be done only once.
    3. Right-click the control unit and select "Actions for this element", "Run custom autoconfigure", "Basic Space Autopilot".

    With a pasteable script configuration

    1. Open this link and copy everything to clipboard.
    2. Right-click the control unit (a remote control or a hover seat) and select "Actions for this element", "Paste Lua configuration from clipboard".
    3. The game should display a "Lua script loaded" message. If it did not, restart the game and copy the script configuration again.
    4. Link the core (required) and fuel tanks (optional) to the control unit.

    Credits

    Many planet positions were provided by @meigrafd from Hyperion.

    The script was bundled (amalgamated from multiple .lua files) using amalg.

     

    Change log

    2020-09-23. Fixed heavy constructs not accelerating past 29997 km/h. A radar widget will be displayed if a PVP radar is linked (not available on remote controllers). Tested in r0.22.2.

    2020-09-16. Posted the first version outside the NDA forums section. Tested in r0.21.6.

  12. image.png.d57f24eb199f48b01e38e45ddb7ac074.png

     

    About

    This is a short script that prints base max thrust of linked engines. It can serve as an example, and may also be used to detect which engines do not have a technician buff applied to them.

     

    Set-up

    1. Place a programming board.
    2. Link up to 10 engines to the programming board.
    3. In the Lua editor (right-click, "Advanced", "Edit Lua code") create a unit start() event handler with this code:
      -- detect linked engines
      local engines = {}
      
      for key, value in pairs(unit) do
        if type(value) == "table" and type(value.export) == "table" then -- `value` is an element and `key` is the slot name
          if value.getThrust and value.getMaxThrust then -- `value` is an engine
            engines[#engines + 1] = value
          end
        end
      end
      
      -- get engine names
      local engineNames = {}
      
      for _, engine in ipairs(engines) do
        -- engine name is available in its widget data
        -- for other elements `core.getElementNameById` would have to be used instead
      
        local dataJson = engine.getData()
        local data = json.decode(dataJson)
      
        engineNames[engine] = data.name or "???"
      end
      
      -- sort engines by name
      table.sort(engines, function (engine1, engine2)
        return engineNames[engine1] < engineNames[engine2]
      end)
      
      -- print engines and their base max thrust
      system.print("Linked engines: " .. #engines)
      
      for _, engine in ipairs(engines) do
        local name = engineNames[engine]
        local maxThrustBase = engine.getMaxThrustBase()
      
        system.print(string.format("%s: %.0f N", name, maxThrustBase))
      end
      
      unit.exit()

       

    4. Click "Apply" in the Lua editor, exit build mode and activate the programming board. You should see base max thrust printed in the Lua chat tab.

       

    Change log

    2020-09-13. Posted the first version (tested in r0.21.5).

  13. About

    This tool enables a somewhat different way of writing Dual Universe scripts. It takes a single Lua file that defines a global object with event handlers, and automatically generates a script configuration that can be pasted into a control unit. This allows writing the entire script outside the game, and automates away the need to manually set up each event handler.

     

    Prerequisites

    • Some knowledge of Dual Universe Lua scripting (watch the official tutorial)
    • Be able to run a Lua script from the command line.

    Download

    wrap.lua

    example-input.lua

    example-output.json

     

    Usage example

    Let's make a simple script that will react to key presses and display some text on a screen element.

     

    1. Edit and save a Lua script in any plain text editor:

    -- Define a global script object with event handlers
    script = {}
    
    function script.onStart ()
      -- Display some text
      screen.setCenteredText("script started")
    
      -- Create some timers to show that the script is working
      unit.setTimer("a", 2) -- timer id "a", ticks every 2 seconds
      unit.setTimer("b", 3) -- timer id "b", ticks every 3 seconds
    end
    
    function script.onStop ()
      screen.setCenteredText("script stopped")
    end
    
    function script.onActionStart (actionName)
      screen.setCenteredText(actionName .. " key pressed")
    end
    
    function script.onActionStop (actionName)
      screen.setCenteredText(actionName .. " key released")
    end
    
    function script.onTick (timerId)
      screen.setCenteredText("timer " .. timerId .. " ticked")
    end
    
    -- Other events that are available by default:
    -- * onActionLoop(actionName): action key is held
    -- * onUpdate(): executed once per frame
    -- * onFlush(): executed 60 times per second, for physics calculations only; setEngineCommand must be called from here
    
    -- Slot events are available if slot type is set with the --slot command line option.
    function script.onMouseDown (x, y)
      screen.setCenteredText("mouse down: x=" .. x .. " , y=" .. y)
    end
    
    -- Call the start event handler
    -- Alternatively, initialization code can be placed anywhere in this file.
    -- The only requirement is that there is a global "script" object with event handlers
    script.onStart()

    Note: sometimes invalid characters are added when copying code from forums. If that happens, copy code from the provided link instead.
    2. Run the packaging script:

    lua wrap.lua yourscript.lua yourscript.json --slots screen:type=screen --handle-errors

    --slots screen:type=screen sets first slot's name to screen and adds mouse down/up event support for that slot.

    --handle-errors adds error handling code, so that run-time Lua errors are displayed on the screen and in the Lua tab.
    3. Open the resulting configuration file in a text editor, and copy everything to clipboard.

    4. Inside Dual Universe, prepare a construct. There must be a programming board and a screen, and the screen must be linked into the programming board's slot 1.

    5. Right-click on the programming board, select "Advanced", "Paste Lua configuration from clipboard".

    Done! The DU construct has been programmed without opening the in-game editor once. Activate the programming board and see if it works.

     

    Command line arguments

    Spoiler
    
    Usage: wrap.lua ([--handle-errors] | [--handle-errors-min])
           [--output <format>] [--name <name>]
           [--object <script_object_name>] [--call-with <dot_or_colon>]
           [--default-slot type=<slot_type>] [--fix-gc] [--fix-require]
           [--indent-json] [--list-slot-types] [-h] <input file>
           [<output file>]
           [--slots [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] ...]
           [--methods [<method_signature>] ...]
    
    Arguments:
       input file            The Lua file that contains script code.
       output file           The file that the JSON configuration or the YAML autoconf will be written to. If not set, standard output will be used instead.
    
    Options:
       --output <format>     Output format. Valid values: "json", "yaml". Defaults to "json".
                             JSON output can be pasted in-game by right-clicking on the control unit.
                             YAML files the with .conf extension can be placed in data/lua/autoconf/custom.
       --name <name>         Script name. Only used when outputting YAML.
       --slots [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] [<slot_name>[:type=<slot_type>[,class=<slot_class>][,select=all]]] ...
                             Control unit slot names and, optionally, element types (to generate element type specific event handlers).
                             When output format is YAML, "class" option can be used to link elements that do not have a type defined in this script, and the "select=all" option can be used to link all elements of that type or class.
                             Unit, system and library slots are added automatically. Slot names default to slot1, slot2, ..., slot10.
       --methods [<method_signature>] ...
                             Methods to define on the control unit. This is not very useful and is only supported when outputting JSON.
       --object <script_object_name>
                             The name of the object containing the event handlers. Defaults to "script".
       --call-with <dot_or_colon>
                             Event handler function call operator. Valid values: ".", ":". Defaults to ".".
       --default-slot type=<slot_type>
                             Default slot options.
       --fix-gc              Adjust GC to run more frequently. This can help prevent memory overload errors.
       --fix-require         Replace non-working require() with a function that looks in package.preload and package.loaded.
                             This is not necessary unless require() is disabled in-game again.
       --handle-errors       Add error handling code that displays errors on screen elements.
       --handle-errors-min   Add minified error handling code that displays errors on screen elements.
       --indent-json         Indent the JSON output.
       --list-slot-types     Lists slot types supported by the --slots option.
       -h, --help            Show this help message and exit.

     

    Command line examples

    To produce a pasteable configuration for a custom piloting script:

    lua wrap.lua pilot.bundle.lua pilot.bundle.json --slots core gyro container_0 screen verticalEngine

    To produce a pasteable configuration for a radar script:

    lua wrap.lua radar.bundle.lua radar.bundle.json --handle-errors --default-slot type=pressable

    To produce an autoconf file for another custom piloting script:

    lua wrap.lua flight-enhancednav.bundle.lua flight-enhancednav.conf --output yaml --name "Airplane Cockpit (Enhanced)" --slots core:type=core gyro:type=gyro container:type=fuelContainer,select=all --handle-errors

    Known issues

    "Root node should be a map"

    This error is caused by wrong .conf file encoding. If you are using Powershell, the > operator saves the output with UCS-2 LE BOM encoding. Use cmd.exe instead, or replace > my.conf with | Out-File -Encoding UTF8 my.conf, or do not use output redirection, as the output file name can now be specified as an argument.

     

    Change log

    2020-09-04. Posted the first version outside the NDA forums section. Output can now be written to a file without using output redirection.

     

    Credits

    This tool uses argparse and dkjson libraries, and was bundled using amalg.

  14. Unofficial Lua changelog

    r0.23.0

    Changes since r0.22.4:

    • All elements
      • New functions: getMaxRestorations(), getRemainingRestorations().
    • Anti-Gravity Generator
      • setBaseAltitude(altitude) no longer works inside the system flush() event.
    • Container (Fuel and Item)
      • New event: storageAcquired().
      • New functions: acquireStorage(), getItemsList(), getItemsVolume(), getMaxVolume().
    • Control unit
      • New function: getMasterPlayerRelativeOrientation().
      • Restored function: setupControlMasterModeProperties(controlMasterModeId,displayName).
    • Core
      • New functions: getElementIndustryStatus(localId), getSchematicInfo(schematicId).
    • Emitter and Receiver
      • Range increased to 1000 m.
    • Industry
      • New functions: getCurrentSchematic(), setCurrentSchematic(id).
    • Light
      • New functions: getRGBColor(), setRGBColor(r,g,b).
    • System
      • New event: inputText(text).
      • New functions: getFov(), getScreenHeight(), getScreenWidth(), getWaypointFromPlayerPos(), setWaypoint(waypointStr).
    • Warp drive
      • Removed function: activateWarp().

    r0.22.4

    Changes since r0.22.0:

    • Core
      • New functions: getElementPositionById(localId), getElementRotationById(localId), getElementTagsById(localId).
    • Other
      • global.lua is now inside game.ung and cannot be edited by players.
      • Editing existing files in Game/data/lua should no longer trigger the EQU8 anti-cheat.

    r0.22.0

    Changes since r0.21.3:

    • PVP radar
      • New functions:  getConstructName(id), getConstructPos(id), getConstructSize(id), getConstructType(id), getEntries(), getRange(), hasMatchingTransponder(id). The getConstruct* functions return "unreachable" or { 0, 0, 0 }, even for construct information that's available in getData().
      • New events: enter(id), leave(id).

    r0.21.3

    Changes since r0.21.2:

    • Other
      • package.loadlib has been disabled.

    r0.21.2

    Changes since r0.20.0:

    • Anti-Gravity Generator
      • New function: getBaseAltitude().
    • PVP radar
      • getData() no longer returns construct positions.
    • Other
      • pcall and xpcall can no longer be used to avoid the CPU instruction limit.
×
×
  • Create New...