Skip to content

Instantly share code, notes, and snippets.

View Brianetta's full-sized avatar

Brian Ronald Brianetta

  • North East England
View GitHub Profile

Sent: Monday, 05 March, 2012 at 9:45 pm by Brianetta

Benamucki wrote:Hi Brian,

by adding a "break" in those loops you no longer get the minimum and therefore fair price, the calculation of "due" is also broken. These features were actually the intention of the script.

@Brianetta
Brianetta / OutOfFuel.lua
Created February 25, 2012 00:56
Replacement fuel warning script
local onShipFuelChanged = function (ship, state)
if ship:IsPlayer() then
Game.player:SetFuelPercent()
else
if state == "EMPTY" then
print(('{label} ({type}) out of fuel'):interp({label=ship.label,type=ship.shipType}))
end
end
end
@Brianetta
Brianetta / DeliverPackage.lua
Created February 21, 2012 20:57
Benamucki's DeliverPackage.lua
-- Get the translator function
local t = Translate:GetTranslator()
-- don't produce missions for further than this many light years away
local max_delivery_dist = 20
local hourly_rate = 2000 / (24 * 30)
local AU = 149598000000.0 -- Game uses this approximation
local ads = {}
local missions = {}
@Brianetta
Brianetta / target.lua
Created February 15, 2012 21:31
Target function
target = function (label)
if not label then return end
local target = (Space.GetBodies(function (body) return body.label == label end))[1]
if not target then return end
if target:isa('Ship') then
if not target:IsPlayer() then
Game.player:SetCombatTarget(target)
end
else
Game.player:SetNavTarget(target)
@Brianetta
Brianetta / Star brightness.markdown
Created February 13, 2012 02:12
Inverse square law

@Luomu wrote:

This could be fixed by giving the sun a halo that stops getting smaller after certain distance. Or just fading the star out, right now the brightness of the star pixels stays the same at all distances.

I don't really have a good grasp of this: What should the sun look like from 8 AU away? Is it appropriate to decrease the brightness at all? @Brianetta would you perhaps know :)

Radiation, including sunlight, obeys the inverse square law. The amount of radiation falling on a surface from a point light source is inversely proportional to the square of the distance. If you have two otherwise identical cameras, and one is twice as far away, it will get a quarter of the light entering its aperture. Three times as far means a ninth of the light.

Note that while this diminishes very rapidly when close to the light source, it approaches an asymptote with distance, which is why you'll never travel so far from a star that you can't see it any more.

@Brianetta
Brianetta / lets_play_extra_features.lua
Created February 4, 2012 04:36
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,
})
@Brianetta
Brianetta / fly_with_brian.lua
Created February 4, 2012 01:10
Fly Places with Brian (generic edition)
local dest
local coordinate_choice
local choices
local brianetta = Character.New({
name = "Brian Ronald",
female = false,
title = "Pioneer Developer",
armour = false,
seed = 2397007322,
@Brianetta
Brianetta / test_systems.lua
Created December 19, 2011 21:57
Sample star system grid generator
-- Define some desired system types
local systypes = {
{'STAR_A_GIANT','STAR_F_GIANT'},
{'STAR_M_SUPER_GIANT','STAR_K_SUPER_GIANT'},
{'STAR_G_HYPER_GIANT','STAR_B_HYPER_GIANT'},
{'STAR_S_BH','WHITE_DWARF'},
{'STAR_IM_BH'},
{'STAR_SM_BH'},
{'STAR_O','STAR_O','STAR_O','STAR_O',},
}

Prerequisites

Terminology:

Mesh - a 3d model produced and animated by an artist. Inclusive of all (base) textures and UV maps. Model - a mesh that has been imported to the game and given some attributes; not necessarily 'ready to use'. Object - a game object that is ready to use. May either be a single model or several 'clicked together'. To all intents and purposes an exemplar of an entity. Entity - an instance of an Object as seen by the game.

  1. Meshes are designed / animated in .x format. This exposes a number of features, notably bones that can easily be identified, the ability to manipulate (or add) a basic rig to an object. Meshes are the base renderable type.
@Brianetta
Brianetta / fly_with_brian.lua
Created December 5, 2011 13:54
Pioneer script for flying to interesting places.
local dest
local range = 5 -- sectors, not light years
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))