mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-04-21 11:56:55 +02:00
Merge pull request #2 from ComfyFactory/planet_prison_fix
planet prison fix
This commit is contained in:
commit
77c4a13783
@ -107,6 +107,9 @@ require 'modules.autostash'
|
|||||||
--![[East VS West Survival PVP, where you breed biters with science flasks]]--
|
--![[East VS West Survival PVP, where you breed biters with science flasks]]--
|
||||||
--require 'maps.biter_hatchery.main'
|
--require 'maps.biter_hatchery.main'
|
||||||
|
|
||||||
|
--![[Fight in a world where everyone are prisoners]]
|
||||||
|
--require 'maps.planet_prison'
|
||||||
|
|
||||||
--![[Chop trees to gain resources]]--
|
--![[Chop trees to gain resources]]--
|
||||||
--require 'maps.choppy'
|
--require 'maps.choppy'
|
||||||
--require 'maps.choppy_dx'
|
--require 'maps.choppy_dx'
|
||||||
@ -201,7 +204,6 @@ require 'modules.autostash'
|
|||||||
--require 'maps.wave_defense'
|
--require 'maps.wave_defense'
|
||||||
--require 'maps.crossing'
|
--require 'maps.crossing'
|
||||||
--require 'maps.anarchy'
|
--require 'maps.anarchy'
|
||||||
--require 'maps.planet_prison'
|
|
||||||
--require 'maps.blue_beach'
|
--require 'maps.blue_beach'
|
||||||
--require 'maps.nightfall'
|
--require 'maps.nightfall'
|
||||||
--require 'maps.pitch_black.main'
|
--require 'maps.pitch_black.main'
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
return '{"blueprint":{"icons":[{"signal":{"type":"item","name":"crash-site-lab-repaired"},"index":1},{"signal":{"type":"item","name":"crash-site-generator"},"index":2}],"entities":[{"entity_number":1,"name":"crash-site-generator","position":{"x":3,"y":-3.5}},{"entity_number":2,"name":"crash-site-lab-repaired","position":{"x":-2,"y":-1}},{"entity_number":3,"name":"crash-site-chest-1","position":{"x":4,"y":-1}},{"entity_number":4,"name":"crash-site-chest-2","position":{"x":-3,"y":3}},{"entity_number":5,"name":"crash-site-assembling-machine-1-repaired","position":{"x":-2,"y":-5}}],"item":"blueprint","version":73019621376}}'
|
return '{"blueprint":{"icons":[{"signal":{"type":"item","name":"crash-site-lab-repaired"},"index":1}],"entities":[{"entity_number":2,"name":"crash-site-chest-1","position":{"x":4,"y":-1}},{"entity_number":3,"name":"crash-site-chest-2","position":{"x":-3,"y":3}}],"item":"blueprint","version":73019621376}}'
|
||||||
|
@ -2,35 +2,35 @@ local public = {}
|
|||||||
|
|
||||||
public.player_ship_loot = {
|
public.player_ship_loot = {
|
||||||
{
|
{
|
||||||
name = "piercing-rounds-magazine",
|
name = 'piercing-rounds-magazine',
|
||||||
count = 35,
|
count = 35
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "grenade",
|
name = 'grenade',
|
||||||
count = 2,
|
count = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "submachine-gun",
|
name = 'submachine-gun',
|
||||||
count = 1,
|
count = 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "light-armor",
|
name = 'light-armor',
|
||||||
count = 1,
|
count = 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "iron-plate",
|
name = 'iron-plate',
|
||||||
count = 30,
|
count = 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "copper-plate",
|
name = 'copper-plate',
|
||||||
count = 10,
|
count = 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "raw-fish",
|
name = 'raw-fish',
|
||||||
count = 2,
|
count = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "small-lamp",
|
name = 'small-lamp',
|
||||||
count = 1
|
count = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,20 +204,20 @@ public.permission_orbit = {
|
|||||||
defines.input_action.upgrade_opened_blueprint,
|
defines.input_action.upgrade_opened_blueprint,
|
||||||
defines.input_action.use_artillery_remote,
|
defines.input_action.use_artillery_remote,
|
||||||
defines.input_action.use_item,
|
defines.input_action.use_item,
|
||||||
defines.input_action.wire_dragging,
|
defines.input_action.wire_dragging
|
||||||
}
|
}
|
||||||
|
|
||||||
public.self_explode = 60 * 60 * 10 -- time until main shipwreck explosion
|
public.self_explode = 60 * 60 * 10 -- time until main shipwreck explosion
|
||||||
public.claim_markers = {
|
public.claim_markers = {
|
||||||
"gun-turret",
|
'gun-turret',
|
||||||
"laser-turret",
|
'laser-turret',
|
||||||
"stone-wall",
|
'stone-wall'
|
||||||
}
|
}
|
||||||
public.claim_max_distance = 15
|
public.claim_max_distance = 15
|
||||||
public.base_costs = {
|
public.base_costs = {
|
||||||
["gun-turret"] = 1,
|
['gun-turret'] = 1,
|
||||||
["laser-turret"] = 5,
|
['laser-turret'] = 5,
|
||||||
["stone-wall"] = 0.1,
|
['stone-wall'] = 0.1
|
||||||
}
|
}
|
||||||
public.raid_costs = {
|
public.raid_costs = {
|
||||||
{
|
{
|
||||||
@ -225,14 +225,14 @@ public.raid_costs = {
|
|||||||
chance = 300,
|
chance = 300,
|
||||||
gear = {
|
gear = {
|
||||||
{
|
{
|
||||||
weap = "shotgun",
|
weap = 'shotgun',
|
||||||
ammo = "shotgun-shell",
|
ammo = 'shotgun-shell',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weap = "pistol",
|
weap = 'pistol',
|
||||||
ammo = "firearm-magazine",
|
ammo = 'firearm-magazine',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -241,14 +241,14 @@ public.raid_costs = {
|
|||||||
chance = 150,
|
chance = 150,
|
||||||
gear = {
|
gear = {
|
||||||
{
|
{
|
||||||
weap = "shotgun",
|
weap = 'shotgun',
|
||||||
ammo = "shotgun-shell",
|
ammo = 'shotgun-shell',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weap = "pistol",
|
weap = 'pistol',
|
||||||
ammo = "firearm-magazine",
|
ammo = 'firearm-magazine',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -257,14 +257,14 @@ public.raid_costs = {
|
|||||||
chance = 100,
|
chance = 100,
|
||||||
gear = {
|
gear = {
|
||||||
{
|
{
|
||||||
weap = "shotgun",
|
weap = 'shotgun',
|
||||||
ammo = "shotgun-shell",
|
ammo = 'shotgun-shell',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weap = "pistol",
|
weap = 'pistol',
|
||||||
ammo = "firearm-magazine",
|
ammo = 'firearm-magazine',
|
||||||
armor = "light-armor"
|
armor = 'light-armor'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -273,14 +273,14 @@ public.raid_costs = {
|
|||||||
chance = 100,
|
chance = 100,
|
||||||
gear = {
|
gear = {
|
||||||
{
|
{
|
||||||
weap = "shotgun",
|
weap = 'shotgun',
|
||||||
ammo = "shotgun-shell",
|
ammo = 'shotgun-shell',
|
||||||
armor = "heavy-armor"
|
armor = 'heavy-armor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weap = "pistol",
|
weap = 'pistol',
|
||||||
ammo = "firearm-magazine",
|
ammo = 'firearm-magazine',
|
||||||
armor = "heavy-armor"
|
armor = 'heavy-armor'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -289,507 +289,495 @@ public.raid_costs = {
|
|||||||
chance = 100,
|
chance = 100,
|
||||||
gear = {
|
gear = {
|
||||||
{
|
{
|
||||||
weap = "shotgun",
|
weap = 'shotgun',
|
||||||
ammo = "piercing-shotgun-shell",
|
ammo = 'piercing-shotgun-shell',
|
||||||
armor = "heavy-armor"
|
armor = 'heavy-armor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weap = "pistol",
|
weap = 'pistol',
|
||||||
ammo = "piercing-rounds-magazine",
|
ammo = 'piercing-rounds-magazine',
|
||||||
armor = "heavy-armor"
|
armor = 'heavy-armor'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public.wreck_loot = {
|
public.wreck_loot = {
|
||||||
["iron-plate"] = {
|
['iron-plate'] = {
|
||||||
rare = 0.1,
|
rare = 0.1,
|
||||||
count = { 20, 40 },
|
count = {20, 40}
|
||||||
},
|
},
|
||||||
["copper-plate"] = {
|
['copper-plate'] = {
|
||||||
rare = 0.1,
|
rare = 0.1,
|
||||||
count = { 10, 30 },
|
count = {10, 30}
|
||||||
},
|
},
|
||||||
["empty-barrel"] = {
|
['empty-barrel'] = {
|
||||||
rare = 0.4,
|
rare = 0.4,
|
||||||
count = { 1, 1},
|
count = {1, 1}
|
||||||
},
|
},
|
||||||
["copper-cable"] = {
|
['copper-cable'] = {
|
||||||
rare = 0.5,
|
rare = 0.5,
|
||||||
count = { 5, 20 },
|
count = {5, 20}
|
||||||
},
|
},
|
||||||
["electronic-circuit"] = {
|
['electronic-circuit'] = {
|
||||||
rare = 0.6,
|
rare = 0.6,
|
||||||
count = { 5, 20 },
|
count = {5, 20}
|
||||||
},
|
},
|
||||||
["firearm-magazine"] = {
|
['firearm-magazine'] = {
|
||||||
rare = 0.4,
|
rare = 0.4,
|
||||||
count = { 1, 2 },
|
count = {1, 2}
|
||||||
},
|
},
|
||||||
["steel-plate"] = {
|
['steel-plate'] = {
|
||||||
rare = 0.8,
|
rare = 0.8,
|
||||||
count = { 1, 5 },
|
count = {1, 5}
|
||||||
},
|
},
|
||||||
["explosives"] = {
|
['explosives'] = {
|
||||||
rare = 0.85,
|
rare = 0.85,
|
||||||
count = { 1, 5 },
|
count = {1, 5}
|
||||||
},
|
},
|
||||||
["advanced-circuit"] = {
|
['advanced-circuit'] = {
|
||||||
rare = 0.9,
|
rare = 0.9,
|
||||||
count = { 1, 5 },
|
count = {1, 5}
|
||||||
},
|
},
|
||||||
["processing-unit"] = {
|
['processing-unit'] = {
|
||||||
rare = 0.95,
|
rare = 0.95,
|
||||||
count = { 1, 2 },
|
count = {1, 2}
|
||||||
},
|
},
|
||||||
["electric-engine-unit"] = {
|
['electric-engine-unit'] = {
|
||||||
rare = 0.95,
|
rare = 0.95,
|
||||||
count = { 1, 1 },
|
count = {1, 1}
|
||||||
},
|
},
|
||||||
["battery"] = {
|
['battery'] = {
|
||||||
rare = 0.95,
|
rare = 0.95,
|
||||||
count = { 1, 2 },
|
count = {1, 2}
|
||||||
},
|
},
|
||||||
["piercing-rounds-magazine"] = {
|
['piercing-rounds-magazine'] = {
|
||||||
rare = 0.99,
|
rare = 0.99,
|
||||||
count = { 1, 2 },
|
count = {1, 2}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public.technologies = {
|
public.technologies = {
|
||||||
["military"] = true,
|
['military'] = true,
|
||||||
["artillery"] = false,
|
['artillery'] = false,
|
||||||
["artillery-shell-range-1"] = false,
|
['artillery-shell-range-1'] = false,
|
||||||
["artillery-shell-speed-1"] = false,
|
['artillery-shell-speed-1'] = false,
|
||||||
["automation-3"] = false,
|
['automation-3'] = false,
|
||||||
["battery-equipment"] = false,
|
['battery-equipment'] = false,
|
||||||
["battery-mk2-equipment"] = false,
|
['battery-mk2-equipment'] = false,
|
||||||
["belt-immunity-equipment"] = false,
|
['belt-immunity-equipment'] = false,
|
||||||
["distractor"] = false,
|
['distractor'] = false,
|
||||||
["destroyer"] = false,
|
['destroyer'] = false,
|
||||||
["discharge-defense-equipment"] = false,
|
['discharge-defense-equipment'] = false,
|
||||||
["energy-shield-equipment"] = false,
|
['energy-shield-equipment'] = false,
|
||||||
["energy-shield-mk2-equipment"] = false,
|
['energy-shield-mk2-equipment'] = false,
|
||||||
["exoskeleton-equipment"] = false,
|
['exoskeleton-equipment'] = false,
|
||||||
["explosive-rocketry"] = false,
|
['explosive-rocketry'] = false,
|
||||||
["flamethrower"] = false,
|
['flamethrower'] = false,
|
||||||
["fusion-reactor-equipment"] = false,
|
['fusion-reactor-equipment'] = false,
|
||||||
["kovarex-enrichment-process"] = false,
|
['kovarex-enrichment-process'] = false,
|
||||||
["land-mine"] = false,
|
['land-mine'] = false,
|
||||||
["logistics-3"] = false,
|
['logistics-3'] = false,
|
||||||
["military-4"] = false,
|
['military-4'] = false,
|
||||||
["modular-armor"] = false,
|
['modular-armor'] = false,
|
||||||
["night-vision-equipment"] = false,
|
['night-vision-equipment'] = false,
|
||||||
["nuclear-fuel-reprocessing"] = false,
|
['nuclear-fuel-reprocessing'] = false,
|
||||||
["nuclear-power"] = false,
|
['nuclear-power'] = false,
|
||||||
["personal-laser-defense-equipment"] = false,
|
['personal-laser-defense-equipment'] = false,
|
||||||
["personal-roboport-equipment"] = false,
|
['personal-roboport-equipment'] = false,
|
||||||
["personal-roboport-mk2-equipment"] = false,
|
['personal-roboport-mk2-equipment'] = false,
|
||||||
["power-armor"] = false,
|
['power-armor'] = false,
|
||||||
["power-armor-mk2"] = false,
|
['power-armor-mk2'] = false,
|
||||||
["refined-flammables-1"] = false,
|
['refined-flammables-1'] = false,
|
||||||
["refined-flammables-2"] = false,
|
['refined-flammables-2'] = false,
|
||||||
["refined-flammables-3"] = false,
|
['refined-flammables-3'] = false,
|
||||||
["refined-flammables-4"] = false,
|
['refined-flammables-4'] = false,
|
||||||
["refined-flammables-5"] = false,
|
['refined-flammables-5'] = false,
|
||||||
["refined-flammables-6"] = false,
|
['refined-flammables-6'] = false,
|
||||||
["refined-flammables-7"] = false,
|
['refined-flammables-7'] = false,
|
||||||
["rocketry"] = false,
|
['rocketry'] = false,
|
||||||
["solar-panel-equipment"] = false,
|
['solar-panel-equipment'] = false,
|
||||||
["stack-inserter"] = false,
|
['stack-inserter'] = false,
|
||||||
["stronger-explosives-2"] = false,
|
['stronger-explosives-2'] = false,
|
||||||
["stronger-explosives-3"] = false,
|
['stronger-explosives-3'] = false,
|
||||||
["stronger-explosives-4"] = false,
|
['stronger-explosives-4'] = false,
|
||||||
["stronger-explosives-5"] = false,
|
['stronger-explosives-5'] = false,
|
||||||
["stronger-explosives-6"] = false,
|
['stronger-explosives-6'] = false,
|
||||||
["stronger-explosives-7"] = false,
|
['stronger-explosives-7'] = false,
|
||||||
["physical-projectile-damage-4"] = false,
|
['physical-projectile-damage-4'] = false,
|
||||||
["physical-projectile-damage-5"] = false,
|
['physical-projectile-damage-5'] = false,
|
||||||
["physical-projectile-damage-6"] = false,
|
['physical-projectile-damage-6'] = false,
|
||||||
["physical-projectile-damage-7"] = false,
|
['physical-projectile-damage-7'] = false,
|
||||||
["weapon-shooting-speed-4"] = false,
|
['weapon-shooting-speed-4'] = false,
|
||||||
["weapon-shooting-speed-5"] = false,
|
['weapon-shooting-speed-5'] = false,
|
||||||
["weapon-shooting-speed-6"] = false,
|
['weapon-shooting-speed-6'] = false,
|
||||||
["energy-weapons-damage-1"] = false,
|
['energy-weapons-damage-1'] = false,
|
||||||
["energy-weapons-damage-2"] = false,
|
['energy-weapons-damage-2'] = false,
|
||||||
["energy-weapons-damage-3"] = false,
|
['energy-weapons-damage-3'] = false,
|
||||||
["energy-weapons-damage-4"] = false,
|
['energy-weapons-damage-4'] = false,
|
||||||
["energy-weapons-damage-5"] = false,
|
['energy-weapons-damage-5'] = false,
|
||||||
["energy-weapons-damage-6"] = false,
|
['energy-weapons-damage-6'] = false,
|
||||||
["energy-weapons-damage-7"] = false,
|
['energy-weapons-damage-7'] = false,
|
||||||
["laser-shooting-speed-2"] = false,
|
['laser-shooting-speed-2'] = false,
|
||||||
["laser-shooting-speed-3"] = false,
|
['laser-shooting-speed-3'] = false,
|
||||||
["laser-shooting-speed-4"] = false,
|
['laser-shooting-speed-4'] = false,
|
||||||
["laser-shooting-speed-5"] = false,
|
['laser-shooting-speed-5'] = false,
|
||||||
["laser-shooting-speed-6"] = false,
|
['laser-shooting-speed-6'] = false,
|
||||||
["laser-shooting-speed-7"] = false,
|
['laser-shooting-speed-7'] = false,
|
||||||
["follower-robot-count-2"] = false,
|
['follower-robot-count-2'] = false,
|
||||||
["follower-robot-count-3"] = false,
|
['follower-robot-count-3'] = false,
|
||||||
["follower-robot-count-4"] = false,
|
['follower-robot-count-4'] = false,
|
||||||
["follower-robot-count-5"] = false,
|
['follower-robot-count-5'] = false,
|
||||||
["follower-robot-count-6"] = false,
|
['follower-robot-count-6'] = false,
|
||||||
["follower-robot-count-7"] = false,
|
['follower-robot-count-7'] = false,
|
||||||
["tank"] = false,
|
['tank'] = false,
|
||||||
["uranium-ammo"] = false,
|
['uranium-ammo'] = false,
|
||||||
["uranium-processing"] = false,
|
['uranium-processing'] = false,
|
||||||
["atomic-bomb"] = false,
|
['atomic-bomb'] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public.merchant_offer = {
|
public.merchant_offer = {
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "iron-plate",
|
name = 'iron-plate',
|
||||||
amount = 10
|
amount = 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "advanced-circuit",
|
name = 'advanced-circuit',
|
||||||
amount = 2
|
amount = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "battery",
|
name = 'battery',
|
||||||
amount = 2
|
amount = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "small-lamp",
|
name = 'small-lamp',
|
||||||
amount = 2
|
amount = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "copper-cable",
|
name = 'copper-cable',
|
||||||
amount = 5
|
amount = 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "steel-plate",
|
name = 'steel-plate',
|
||||||
amount = 1
|
amount = 1
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "nothing",
|
type = 'nothing',
|
||||||
effect_description = "Construct a GPS receiver"
|
effect_description = 'Construct a GPS receiver'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 100
|
amount = 100
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "heavy-armor"
|
item = 'heavy-armor'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 500
|
amount = 500
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "modular-armor"
|
item = 'modular-armor'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 12000
|
amount = 12000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "power-armor"
|
item = 'power-armor'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 100
|
amount = 100
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "night-vision-equipment"
|
item = 'night-vision-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 70
|
amount = 70
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "battery-equipment"
|
item = 'battery-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 700
|
amount = 700
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "battery-mk2-equipment"
|
item = 'battery-mk2-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 1200
|
amount = 1200
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "exoskeleton-equipment"
|
item = 'exoskeleton-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 2500
|
amount = 2500
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "fusion-reactor-equipment"
|
item = 'fusion-reactor-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 200
|
amount = 200
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "personal-roboport-equipment"
|
item = 'personal-roboport-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 400
|
amount = 400
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "personal-roboport-mk2-equipment"
|
item = 'personal-roboport-mk2-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 90
|
amount = 90
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "solar-panel-equipment"
|
item = 'solar-panel-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 300
|
amount = 300
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "energy-shield-equipment"
|
item = 'energy-shield-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 2000
|
amount = 2000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "energy-shield-mk2-equipment"
|
item = 'energy-shield-mk2-equipment'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 50
|
amount = 50
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "flamethrower-ammo"
|
item = 'flamethrower-ammo'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 1
|
amount = 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "firearm-magazine"
|
item = 'firearm-magazine'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 5
|
amount = 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "piercing-rounds-magazine"
|
item = 'piercing-rounds-magazine'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 1000
|
amount = 1000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "unlock-recipe",
|
type = 'unlock-recipe',
|
||||||
recipe = "flamethrower"
|
recipe = 'flamethrower'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 50
|
amount = 50
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "defender-capsule"
|
item = 'defender-capsule'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 200
|
amount = 200
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "distractor-capsule"
|
item = 'distractor-capsule'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 250
|
amount = 250
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "give-item",
|
type = 'give-item',
|
||||||
item = "destroyer-capsule"
|
item = 'destroyer-capsule'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 70
|
amount = 70
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "unlock-recipe",
|
type = 'unlock-recipe',
|
||||||
recipe = "filter-inserter"
|
recipe = 'filter-inserter'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 100
|
amount = 100
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "unlock-recipe",
|
type = 'unlock-recipe',
|
||||||
recipe = "stack-inserter"
|
recipe = 'stack-inserter'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
price = {
|
price = {
|
||||||
{
|
{
|
||||||
type = "item",
|
type = 'item',
|
||||||
name = "coin",
|
name = 'coin',
|
||||||
amount = 170
|
amount = 170
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offer = {
|
offer = {
|
||||||
type = "unlock-recipe",
|
type = 'unlock-recipe',
|
||||||
recipe = "stack-filter-inserter"
|
recipe = 'stack-filter-inserter'
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
price = {
|
|
||||||
{
|
|
||||||
type = "item",
|
|
||||||
name = "coin",
|
|
||||||
amount = 65000
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
offer = {
|
|
||||||
type = "give-item",
|
|
||||||
item = "computer"
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public.manual = [[
|
public.manual =
|
||||||
|
[[
|
||||||
[font=heading-1]Planet Prison (1.1.0) - Manual[/font]
|
[font=heading-1]Planet Prison (1.1.0) - Manual[/font]
|
||||||
[font=default-bold]You did naughty things and was sent to this planet with a one way ticket. Once an industrial site, turned into non-hospitable planet due to pollution and war. Among other inmates, there are still bandits scavenging through the junk looking for rare items.
|
[font=default-bold]You did naughty things and was sent to this planet with a one way ticket. Once an industrial site, turned into non-hospitable planet due to pollution and war. Among other inmates, there are still bandits scavenging through the junk looking for rare items.
|
||||||
|
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
local _common = require(".common")
|
local _common = require('.common')
|
||||||
|
|
||||||
public.command = {
|
public.command = {
|
||||||
--[[
|
--[[
|
||||||
@param args nil
|
@param args nil
|
||||||
--]]
|
--]]
|
||||||
noop = 0,
|
noop = 0,
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@param args nil
|
@param args nil
|
||||||
--]]
|
--]]
|
||||||
seek_and_destroy_player = 1,
|
seek_and_destroy_player = 1,
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@param args = {
|
@param args = {
|
||||||
agents, // All movable agents
|
agents, // All movable agents
|
||||||
@ -25,16 +23,13 @@ public.command = {
|
|||||||
init - Initialize the module.
|
init - Initialize the module.
|
||||||
--]]
|
--]]
|
||||||
public.init = function()
|
public.init = function()
|
||||||
if global.this == nil then
|
|
||||||
global.this = {}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _get_direction(src, dest)
|
local function _get_direction(src, dest)
|
||||||
local src_x = _common.get_axis(src, "x")
|
local src_x = _common.get_axis(src, 'x')
|
||||||
local src_y = _common.get_axis(src, "y")
|
local src_y = _common.get_axis(src, 'y')
|
||||||
local dest_x = _common.get_axis(dest, "x")
|
local dest_x = _common.get_axis(dest, 'x')
|
||||||
local dest_y = _common.get_axis(dest, "y")
|
local dest_y = _common.get_axis(dest, 'y')
|
||||||
|
|
||||||
local step = {
|
local step = {
|
||||||
x = nil,
|
x = nil,
|
||||||
@ -63,7 +58,7 @@ end
|
|||||||
|
|
||||||
local function _move_to(ent, trgt, min_distance)
|
local function _move_to(ent, trgt, min_distance)
|
||||||
local state = {
|
local state = {
|
||||||
walking = false,
|
walking = false
|
||||||
}
|
}
|
||||||
|
|
||||||
local distance = _common.get_distance(trgt.position, ent.position)
|
local distance = _common.get_distance(trgt.position, ent.position)
|
||||||
@ -102,10 +97,10 @@ local function _do_job_seek_and_destroy_player(surf)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local search_info = {
|
local search_info = {
|
||||||
name = "character",
|
name = 'character',
|
||||||
position = player.character.position,
|
position = player.character.position,
|
||||||
radius = 20,
|
radius = 20,
|
||||||
force = "enemy",
|
force = 'enemy'
|
||||||
}
|
}
|
||||||
|
|
||||||
local ents = surf.find_entities_filtered(search_info)
|
local ents = surf.find_entities_filtered(search_info)
|
||||||
@ -148,13 +143,13 @@ local function _do_job_attack_objects(surf, args)
|
|||||||
position = agent.position,
|
position = agent.position,
|
||||||
radius = 15,
|
radius = 15,
|
||||||
type = {
|
type = {
|
||||||
"projectile",
|
'projectile',
|
||||||
"beam"
|
'beam'
|
||||||
},
|
},
|
||||||
force = {
|
force = {
|
||||||
"enemy",
|
'enemy',
|
||||||
"player",
|
'player',
|
||||||
"neutral",
|
'neutral'
|
||||||
},
|
},
|
||||||
invert = true
|
invert = true
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
local _common = require(".common")
|
local _common = require('.common')
|
||||||
|
local Global = require 'utils.global'
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
|
||||||
|
local this = {}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
public.init = function()
|
public.init = function()
|
||||||
if global.this == nil then
|
this._bps = {}
|
||||||
global.this = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
global.this._bps = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -20,7 +27,7 @@ public.push_blueprint = function(name, bp)
|
|||||||
hook = nil,
|
hook = nil,
|
||||||
refs = {}
|
refs = {}
|
||||||
}
|
}
|
||||||
global.this._bps[name] = entry
|
this._bps[name] = entry
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -30,16 +37,18 @@ set_blueprint_hook - Set callback to a blueprint.
|
|||||||
--]]
|
--]]
|
||||||
public.set_blueprint_hook = function(name, hook)
|
public.set_blueprint_hook = function(name, hook)
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.set_blueprint_hook: name is nil")
|
log('bp.set_blueprint_hook: name is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if global.this._bps[name] == nil then
|
if this._bps[name] == nil then
|
||||||
log("bp.set_blueprint_hook: unrecognized blueprint")
|
log('bp.set_blueprint_hook: unrecognized blueprint')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
global.this._bps[name].hook = hook
|
local token = Token.register(hook)
|
||||||
|
|
||||||
|
this._bps[name].hook = token
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -48,13 +57,13 @@ get_references - Get all references of the blueprint on the map.
|
|||||||
--]]
|
--]]
|
||||||
public.get_references = function(name)
|
public.get_references = function(name)
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.get_references: name is nil")
|
log('bp.get_references: name is nil')
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = global.this._bps[name]
|
local object = this._bps[name]
|
||||||
if object == nil then
|
if object == nil then
|
||||||
log("bp.get_references: unrecognized blueprint")
|
log('bp.get_references: unrecognized blueprint')
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,13 +76,13 @@ get_references - Gets opaque object representing bp references.
|
|||||||
--]]
|
--]]
|
||||||
public.get_references = function(name)
|
public.get_references = function(name)
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.get_references: name is nil")
|
log('bp.get_references: name is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = global.this._bps[name]
|
local object = this._bps[name]
|
||||||
if object == nil then
|
if object == nil then
|
||||||
log("bp.get_references: unrecognized blueprint")
|
log('bp.get_references: unrecognized blueprint')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -104,7 +113,6 @@ public.reference_get_timestamp = function(reference)
|
|||||||
return reference.timestamp
|
return reference.timestamp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
unlink_references_filtered - Unlinks all references of blueprint on the map if they
|
unlink_references_filtered - Unlinks all references of blueprint on the map if they
|
||||||
meet the query rules.
|
meet the query rules.
|
||||||
@ -116,13 +124,13 @@ unlinked.
|
|||||||
--]]
|
--]]
|
||||||
public.unlink_references_filtered = function(name, query)
|
public.unlink_references_filtered = function(name, query)
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.get_references: name is nil")
|
log('bp.get_references: name is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = global.this._bps[name]
|
local object = this._bps[name]
|
||||||
if object == nil then
|
if object == nil then
|
||||||
log("bp.get_references: unrecognized blueprint")
|
log('bp.get_references: unrecognized blueprint')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -154,13 +162,13 @@ removed.
|
|||||||
--]]
|
--]]
|
||||||
public.destroy_references_filtered = function(surf, name, query)
|
public.destroy_references_filtered = function(surf, name, query)
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.get_references: name is nil")
|
log('bp.get_references: name is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = global.this._bps[name]
|
local object = this._bps[name]
|
||||||
if object == nil then
|
if object == nil then
|
||||||
log("bp.get_references: unrecognized blueprint")
|
log('bp.get_references: unrecognized blueprint')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -180,7 +188,7 @@ public.destroy_references_filtered = function(surf, name, query)
|
|||||||
|
|
||||||
local tiles = {}
|
local tiles = {}
|
||||||
for _, tile in pairs(ref.tiles) do
|
for _, tile in pairs(ref.tiles) do
|
||||||
tile.name = "concrete"
|
tile.name = 'concrete'
|
||||||
table.insert(tiles, tile)
|
table.insert(tiles, tile)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -200,7 +208,7 @@ public.destroy_references = function(surf, name)
|
|||||||
public.destroy_references_filtered(surf, name, {})
|
public.destroy_references_filtered(surf, name, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
global._bp_destroy_reference = function(surf, ref)
|
local _bp_destroy_reference = function(surf, ref)
|
||||||
for _, ent in pairs(ref.entities) do
|
for _, ent in pairs(ref.entities) do
|
||||||
if ent.valid then
|
if ent.valid then
|
||||||
ent.destroy()
|
ent.destroy()
|
||||||
@ -213,7 +221,7 @@ global._bp_destroy_reference = function(surf, ref)
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
tile.name = "concrete"
|
tile.name = 'concrete'
|
||||||
table.insert(tiles, tile)
|
table.insert(tiles, tile)
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
@ -227,11 +235,11 @@ destroy_reference - Destroys reference of a blueprint at given surface.
|
|||||||
@param reference - Any valid reference.
|
@param reference - Any valid reference.
|
||||||
--]]
|
--]]
|
||||||
public.destroy_reference = function(surf, reference)
|
public.destroy_reference = function(surf, reference)
|
||||||
for _, meta in pairs(global.this._bps) do
|
for _, meta in pairs(this._bps) do
|
||||||
for i = 1, #meta.refs do
|
for i = 1, #meta.refs do
|
||||||
local ref = meta.refs[i]
|
local ref = meta.refs[i]
|
||||||
if reference.id == ref.id then
|
if reference.id == ref.id then
|
||||||
global._bp_destroy_reference(surf, ref)
|
_bp_destroy_reference(surf, ref)
|
||||||
table.remove(meta.refs, i)
|
table.remove(meta.refs, i)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -247,8 +255,8 @@ local function _build_tiles(surf, point, tiles)
|
|||||||
local _tile = {
|
local _tile = {
|
||||||
name = tile.name,
|
name = tile.name,
|
||||||
position = {
|
position = {
|
||||||
x = get_axis(tile.position, "x") + get_axis(point, "x"),
|
x = get_axis(tile.position, 'x') + get_axis(point, 'x'),
|
||||||
y = get_axis(tile.position, "y") + get_axis(point, "y")
|
y = get_axis(tile.position, 'y') + get_axis(point, 'y')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.insert(_tiles, _tile)
|
table.insert(_tiles, _tile)
|
||||||
@ -258,7 +266,6 @@ local function _build_tiles(surf, point, tiles)
|
|||||||
return _tiles
|
return _tiles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function _build_entities(surf, point, entities, hook, args)
|
local function _build_entities(surf, point, entities, hook, args)
|
||||||
local _entities = {}
|
local _entities = {}
|
||||||
|
|
||||||
@ -266,10 +273,10 @@ local function _build_entities(surf, point, entities, hook, args)
|
|||||||
for _, ent in pairs(entities) do
|
for _, ent in pairs(entities) do
|
||||||
local ent_info = {
|
local ent_info = {
|
||||||
position = {
|
position = {
|
||||||
x = get_axis(ent.position, "x") + get_axis(point, "x"),
|
x = get_axis(ent.position, 'x') + get_axis(point, 'x'),
|
||||||
y = get_axis(ent.position, "y") + get_axis(point, "y")
|
y = get_axis(ent.position, 'y') + get_axis(point, 'y')
|
||||||
},
|
},
|
||||||
name = ent.name,
|
name = ent.name
|
||||||
}
|
}
|
||||||
local e = surf.create_entity(ent_info)
|
local e = surf.create_entity(ent_info)
|
||||||
if not e or not e.valid then
|
if not e or not e.valid then
|
||||||
@ -277,7 +284,8 @@ local function _build_entities(surf, point, entities, hook, args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if hook then
|
if hook then
|
||||||
hook(e, args)
|
local token = Token.get(hook)
|
||||||
|
token(e, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(_entities, e)
|
table.insert(_entities, e)
|
||||||
@ -296,18 +304,18 @@ build - Place blueprint at given point.
|
|||||||
--]]
|
--]]
|
||||||
public.build = function(surf, name, point, args)
|
public.build = function(surf, name, point, args)
|
||||||
if surf == nil then
|
if surf == nil then
|
||||||
log("bp.build: surf is nil")
|
log('bp.build: surf is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if name == nil then
|
if name == nil then
|
||||||
log("bp.build: name is nil")
|
log('bp.build: name is nil')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local object = global.this._bps[name]
|
local object = this._bps[name]
|
||||||
if object == nil then
|
if object == nil then
|
||||||
log("bp.set_blueprint_hook: unrecognized blueprint")
|
log('bp.set_blueprint_hook: unrecognized blueprint')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -315,7 +323,7 @@ public.build = function(surf, name, point, args)
|
|||||||
entities = {},
|
entities = {},
|
||||||
tiles = {},
|
tiles = {},
|
||||||
bb = nil,
|
bb = nil,
|
||||||
timestamp = game.tick,
|
timestamp = game.tick
|
||||||
}
|
}
|
||||||
local bbs = {}
|
local bbs = {}
|
||||||
local tiles = object.bp.tiles
|
local tiles = object.bp.tiles
|
||||||
@ -325,9 +333,9 @@ public.build = function(surf, name, point, args)
|
|||||||
table.insert(bbs, bb)
|
table.insert(bbs, bb)
|
||||||
|
|
||||||
local query = {
|
local query = {
|
||||||
name = "character",
|
name = 'character',
|
||||||
area = bb,
|
area = bb,
|
||||||
invert = true,
|
invert = true
|
||||||
}
|
}
|
||||||
for _, ent in pairs(surf.find_entities_filtered(query)) do
|
for _, ent in pairs(surf.find_entities_filtered(query)) do
|
||||||
if ent.valid then
|
if ent.valid then
|
||||||
@ -343,9 +351,9 @@ public.build = function(surf, name, point, args)
|
|||||||
table.insert(bbs, bb)
|
table.insert(bbs, bb)
|
||||||
|
|
||||||
local query = {
|
local query = {
|
||||||
name = "character",
|
name = 'character',
|
||||||
area = bb,
|
area = bb,
|
||||||
invert = true,
|
invert = true
|
||||||
}
|
}
|
||||||
for _, ent_found in pairs(surf.find_entities_filtered(query)) do
|
for _, ent_found in pairs(surf.find_entities_filtered(query)) do
|
||||||
if not ent_found.valid then
|
if not ent_found.valid then
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
local common = require(".common")
|
local common = require('.common')
|
||||||
|
local Global = require 'utils.global'
|
||||||
|
|
||||||
|
local this = {}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
init - Initialize claim system.
|
init - Initialize claim system.
|
||||||
@ -7,30 +17,26 @@ init - Initialize claim system.
|
|||||||
@param max_distance - Maximal distance allowed between markers
|
@param max_distance - Maximal distance allowed between markers
|
||||||
--]]
|
--]]
|
||||||
public.init = function(names, max_distance)
|
public.init = function(names, max_distance)
|
||||||
if global.this == nil then
|
if type(names) ~= 'table' then
|
||||||
global.this = {}
|
names = {names}
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(names) ~= "table" then
|
this._claims_info = {}
|
||||||
names = { names }
|
this._claims_visible_to = {}
|
||||||
end
|
this._claim_markers = names
|
||||||
|
this._claim_max_dist = max_distance
|
||||||
global.this._claims_info = {}
|
|
||||||
global.this._claims_visible_to = {}
|
|
||||||
global.this._claim_markers = names
|
|
||||||
global.this._claim_max_dist = max_distance
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function claim_new_claim(ent, deps)
|
local function claim_new_claim(ent, deps)
|
||||||
local comm = deps.common
|
local comm = deps.common
|
||||||
local point = {
|
local point = {
|
||||||
{
|
{
|
||||||
x = comm.get_axis(ent.position, "x"),
|
x = comm.get_axis(ent.position, 'x'),
|
||||||
y = comm.get_axis(ent.position, "y"),
|
y = comm.get_axis(ent.position, 'y')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local claims = global.this._claims_info
|
local claims = this._claims_info
|
||||||
if claims[ent.force.name] == nil then
|
if claims[ent.force.name] == nil then
|
||||||
claims[ent.force.name] = {}
|
claims[ent.force.name] = {}
|
||||||
claims[ent.force.name].polygons = {}
|
claims[ent.force.name].polygons = {}
|
||||||
@ -42,10 +48,10 @@ local function claim_new_claim(ent, deps)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function claim_on_build_entity(ent, deps)
|
local function claim_on_build_entity(ent, deps)
|
||||||
local max_dist = global.this._claim_max_dist
|
local max_dist = this._claim_max_dist
|
||||||
local force = ent.force.name
|
local force = ent.force.name
|
||||||
local comm = deps.common
|
local comm = deps.common
|
||||||
local data = global.this._claims_info[force]
|
local data = this._claims_info[force]
|
||||||
|
|
||||||
if data == nil then
|
if data == nil then
|
||||||
claim_new_claim(ent, deps)
|
claim_new_claim(ent, deps)
|
||||||
@ -66,8 +72,8 @@ local function claim_on_build_entity(ent, deps)
|
|||||||
|
|
||||||
in_range = true
|
in_range = true
|
||||||
point = {
|
point = {
|
||||||
x = comm.get_axis(ent.position, "x"),
|
x = comm.get_axis(ent.position, 'x'),
|
||||||
y = comm.get_axis(ent.position, "y"),
|
y = comm.get_axis(ent.position, 'y')
|
||||||
}
|
}
|
||||||
table.insert(points, point)
|
table.insert(points, point)
|
||||||
data.claims[i] = comm.get_convex_hull(points)
|
data.claims[i] = comm.get_convex_hull(points)
|
||||||
@ -83,7 +89,7 @@ local function claim_on_build_entity(ent, deps)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function claims_in_markers(name)
|
local function claims_in_markers(name)
|
||||||
for _, marker in pairs(global.this._claim_markers) do
|
for _, marker in pairs(this._claim_markers) do
|
||||||
if name == marker then
|
if name == marker then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -102,7 +108,7 @@ public.on_built_entity = function(ent)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local deps = {
|
local deps = {
|
||||||
common = common,
|
common = common
|
||||||
}
|
}
|
||||||
claim_on_build_entity(ent, deps)
|
claim_on_build_entity(ent, deps)
|
||||||
end
|
end
|
||||||
@ -110,7 +116,7 @@ end
|
|||||||
local function claim_on_entity_died(ent, deps)
|
local function claim_on_entity_died(ent, deps)
|
||||||
local comm = deps.common
|
local comm = deps.common
|
||||||
local force = ent.force.name
|
local force = ent.force.name
|
||||||
local data = global.this._claims_info[force]
|
local data = this._claims_info[force]
|
||||||
if data == nil then
|
if data == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -136,7 +142,7 @@ local function claim_on_entity_died(ent, deps)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #data.claims == 0 then
|
if #data.claims == 0 then
|
||||||
global.this._claims_info[force] = nil
|
this._claims_info[force] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -150,7 +156,7 @@ public.on_entity_died = function(ent)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local deps = {
|
local deps = {
|
||||||
common = common,
|
common = common
|
||||||
}
|
}
|
||||||
claim_on_entity_died(ent, deps)
|
claim_on_entity_died(ent, deps)
|
||||||
end
|
end
|
||||||
@ -168,7 +174,7 @@ on_player_died - Event processing function
|
|||||||
@param player - Player
|
@param player - Player
|
||||||
--]]
|
--]]
|
||||||
public.on_player_died = function(player)
|
public.on_player_died = function(player)
|
||||||
global.this._claims_info[player.name] = nil
|
this._claims_info[player.name] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -176,16 +182,16 @@ get_claims - Get all claims data points for given force.
|
|||||||
@param f_name - Force name.
|
@param f_name - Force name.
|
||||||
--]]
|
--]]
|
||||||
public.get_claims = function(f_name)
|
public.get_claims = function(f_name)
|
||||||
if global.this._claims_info[f_name] == nil then
|
if this._claims_info[f_name] == nil then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return global.this._claims_info[f_name].claims
|
return this._claims_info[f_name].claims
|
||||||
end
|
end
|
||||||
|
|
||||||
local function claims_update_visiblity()
|
local function claims_update_visiblity()
|
||||||
if #global.this._claims_visible_to == 0 then
|
if #this._claims_visible_to == 0 then
|
||||||
for _, info in pairs(global.this._claims_info) do
|
for _, info in pairs(this._claims_info) do
|
||||||
for _, id in pairs(info.polygons) do
|
for _, id in pairs(info.polygons) do
|
||||||
if rendering.is_valid(id) then
|
if rendering.is_valid(id) then
|
||||||
rendering.set_visible(id, false)
|
rendering.set_visible(id, false)
|
||||||
@ -195,11 +201,11 @@ local function claims_update_visiblity()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, info in pairs(global.this._claims_info) do
|
for _, info in pairs(this._claims_info) do
|
||||||
for _, id in pairs(info.polygons) do
|
for _, id in pairs(info.polygons) do
|
||||||
if rendering.is_valid(id) then
|
if rendering.is_valid(id) then
|
||||||
rendering.set_visible(id, true)
|
rendering.set_visible(id, true)
|
||||||
rendering.set_players(id, global.this._claims_visible_to)
|
rendering.set_players(id, this._claims_visible_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -210,13 +216,13 @@ set_visibility_to - Specifies who can see the claims and redraws.
|
|||||||
@param name - Name of a player.
|
@param name - Name of a player.
|
||||||
--]]
|
--]]
|
||||||
public.set_visibility_to = function(name)
|
public.set_visibility_to = function(name)
|
||||||
for _, p in pairs(global.this._claims_visible_to) do
|
for _, p in pairs(this._claims_visible_to) do
|
||||||
if p == name then
|
if p == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(global.this._claims_visible_to, name)
|
table.insert(this._claims_visible_to, name)
|
||||||
claims_update_visiblity()
|
claims_update_visiblity()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -225,10 +231,10 @@ remove_visibility_from - Remove the claim visibility from the player.
|
|||||||
@param name - Name of a player.
|
@param name - Name of a player.
|
||||||
--]]
|
--]]
|
||||||
public.remove_visibility_from = function(name)
|
public.remove_visibility_from = function(name)
|
||||||
for i = 1, #global.this._claims_visible_to do
|
for i = 1, #this._claims_visible_to do
|
||||||
local p = global.this._claims_visible_to[i]
|
local p = this._claims_visible_to[i]
|
||||||
if p == name then
|
if p == name then
|
||||||
table.remove(global.this._claims_visible_to, i)
|
table.remove(this._claims_visible_to, i)
|
||||||
claims_update_visiblity()
|
claims_update_visiblity()
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
|
local Global = require 'utils.global'
|
||||||
|
|
||||||
|
local this = {}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
public.init = function()
|
public.init = function()
|
||||||
if global.this == nil then
|
if this == nil then
|
||||||
global.this = {}
|
this = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -12,11 +22,11 @@ rand_range - Return random integer within the range.
|
|||||||
@param stop - Stop range.
|
@param stop - Stop range.
|
||||||
--]]
|
--]]
|
||||||
public.rand_range = function(start, stop)
|
public.rand_range = function(start, stop)
|
||||||
if not global.this.rng then
|
if not this.rng then
|
||||||
global.this.rng = game.create_random_generator()
|
this.rng = game.create_random_generator()
|
||||||
end
|
end
|
||||||
|
|
||||||
return global.this.rng(start, stop)
|
return this.rng(start, stop)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
local _common = require(".common")
|
local _common = require('.common')
|
||||||
local _simplex = require(".simplex_noise")
|
local _simplex = require('.simplex_noise')
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
local Global = require 'utils.global'
|
||||||
|
|
||||||
|
local this = {}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
public.init = function()
|
public.init = function()
|
||||||
if global.this == nil then
|
this._grid = {}
|
||||||
global.this = {}
|
this._exclusions = {}
|
||||||
end
|
this._layers = {}
|
||||||
|
this._collision_mask = {}
|
||||||
global.this._grid = {}
|
|
||||||
global.this._exclusions = {}
|
|
||||||
global.this._layers = {}
|
|
||||||
global.this._collision_mask = {}
|
|
||||||
_simplex.init()
|
_simplex.init()
|
||||||
end
|
end
|
||||||
--[[
|
--[[
|
||||||
@ -18,7 +25,7 @@ push_chunk - Pushes chunk position into a grid for later processing.
|
|||||||
@param chunk - ChunkPosition
|
@param chunk - ChunkPosition
|
||||||
--]]
|
--]]
|
||||||
public.push_chunk = function(chunk)
|
public.push_chunk = function(chunk)
|
||||||
table.insert(global.this._grid, chunk)
|
table.insert(this._grid, chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -26,7 +33,7 @@ add_excluding_bounding_box - Pushes bounding box into exclusion list.
|
|||||||
@param bb - BoundindBox.
|
@param bb - BoundindBox.
|
||||||
--]]
|
--]]
|
||||||
public.push_excluding_bounding_box = function(bb)
|
public.push_excluding_bounding_box = function(bb)
|
||||||
table.insert(global.this._exclusions, bb)
|
table.insert(this._exclusions, bb)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -34,10 +41,10 @@ remove_ecluding_bounding_box - Removes bounding box from exclusion list.
|
|||||||
@param bb - BoundingBox to get rid of.
|
@param bb - BoundingBox to get rid of.
|
||||||
--]]
|
--]]
|
||||||
public.remove_excluding_bounding_box = function(bb)
|
public.remove_excluding_bounding_box = function(bb)
|
||||||
for i = 1, #global.this._exclusions do
|
for i = 1, #this._exclusions do
|
||||||
local box = global.this._exclusions[i]
|
local box = this._exclusions[i]
|
||||||
if box == bb then
|
if box == bb then
|
||||||
table.remove(global.this._exclusions, i)
|
table.remove(this._exclusions, i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -60,10 +67,10 @@ public.add_noise_layer = function(type, name, objects, elevation, resolution)
|
|||||||
resolution = resolution,
|
resolution = resolution,
|
||||||
cache = {},
|
cache = {},
|
||||||
hook = nil,
|
hook = nil,
|
||||||
deps = nil,
|
deps = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
table.insert(global.this._layers, layer)
|
table.insert(this._layers, layer)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -72,7 +79,7 @@ add_noise_layer_hook - Execute callback on created object.
|
|||||||
@param hook - Callback that will be called with an object argument.
|
@param hook - Callback that will be called with an object argument.
|
||||||
--]]
|
--]]
|
||||||
public.add_noise_layer_hook = function(name, hook)
|
public.add_noise_layer_hook = function(name, hook)
|
||||||
for _, layer in pairs(global.this._layers) do
|
for _, layer in pairs(this._layers) do
|
||||||
if layer.name == name then
|
if layer.name == name then
|
||||||
layer.hook = hook
|
layer.hook = hook
|
||||||
break
|
break
|
||||||
@ -86,7 +93,7 @@ lua variable. This dependency then is injected into hook.
|
|||||||
@param deps - Dependencies, any variable.
|
@param deps - Dependencies, any variable.
|
||||||
--]]
|
--]]
|
||||||
public.add_noise_layer_dependency = function(name, deps)
|
public.add_noise_layer_dependency = function(name, deps)
|
||||||
for _, layer in pairs(global.this._layers) do
|
for _, layer in pairs(this._layers) do
|
||||||
if layer.name == name then
|
if layer.name == name then
|
||||||
layer.deps = deps
|
layer.deps = deps
|
||||||
break
|
break
|
||||||
@ -99,7 +106,7 @@ set_collision_mask - Set which tiles should be ignored.
|
|||||||
@param mask - Table of collision masks.
|
@param mask - Table of collision masks.
|
||||||
--]]
|
--]]
|
||||||
public.set_collision_mask = function(mask)
|
public.set_collision_mask = function(mask)
|
||||||
global.this._collision_mask = mask
|
this._collision_mask = mask
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _do_job_tile(surf, layer)
|
local function _do_job_tile(surf, layer)
|
||||||
@ -108,9 +115,24 @@ end
|
|||||||
|
|
||||||
local function _do_job_entity(surf, layer)
|
local function _do_job_entity(surf, layer)
|
||||||
local hook = layer.hook
|
local hook = layer.hook
|
||||||
|
if not hook then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local func = Token.get(hook)
|
||||||
|
if not func then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
func = Token.get(func)
|
||||||
local deps = layer.deps
|
local deps = layer.deps
|
||||||
|
if not deps then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local func2 = Token.get(deps)
|
||||||
|
if not func2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
for _, object in pairs(layer.cache) do
|
for _, object in pairs(layer.cache) do
|
||||||
if object.name == "character" or object.name == "gun-turret" then
|
if object.name == 'character' or object.name == 'gun-turret' then
|
||||||
if not surf.can_place_entity(object) then
|
if not surf.can_place_entity(object) then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
@ -122,7 +144,7 @@ local function _do_job_entity(surf, layer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if hook then
|
if hook then
|
||||||
hook(ent, deps)
|
func(ent, func2)
|
||||||
end
|
end
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
@ -132,20 +154,20 @@ end
|
|||||||
local function _do_job(surf, x, y)
|
local function _do_job(surf, x, y)
|
||||||
local point = {
|
local point = {
|
||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, exclusion in pairs(global.this._exclusions) do
|
for _, exclusion in pairs(this._exclusions) do
|
||||||
if _common.point_in_bounding_box(point, exclusion) then
|
if _common.point_in_bounding_box(point, exclusion) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, layer in pairs(global.this._layers) do
|
for _, layer in pairs(this._layers) do
|
||||||
local ret = _simplex.get(point, layer.resolution)
|
local ret = _simplex.get(point, layer.resolution)
|
||||||
if ret >= layer.elevation then
|
if ret >= layer.elevation then
|
||||||
local tile = surf.get_tile(point)
|
local tile = surf.get_tile(point)
|
||||||
for _, mask in pairs(global.this._collision_mask) do
|
for _, mask in pairs(this._collision_mask) do
|
||||||
if tile.collides_with(mask) then
|
if tile.collides_with(mask) then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
@ -159,7 +181,7 @@ local function _do_job(surf, x, y)
|
|||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
name = object_name,
|
name = object_name,
|
||||||
position = point,
|
position = point
|
||||||
}
|
}
|
||||||
table.insert(layer.cache, object)
|
table.insert(layer.cache, object)
|
||||||
|
|
||||||
@ -174,13 +196,13 @@ do_job - Do a single step propagation of a layers.
|
|||||||
@param surf - LuaSurface, onto which action is taken.
|
@param surf - LuaSurface, onto which action is taken.
|
||||||
--]]
|
--]]
|
||||||
public.do_job = function(surf)
|
public.do_job = function(surf)
|
||||||
if #global.this._grid <= 0 then
|
if #this._grid <= 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local chunk = table.remove(global.this._grid)
|
local chunk = table.remove(this._grid)
|
||||||
local x = _common.get_axis(chunk, "x")
|
local x = _common.get_axis(chunk, 'x')
|
||||||
local y = _common.get_axis(chunk, "y")
|
local y = _common.get_axis(chunk, 'y')
|
||||||
|
|
||||||
chunk = {
|
chunk = {
|
||||||
left_top = {
|
left_top = {
|
||||||
@ -189,18 +211,18 @@ public.do_job = function(surf)
|
|||||||
},
|
},
|
||||||
right_bottom = {
|
right_bottom = {
|
||||||
x = (x * 32) + 32,
|
x = (x * 32) + 32,
|
||||||
y = (y * 32) + 32,
|
y = (y * 32) + 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_common.for_bounding_box(surf, chunk, _do_job)
|
_common.for_bounding_box(surf, chunk, _do_job)
|
||||||
|
|
||||||
for _, layer in pairs(global.this._layers) do
|
for _, layer in pairs(this._layers) do
|
||||||
local cache = layer.cache
|
local cache = layer.cache
|
||||||
if #cache >= 1 then
|
if #cache >= 1 then
|
||||||
if layer.type == "LuaTile" then
|
if layer.type == 'LuaTile' then
|
||||||
_do_job_tile(surf, layer)
|
_do_job_tile(surf, layer)
|
||||||
elseif layer.type == "LuaEntity" then
|
elseif layer.type == 'LuaEntity' then
|
||||||
_do_job_entity(surf, layer)
|
_do_job_entity(surf, layer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
local public = {}
|
local public = {}
|
||||||
local _global = require('utils.global')
|
local Global = require 'utils.global'
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
|
||||||
|
local this = {}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
public.init = function()
|
public.init = function()
|
||||||
if global.this == nil then
|
this.timers = {}
|
||||||
global.this = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
global.this.timers = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -16,16 +22,18 @@ set_timer - Sets a timer.
|
|||||||
--]]
|
--]]
|
||||||
public.set_timer = function(left, hook)
|
public.set_timer = function(left, hook)
|
||||||
local id = game.tick
|
local id = game.tick
|
||||||
|
local token = Token.register(hook)
|
||||||
|
local token2 = Token.register(left)
|
||||||
local entry = {
|
local entry = {
|
||||||
left = left,
|
left = token2,
|
||||||
hook_finish = hook,
|
hook_finish = token,
|
||||||
hook_update = nil,
|
hook_update = nil,
|
||||||
deps = nil,
|
deps = nil,
|
||||||
running = false,
|
running = false,
|
||||||
last_update = 0,
|
last_update = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
global.this.timers[id] = entry
|
this.timers[id] = entry
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,7 +44,8 @@ timers is updated.
|
|||||||
@param hook - Hook that will be executed per update.
|
@param hook - Hook that will be executed per update.
|
||||||
--]]
|
--]]
|
||||||
public.set_timer_on_update = function(id, hook)
|
public.set_timer_on_update = function(id, hook)
|
||||||
global.this.timers[id].hook_update = hook
|
local token = Token.register(hook)
|
||||||
|
this.timers[id].hook_update = token
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -45,7 +54,8 @@ set_timer_dependency - Adds dependency into user callback.
|
|||||||
@param deps - Dependency of timer to add.
|
@param deps - Dependency of timer to add.
|
||||||
--]]
|
--]]
|
||||||
public.set_timer_dependency = function(id, deps)
|
public.set_timer_dependency = function(id, deps)
|
||||||
global.this.timers[id].deps = deps
|
local token = Token.register(deps)
|
||||||
|
this.timers[id].deps = token
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -53,8 +63,8 @@ set_timer_start - Sets the timer to run.
|
|||||||
@param id - Id of a timer.
|
@param id - Id of a timer.
|
||||||
--]]
|
--]]
|
||||||
public.set_timer_start = function(id)
|
public.set_timer_start = function(id)
|
||||||
global.this.timers[id].running = true
|
this.timers[id].running = true
|
||||||
global.this.timers[id].last_update = game.tick
|
this.timers[id].last_update = game.tick
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -62,14 +72,14 @@ kill_timer - Effectivly kills the timer.
|
|||||||
@param id - Timer id.
|
@param id - Timer id.
|
||||||
--]]
|
--]]
|
||||||
public.kill_timer = function(id)
|
public.kill_timer = function(id)
|
||||||
global.this.timers[id] = nil
|
this.timers[id] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
do_job - Execute timer logic within a tick.
|
do_job - Execute timer logic within a tick.
|
||||||
--]]
|
--]]
|
||||||
public.do_job = function()
|
public.do_job = function()
|
||||||
for id, entry in pairs(global.this.timers) do
|
for id, entry in pairs(this.timers) do
|
||||||
if entry.running == false then
|
if entry.running == false then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
@ -89,7 +99,7 @@ public.do_job = function()
|
|||||||
|
|
||||||
::premature_finish::
|
::premature_finish::
|
||||||
entry.hook_finish(entry.deps)
|
entry.hook_finish(entry.deps)
|
||||||
global.this.timers[id] = nil
|
this.timers[id] = nil
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user