Page 1 of 9 123 ... LastLast
Results 1 to 15 of 129

Thread: djkrose's Scripting Mod

  1. #1
    Tracker djkrose's Avatar
    Join Date
    Apr 2014
    Posts
    156
    Rep Power
    1

    djkrose's Scripting Mod

    djkrose's
    Scripting Mod

    Adds Lua and JavaScript support and
    other unique functionality to 7DTD dedicated servers.


    Infos and Download

    - Now open source! -

    This mod adds support for scripting custom commands and events directly in Lua or JavaScript. It is NOT a bot for telnet. Instead, it runs directly IN the game and has full access to all .Net CLR, Unity data, 7DTD data, and full OS access. You can basically change any behavior without even restarting. Scripts can communicate with any external system like web services, REST/JSON, databases, files, email, and so on. – See the Github page for details.


    Built-in Commands

    The mod also includes some unique built-in commands (see help <command> for details):

    dj-export Exports a prefab including all container content, sign texts, ownership, etc.
    dj-import Imports a prefab, optionally including all container content, sign texts, ownership, etc.
    dj-pos Shows the current player's position in various units and formats
    dj-log-events Enables or disables logging of events to the server console.
    dj-regen Regenerates a chunk or custom area based on the world seed
    dj-repair Repairs server problems of various kinds
    dj-eac-whitelist Allows players to be exempt from EAC checks on an EAC-enabled server
    dj-patch Enables or disables runtime server patches
    dj-version Shows djkrose's Scripting Mod version information.
    Included scripts:
    dj-test-js Test basic JavaScript functionality and assembly import
    dj-test-lua Test basic Lua script functionality and assembly import
    dj-minibike Teleport your minibike back to your position (in case stuck or lost)
    dj-sleepers Removes all sleeper volumes from the current chunk (useful after removing a POI)
    _dj-variables Example script to show how to access certain game objects. Doesn't output anything.
    _dj-pay Allows players to pay with in-game items (see script comments). [suggested by Trekkan]
    _event-... A couple of event scripts to show how to bind functionality to game events.

    _ = Deactivated by default; remove underscore from filename to activate.

    Latest Release

    Version 1.0 - compatible with A16.4 (b8)


    • Removed all obfuscation and made the mod open source.
    • Added event system that allows logging or scripting of in-game events.
    • Added command "dj-log-events" to manage event logging. See help.
    • Added 28 selected events with custom event data.
    • Added 5 example scripts for events.
    • Added possibility to disable scripts by prefixing them with underscore (_). Disabled example scripts.
    • Added telemetry and exception reporting; deactivate with <Telemetry>false</Telemetry> in settings.
    • Changed script commands js-test, js-minibike, js-sleepers, and lua-test to all use "dj-" prefix instead.
    • Changed syntax of "dj-patch XYZ on" to "dj-patch xyz /on" to match other command syntax.
    • Fixed: Parsing of script metadata can be very slow or freeze when file has many comments [#4]
    • Fixed: Incompatible line breaks in scripts on Linux [#28]
    • Removed deprecated command "dj-check-power". Use "dj-repair" instead.


    Help and Feedback

    Detailed documentation and API specification is just starting to grow: Documentation Wiki

    Also have a look at the many example scripts included. Remove the underscore (_) from filename to activate and test.

    For further help and other questions just use this thread so others can answer or benefit as well. If you wanna have a chat, find me in my Discord channel.

    To report bugs and feature requests please use the Github issue tracker.

    .oO( djkrose )Oo.
    Last edited by djkrose; 12-16-2017 at 08:23 PM.

  2. #2
    Colony Founder xyth's Avatar
    Join Date
    Dec 2016
    Location
    Florida, USA
    Posts
    1,172
    Rep Power
    1
    This looks very promising. Thanks for working on this!

  3. #3
    Hunter
    Join Date
    Jun 2017
    Posts
    104
    Rep Power
    0
    I just copied over a prefab from one server to another with your tool. it worked well for the most part...i just saw a couple of issues that may need to be addressed.

    First, i had to play with the export and import...i had to exaggerate the y number for underground portion of the base because even when i sunk down lower than i thought i needed to be to capture the bottom, it cut off part of the basement....then i had to experiment with placing is as it wanted to put the whole thing above ground by default.

    The bigger issue is that the script missed a couple of things. it didnt copy over the engines in the generator (probably the same for battery and solar banks but i didnt have those in this build)

    Also, it didnt recreate the wiring that was in place between the lights, switches and generator. Worse, it seems to remember something wrong about the wiring, because as i try to rewire things, the game creates wires streaching off into the distance somewhere...like it is trying to reconnect to the old location somewhere...and i cant remove those connections...so i will have to remove and rebuild/rewire everything

    other than that, it did a great job.
    Last edited by Dracos99; 07-27-2017 at 01:38 AM.

  4. #4
    Guppycurian Forum Whore Guppycur's Avatar
    Join Date
    Apr 2014
    Location
    Houston-ish, Texas
    Posts
    17,366
    Rep Power
    1
    Funny you mention those things...

  5. #5
    Colony Founder Pille's Avatar
    Join Date
    Apr 2015
    Location
    Milky Way
    Posts
    1,238
    Rep Power
    1
    Quote Originally Posted by Dracos99 View Post
    The bigger issue is that the script missed a couple of things. it didnt copy over the engines in the generator (probably the same for battery and solar banks but i didnt have those in this build)
    These things are not included in the prefabs files... Therefore I think, it's not an issue with the script.

    Quote Originally Posted by djkrose View Post
    While scripting exposes all internal data in theory, you probably have a hard time finding out how it works, without looking into Unity/7DTD binaries. - But worry not! I will do that for you and expose a nice and clean script API in one of the next versions, together with a handful of example scripts and documentation.
    That sounds really interesting to me. Hope your api has a foolproof design, so I can understand and use it.^^
    Last edited by Pille; 07-27-2017 at 01:50 AM.

  6. #6
    Hunter
    Join Date
    Jun 2017
    Posts
    104
    Rep Power
    0
    Quote Originally Posted by Pille View Post
    These things are not included in the prefabs files... Therefore I think, it's not an issue with the script.
    my understanding was that it was gathering more than the stuff in the prefab file...since it grabs the chest contents, ownership, lock status and other things and places them in a separate file, i would assume it was going to grab the contents of the electrical items and their connections.

    if this piece of the script is to restore an intact POI including things not normally captured with the intent to restore from griefing, i would be disappointed to find out all my engines, batteries and solar panels gone...as well as having to destroy and replace all electrical items and rewire post restore.

  7. #7
    Colony Founder Pille's Avatar
    Join Date
    Apr 2015
    Location
    Milky Way
    Posts
    1,238
    Rep Power
    1
    Ohh you're right. My fault. It's even mentioned in the op^^

  8. #8
    Guppycurian Forum Whore Guppycur's Avatar
    Join Date
    Apr 2014
    Location
    Houston-ish, Texas
    Posts
    17,366
    Rep Power
    1
    Word on the street is he figured out how a few hours ago and will be updating it.

    Sesame street.

  9. #9
    Tracker djkrose's Avatar
    Join Date
    Apr 2014
    Posts
    156
    Rep Power
    1
    Thanks for the feedback @all!

    Quote Originally Posted by Dracos99 View Post
    First, i had to play with the export and import...i had to exaggerate the y number for underground portion of the base because even when i sunk down lower than i thought i needed to be to capture the bottom, it cut off part of the basement....then i had to experiment with placing is as it wanted to put the whole thing above ground by default.
    This needs a bit more testing and a clear reproduction scenario as I cannot reproduce it. The import/export use the exact coordinates that you specify, or if you don't specify, the exact coordinates of the player's position. Pay attention that your "eye level" is higher than your actual player's position, which is measured on the sole of your feet by the game. You can see your current Y position either in debugmode by pressing "F3" or on the map. BadCompanySM mod also has a pos command, which shows you the exact current player position.

    BTW: The coordinates shown in F3 mode are bugged (one too high) for negative values, because it just cuts the decimal part of the position, instead of using Math.Floor(). For negative numbers, this results in rounding up (=Math.ceil), which puts the location one block further north/east. For example, when standing on (-123.246, -54.79) the F3 mode shows incorrectly position (-123, -54) when you are actually standing on block (-124, -55). [some math details] - The pos command from BadCompanySM shows it correctly.

    If a Fun Pimp is reading: Constructor Vector3i.Vector3i(Vector3 _v) seems to be the culprit.

    Quote Originally Posted by Dracos99 View Post
    The bigger issue is that the script missed a couple of things. it didnt copy over the engines in the generator (probably the same for battery and solar banks but i didnt have those in this build)
    You are correct. I identified this problem yesterday with Guppycur and have opened an issue for it. I've no idea yet why these contents are not included.

    https://github.com/djkrose/7DTD-ScriptingMod/issues/2

    Quote Originally Posted by Dracos99 View Post
    Also, it didnt recreate the wiring that was in place between the lights, switches and generator. Worse, it seems to remember something wrong about the wiring, because as i try to rewire things, the game creates wires streaching off into the distance somewhere...like it is trying to reconnect to the old location somewhere...and i cant remove those connections...so i will have to remove and rebuild/rewire everything
    Yes, we also discovered this yesterday and opened an issue for it:
    https://github.com/djkrose/7DTD-ScriptingMod/issues/1

    I think I know how to fix it. It's on my todo list for v0.6.

    The reason for the weird wireing is quite simple: Every power block saves the absolute xyz-position to where wires go. This position is simply copied with everything else, so that wires still point to the old position, even when imported somewhere else. - I would need to adjust the wire positions relative to the new position.

    This of course also means that wires need to be capped, if only a part of an electric setup is copied. If you copy a turret out without the connected generator, it would end up without a connection in the copy. I think that makes sense.

    Thanks again for the feedback and testing!

    djk

  10. #10
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,771
    Rep Power
    1
    for the wiring my suggestion would be to get the offset from prefab pos on export, then reconvert the vector to world pos on import (import pos + offset vector)

    Also, I didnt check your dll, but are you using postion, or serverpos for y pos of player?

    serverpos will give the real pos (serverPos.y/32 to get vector int)

  11. #11
    Tracker djkrose's Avatar
    Join Date
    Apr 2014
    Posts
    156
    Rep Power
    1
    @StompyNZ: Yes, something like this would do it. I cannot easily modify the metadata object during export, because that would modify the actual metadata in the running game (= re-routing wires), but i can save the original position and adjust during import accordingly. This gives me the added benefit that I can extend the import command to offer importing at the exact old position, e.g. for restoring structures.

    I first tried serverpos, but am now using position, because that is what's used game-wide everywhere for every action and decision, like AI pathfinding, calculating distance, chunk loading, etc. It is also updated frequently though Entity.OnUpdatePosition, while serverpos is just used intermediary during network communication. position is referenced 178 times, serverpos 6 times. -- What makes you think serverpos is better?

  12. #12
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,771
    Rep Power
    1
    because position.y won't track your underground position, it will give the surface pos (that's why the teleports to surface happen)

    It only applies when clipping underground.

    serverPos seemed to map correctly 100% of the time when above ground, so I don't think the update rate would matter unless doing some high speed maneuvers while exporting

    you could always use serverpos just for the y pos and position for x and z

    - - - Updated - - -

    also, would you be able to edit the meta after you have it all in memory?

  13. #13
    Tracker djkrose's Avatar
    Join Date
    Apr 2014
    Posts
    156
    Rep Power
    1
    Good point!

    Tested, comfirmed, and fixed for next version.

  14. #14
    Tracker djkrose's Avatar
    Join Date
    Apr 2014
    Posts
    156
    Rep Power
    1
    New Release: https://github.com/djkrose/7DTD-ScriptingMod/releases

    Version 0.5 - tested with 7DTD A16.1 (b1)

    • Improved compatibility with Assembly-CSharp.dll to (hopefully) support future versions
    • Added LICENSE.txt to credit the mod and all included third-party software properly
    • Fixed import/export commands to correctly consider player's underground positions when clipping is off
    • Fixed a bug where reloading chunks after dj-import could lead to a KeyNotFoundException
    • Added command dj-check-tripwires to check and repair corrupt tripwire data
      Details: https://7daystodie.com/forums/showth...dTrigger-write


    I'm also quite far with supporting import/export of electrical blocks and their content, but this fix is not yet in this release. I think/hope it will come with the next.

    .oO( djkrose )Oo.

  15. #15
    Scavenger
    Join Date
    Jul 2017
    Posts
    38
    Rep Power
    0
    Your saying it has full integration with things outside of just the game, afew things i would like to see if possible.

    1) Ability to restart the game server from in the game. I manage the server but its being hosted by a mate. he is not always available to shutdown the exe and reload the exe when im patching in new mods etc. - If i could combine this with server tools allowing server countdown notifications i would be super happy.

    2) We use discord to communicate, i would love to have game chat extracted from the game and able to be posted to discord or teamspeak\vent, etc. lol

    3) This is something i think would be cool, but i dont know how useful or easy it would be, but what about email notification to owner of a trap, if triggered by people.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •