Jump to content

[Help] Creating wormholes


LogicSocket

Recommended Posts

I'm trying to get a function to work to create a wormhole:

 

function onWormHolePlanPressed()
    if onClient() then
        invokeServerFunction("onWormHolePlanPressed")
        return
    end
local generator = SectorGenerator(Sector():getCoordinates())
generator:createGates()

end

 

Anyone know why this isn't working or know the proper way to do that please?

Thank you

-LS

 

Changed subject so it gives some idea about what's inside, Aki.

Link to comment
Share on other sites

@LogicSocket

I leave following code for you as some kind of small reference. I was playing around with wh creation and this is really simple function for that.

-- x and y are coordinates of exit
function popWormhole(x, y)
if x and y then
	local player = Player()
	local sector = Sector()
	local ship = Entity(player.craftIndex)
	local wormhole = sector:createWormHole(x, y, ColorRGB(0,1,1), 25)
	wormhole.translation = ship.translation -- you will need to get away from the wormhole first
end
end

Link to comment
Share on other sites

Thank you Aki! works like a charm.

For my uses I have scripts attached to a system that allows for dialog options:

function onStartDialog(playerIndex)
ScriptUI(playerIndex):addDialogOption("[Create WormHole]"%_t, "popWormhole")
end

function popWormhole()
    if onClient() then
        invokeServerFunction("popWormhole")
        return
    end

	local player = Player()
	local sector = Sector()
	local ship = Entity(player.craftIndex)
	local x, y = random():getInt(-400, 400)
	local wormhole = sector:createWormHole(x, y, ColorRGB(0,1,1), 25)
	wormhole.translation = ship.translation -- you will need to get away from the wormhole first

end

 

EDIT:I changed wormhole.translation = ship.translation to wormhole.translation = random():getFloat(75,150) this solves it being right on top of the ship :) cheers

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...