Skip to content

Instantly share code, notes, and snippets.

@Sambo3975
Created April 6, 2017 20:23
Show Gist options
  • Save Sambo3975/61def1cd7cfe9dbefd802ce9b0a26518 to your computer and use it in GitHub Desktop.
Save Sambo3975/61def1cd7cfe9dbefd802ce9b0a26518 to your computer and use it in GitHub Desktop.
--------------------------------------------
-- lineNpcs - NPC extension for lineguide --
---------- Created by Sambo, 2017 ----------
--------------------------------------------
local npcManager = API.load("npcManager")
local pnpc = API.load("pnpc")
--293
local lineNpcs = {}
local SMW_WOOD_PLATFORM_ID = 339
local YI_GREEN_PLATFORM_ID = 341
local YI_YELLOW_PLATFORM_ID = 342
local YI_RED_PLATFORM_ID = 343
local BLUE_SKULL_RAFT_ID = 340
local lineguide = API.load("lineguide")
assert(lineguide, "Unable to load lineguide API")
-- table concatenation
local mt = {
__concat = function(lhs, rhs) -- lhs .. rhs
local tabl = {}
for k,v in pairs (lhs) do
tabl[k] = v;
end
for k,v in pairs (rhs) do -- duplicate values in second table overwrite values in first table.
tabl[k] = v;
end
return tabl;
end
}
----------------------------------------------------------
---- Extended vanilla stuff ----
----------------------------------------------------------
--Skull Raft
lineguide.properties[190] = {activeByDefault = false, activateOnStanding = true, activateNearby = true}
--[[******************************************************
* Update Skull Raft
* Activate the skull raft if its vanilla activation flag becomes true
******************************************************]]
function lineNpcs.checkSkullRaftActivation(npc)
if npc.ai1 == 1 and not npc.data.lineguide.active then
npc.data.lineguide.active = true
end
end
----------------------------------------------------------
---- New NPCs - Mainly just setting of properties ----
----------------------------------------------------------
--Register the NPCs with lineguide
lineguide.registerNpcs({SMW_WOOD_PLATFORM_ID, YI_GREEN_PLATFORM_ID, YI_YELLOW_PLATFORM_ID, YI_RED_PLATFORM_ID, BLUE_SKULL_RAFT_ID})
--Basic platform settings
local basicPlatformSettings = {speed = 0, playerblocktop = -1, npcblocktop = -1, nohurt = -1, frames = 1, framestyle = 0, noiceball = -1}
setmetatable(basicPlatformSettings, mt) -- set up concatenation
--SMW wood platform
local smwWoodPlatformSettings = basicPlatformSettings .. {id = SMW_WOOD_PLATFORM_ID, width = 96, height = 122}
npcManager.setNpcSettings(smwWoodPlatformSettings)
lineguide.properties[SMW_WOOD_PLATFORM_ID] = {lineSpeed = 1.8, activeByDefault = false, fallWhenInactive = false, activateOnStanding = true}
--YI platforms
local yiPlatformSettings = basicPlatformSettings .. {width = 96, height = 24}
setmetatable(yiPlatformSettings, mt)
local yiGreenPlatformSettings = yiPlatformSettings .. {id = YI_GREEN_PLATFORM_ID}
local yiYellowPlatformSettings = yiPlatformSettings .. {id = YI_YELLOW_PLATFORM_ID}
local yiRedPlatformSettings = yiPlatformSettings .. {id = YI_RED_PLATFORM_ID}
npcManager.setNpcSettings(yiGreenPlatformSettings)
npcManager.setNpcSettings(yiYellowPlatformSettings)
npcManager.setNpcSettings(yiRedPlatformSettings)
lineguide.properties[YI_GREEN_PLATFORM_ID] = {lineSpeed = 2, activeByDefault = false, fallWhenInactive = false, activateOnStanding = true}
lineguide.properties[YI_YELLOW_PLATFORM_ID] = {lineSpeed = 3, activeByDefault = false, fallWhenInactive = false, activateOnStanding = true}
lineguide.properties[YI_RED_PLATFORM_ID] = {lineSpeed = 4, activeByDefault = false, fallWhenInactive = false, activateOnStanding = true}
--Blue Skull Raft
blueSkullRaftSettings = basicPlatformSettings .. {width = 32, height = 20,}
return lineNpcs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment