Jump to content

Wrote a simple mod.


TheSilentOracle

Recommended Posts

Wrote a simple mod for our personal server that I would like to share. Is there a convention where we want to host these scripts? Also, is there a convention behind created scripts to reduce conflicts between mods or is this something that's too much in infancy?

[move]This is my first foray into Lua and I'm not sure how to proceed. Marquees?[/move]

 

edit: added zip attachment

scripts.zip

Link to comment
Share on other sites

  • Boxelware Team

Right now you still have to manage inconsistencies between mods yourself. Later on, once we do the workshop integration for mods, we're going to do sanity check to make sure mods don't interfere with each other.

 

Apart from that, just post it here. If it's server only, it's not an issue anyways. Things like spawning more/less events, chat messages etc. don't have to be synced to clients (which isn't in yet, btw).

Link to comment
Share on other sites

Hey! For those who like to copy pasta code.  Here are the modifications you'll need to make and the mod script he added.

 

Part 1:

Modify:

scripts/server/server.lua

 

Add

player:addScriptOnce("mods/setPreviousSectorAsHomeSector.lua")

after

player:addScriptOnce("story/spawnadventurer.lua")

 

function onPlayerLogIn(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s joined the galaxy"%_t, player.name)

    player:addScriptOnce("headhunter.lua")
    player:addScriptOnce("eventscheduler.lua")
    player:addScriptOnce("story/spawnswoks.lua")
    player:addScriptOnce("story/spawnai.lua")
    player:addScriptOnce("story/spawnguardian.lua")
    player:addScriptOnce("story/spawnadventurer.lua")
    player:addScriptOnce("mods/setPreviousSectorAsHomeSector.lua")
    matchResources(player)
end

 

Part 2:

Mod File Path:

scripts/mods/setPreviousSectorAsHomeSector.lua

 

Contents:

function initialize()
    Player():registerCallback("onSectorLeft", "onSectorLeft")
end

function onSectorEntered(playerindex, x, y)
Server():broadcastChatMessage("Server", 0, "Handler hit")
Player():setHomeSectorCoordinates(x, y)
end

 

Try not to upset The AI with your modding...

Link to comment
Share on other sites

I wrote this on reddit but first a few suggestion:

 

Title better :)

[Mod] somethingname :)

 

I also would suggest rather then doing it your style you add a new menu option for certain stations or it could be all of them. For example colony like stations you can go to them and respawn at them.

 

Maybe also charge the closer you go to the center the more it would cost.

 

Just a small suggestion anyways I feel your current method would end up getting people stuck :)

Link to comment
Share on other sites

Thanks for the feedback Kane!

 

We're working on the station ui portion of the mod, but here is a command I put together in the meantime!

 

Here is the gist of the script: https://gist.github.com/furyanPDX/1c4cb9956196c2994345fbc8f6136e81

Here is the repo that I'll be storing the commands in: https://github.com/FederationOfEngineers/Commands

 

Hi

 

nice addition furyan

 

i tried the command version and a always get respawned at my original home sector... am i doing something wrong?

the command itself executes normally but does not seem to have an effect...

 

 

T

Link to comment
Share on other sites

i tried the command version and a always get respawned at my original home sector... am i doing something wrong?

the command itself executes normally but does not seem to have an effect...

 

What command line version?  ???

Is there a simple chat command I can use to set the current sector as my home sector? Because, that's all I really need...

Link to comment
Share on other sites

  • 2 weeks later...

Sorry, I broke the script last night doing some testing.

 

This current gist should allow you to set the sector: https://gist.github.com/furyanPDX/1c4cb9956196c2994345fbc8f6136e81

 

Anyway this script could be easily fixed?

I'm getting this output when I run it

 

 

 

/setHomeSector -348 -285

<> Setting home sector to sector (-348, -285)!

could not execute function 'execute' in '"data/scripts/commands/setHomeSector.lua"':

data/scripts/commands/setHomeSector.lua:18: attempt to index a nil value

stack traceback:

        data/scripts/commands/setHomeSector.lua:18: in function <data/scripts/commands/setHomeSector.lua:4>

 

Setting script "data/scripts/commands/setHomeSector.lua" to invalid.

 

 

 

Sounds like Aki is correct on why it doesn't work, but I am not knowledgeable enough in lua scripting to fix it.

I would love to get this working, or an iteration where an admin can call a user and set their home directory, could be an excellent administration tool.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...