Skip to content

Instantly share code, notes, and snippets.

@Brianetta
Created February 4, 2012 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brianetta/1735370 to your computer and use it in GitHub Desktop.
Save Brianetta/1735370 to your computer and use it in GitHub Desktop.
A chance to see all the locations brought to you in the Let's Play series by bchimself
local dest
local episode
local current_episode
local range = 3 -- sectors, not light years
local EpisodeName = function (episodeKey)
return ('Episode {number}: {systemName}'):interp({
number=episode[episodeKey].Episode,
systemName=episode[episodeKey].Path:GetStarSystem().name,
})
end
local getnexthop = function (dest)
local dX = dest.sectorX - Game.system.path.sectorX
local dY = dest.sectorY - Game.system.path.sectorY
local dZ = dest.sectorZ - Game.system.path.sectorZ
local dH = math.ceil(math.sqrt(dX*dX+dY*dY+dZ*dZ))
if math.ceil(dH) == 1 then
UI.Message('Final jump','bchimself')
else
UI.Message(('At most {total} jumps to go'):interp({total = math.ceil(dH)}),'bchimself')
end
local longhop
longhop = function (jumpdistance)
print("Jump distance: ",jumpdistance)
local multiplier = jumpdistance / dH
local X,Y,Z
X = math.ceil(dX * multiplier) + Game.system.path.sectorX
Y = math.ceil(dY * multiplier) + Game.system.path.sectorY
Z = math.ceil(dZ * multiplier) + Game.system.path.sectorZ
local OK,newdest = pcall(SystemPath.New,X,Y,Z,0)
if OK then
if Game.system.path:IsSameSystem(newdest) then
return longhop(jumpdistance +1)
else
return newdest
end
elseif jumpdistance > range then
return nil
else
return longhop(jumpdistance +1)
end
end
if dH <= 1 then
return dest
else
return longhop(1)
end
end
local givenewship = function ()
Game.player:SetShipType('Viper Defence Craft')
Game.player:SetLabel('LetsPlay')
Game.player:RemoveEquip("DRIVE_CLASS3")
Game.player:AddEquip("DRIVE_MIL3")
Game.player:AddEquip("MILITARY_FUEL",9)
end
local go_next = function (ship,station)
if ship and not ship:IsPlayer() then return end
local nexthop = getnexthop(dest)
if nexthop then
print('Next hop: ',nexthop:GetStarSystem().name)
Game.player:HyperspaceTo(nexthop)
end
end
local onJettison
onJettison = function (ship,cargo)
if ship:IsPlayer() and cargo.type=="HYDROGEN" then
Game.player:SetLabel('LetsPlay')
Game.player:RemoveEquip("DRIVE_CLASS3")
ship:RemoveEquip('SHIELD_GENERATOR',2)
Game.player:AddEquip("DRIVE_MIL3")
ship:RemoveEquip('HYDROGEN',ship:GetEquipCount('CARGO','HYDROGEN'))
ship:RemoveEquip('FUEL_SCOOP')
Game.player:AddEquip("MILITARY_FUEL",9)
EventQueue.onJettison:Disconnect(onJettison)
go_next()
end
end
local onEnterSystem = function(ship)
EventQueue.onShipUndocked:Disconnect(go_next)
if ship:IsPlayer() and ship.label == 'LetsPlay' then
if ship:GetEquipCount('ENGINE','DRIVE_MIL3') < 1 then
UI.Message('Engine broke; replacing...','bchimself')
ship:RemoveEquip('RUBBISH',ship:GetEquipCount('CARGO','RUBBISH'))
Game.player:AddEquip("DRIVE_MIL3")
end
if Game.system.path:IsSameSystem(dest) then
ship:RemoveEquip('RADIOACTIVES',ship:GetEquipCount('CARGO','RADIOACTIVES'))
ship:RemoveEquip('MILITARY_FUEL',ship:GetEquipCount('CARGO','MILITARY_FUEL'))
ship:RemoveEquip('DRIVE_MIL3',ship:GetEquipCount('ENGINE','DRIVE_MIL3'))
ship:AddEquip('AUTOPILOT')
ship:AddEquip('SCANNER')
ship:AddEquip('ATMOSPHERIC_SHIELDING')
ship:AddEquip('DRIVE_CLASS3')
ship:AddEquip('HYDROGEN',9)
ship:AddEquip('FUEL_SCOOP')
ship:AddEquip('SHIELD_GENERATOR',2)
UI.Message("We have arrived.",'bchimself')
ship:SetLabel("Let's Play")
if current_episode < #episode then
current_episode = current_episode +1
dest = episode[current_episode].Path
EventQueue.onJettison:Connect(onJettison)
end
else
local used_fuel = ship:GetEquipCount('CARGO','RADIOACTIVES')
ship:RemoveEquip('RADIOACTIVES',used_fuel)
ship:AddEquip('MILITARY_FUEL',used_fuel)
Timer:CallAt(Game.time+1,go_next)
end
end
end
local onChat = function (form, ref, option)
if option > 0 then
form:Clear()
current_episode = option
dest = episode[option].Path
givenewship()
form:SetMessage(([[You may launch whenever you're ready.
You have my ship, and we're all set to fly to {system}. Once we get there, you
can continue the journey to the next episode by going to the ship inventory
and ejecting a cannister of fuel. That might sound weird, but we'll just have
to put up with it for now.
Hyperspacing will be automatic.
]]):interp({system=episode[option].Path:GetStarSystem().name}))
form:RemoveAdvertOnClose()
EventQueue.onShipUndocked:Connect(go_next)
return
end
local bchimself = Character.New({
name = "bchimself",
female = false,
title = "Let's Play Pioneer",
armour = false,
seed = 3048851323,
})
form:SetTitle("Episode menu")
form:SetFace(bchimself)
form:SetMessage([[This script is like the DVD extra features of the Let's Play series. You will be able
to travel to the locations seen in the series so far. Here, you can choose to visit
the locations from the beginning, or skip to one of the more recent episodes.
Please choose your episode:
]])
second_displayed_episode = #episode - 8
first_flag = true
for episodeKey,yadda in ipairs(episode) do
if first_flag then
form:AddOption(EpisodeName(episodeKey),episodeKey)
first_flag = false
elseif episodeKey > second_displayed_episode then
form:AddOption(EpisodeName(episodeKey),episodeKey)
end
end
end
local onCreateBB = function (station)
station:AddAdvert("Let's Play Pioneer, with bchimself",onChat)
end
local onGameStart = function ()
episode = {
{Episode=06,Path=SystemPath.New( -3, 0, 0, 0 )},
{Episode=07,Path=SystemPath.New( -5, 0, -1, 0 )},
{Episode=09,Path=SystemPath.New( -8, -1, 0, 1 )},
{Episode=10,Path=SystemPath.New( -9, -1, -1, 1 )},
{Episode=10,Path=SystemPath.New( -11, -1, 0, 0 )},
{Episode=11,Path=SystemPath.New( -14, -1, 1, 1 )},
{Episode=12,Path=SystemPath.New( -16, -1, 0, 0 )},
{Episode=13,Path=SystemPath.New( -19, 0, 0, 0 )},
{Episode=13,Path=SystemPath.New( -21, 0, 0, 1 )},
{Episode=14,Path=SystemPath.New( -24, -1, 0, 0 )},
{Episode=15,Path=SystemPath.New( -23, 0, 1, 0 )},
{Episode=16,Path=SystemPath.New( -29, -1, -1, 0 )},
{Episode=17,Path=SystemPath.New( -41, -1, -1, 0 )},
{Episode=18,Path=SystemPath.New( -50, -2, -3, 1 )},
{Episode=19,Path=SystemPath.New( -57, -2, 0, 0 )},
{Episode=20,Path=SystemPath.New( -68, 0, 0, 0 )},
}
end
EventQueue.onGameStart:Connect(onGameStart)
EventQueue.onEnterSystem:Connect(onEnterSystem)
EventQueue.onCreateBB:Connect(onCreateBB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment