-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Lamp tool; Added Trail tool; Added Resizer sound and reset key; Fixed some UI errors and bugs; Replaced SpawnParticle by Particle spawn directly;
- Loading branch information
Showing
18 changed files
with
217 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- Method to handle when Player picks up the Tool | ||
function HandleLampTool(weapon) | ||
-- Subscribe when the player fires with this weapon | ||
weapon:Subscribe("Fire", function(weapon, shooter) | ||
-- Makes a trace 10000 units ahead | ||
local trace_result = TraceFor(10000, CollisionChannel.WorldStatic | CollisionChannel.WorldDynamic | CollisionChannel.PhysicsBody | CollisionChannel.Vehicle | CollisionChannel.Pawn) | ||
|
||
if (trace_result.Success) then | ||
local distance_trace_object = Vector() | ||
if (trace_result.Entity) then | ||
-- If hit an entity, then calculates the offset distance from the Hit and the Object | ||
distance_trace_object = trace_result.Entity:GetLocation() - trace_result.Location | ||
end | ||
|
||
-- Calls remote to spawn the Lamp | ||
Events:CallRemote("SpawnLamp", {trace_result.Location, trace_result.Normal, trace_result.Entity, distance_trace_object}) | ||
else | ||
-- If didn't hit anything, plays a negative sound | ||
Sound(Vector(), "NanosWorld::A_Invalid_Action", true, true, SoundType.SFX, 1) | ||
end | ||
end) | ||
end | ||
|
||
Events:Subscribe("PickUpToolGun_LampTool", function(tool) | ||
HandleLampTool(tool) | ||
end) | ||
|
||
Events:Subscribe("DropToolGun_LampTool", function(tool) | ||
tool:Unsubscribe("Fire") | ||
end) | ||
|
||
-- Adds this tool to the Sandbox Spawn Menu | ||
AddSpawnMenuItem("NanosWorld", "tools", "LampTool", "Lamps", "assets///NanosWorld/Thumbnails/SK_Blaster.jpg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Method to handle when Player picks up the Tool | ||
function HandleTrailTool(weapon) | ||
-- Subscribe when the player fires with this weapon | ||
weapon:Subscribe("Fire", function(weapon, shooter) | ||
-- Makes a trace 10000 units ahead to spawn the balloon | ||
local trace_result = TraceFor(10000, CollisionChannel.WorldStatic | CollisionChannel.WorldDynamic | CollisionChannel.PhysicsBody | CollisionChannel.Vehicle | CollisionChannel.Pawn) | ||
|
||
-- If hit some object, then spawns a trail on attached it | ||
if (trace_result.Success and trace_result.Entity) then | ||
Events:CallRemote("SpawnTrail", {trace_result.Location, trace_result.Normal, trace_result.Entity}) | ||
else | ||
-- If didn't hit anything, plays a negative sound | ||
Sound(Vector(), "NanosWorld::A_Invalid_Action", true, true, SoundType.SFX, 1) | ||
end | ||
end) | ||
end | ||
|
||
Events:Subscribe("PickUpToolGun_TrailTool", function(tool, character) | ||
HandleTrailTool(tool) | ||
end) | ||
|
||
Events:Subscribe("DropToolGun_TrailTool", function(tool, character) | ||
tool:Unsubscribe("Fire") | ||
end) | ||
|
||
-- Adds this tool to the Sandbox Spawn Menu | ||
AddSpawnMenuItem("NanosWorld", "tools", "TrailTool", "Trail", "assets///NanosWorld/Thumbnails/SK_Blaster.jpg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- Event when Client calls to spawn a Lamp | ||
Events:Subscribe("SpawnLamp", function(player, spawn_location, direction, entity, distance_trace_object) | ||
local rotation = direction:Rotation() + Rotator(-90, 0, 0) | ||
|
||
-- Spawns a Lamp Bulb prop | ||
local prop_lamp = Prop(spawn_location, Rotator(), "NanosWorld::SM_TeaPot_Interior") | ||
|
||
-- Sets the player to be the network authority immediately of this Prop | ||
prop_lamp:SetNetworkAuthority(player) | ||
|
||
-- Sets the prop mesh emissive color to a random color | ||
local color = Color(1, 0.6, 0.4) | ||
|
||
local prop_lamp_bulb = Prop(spawn_location, Rotator(), "NanosWorld::SM_Sphere", CollisionType.NoCollision, true, false) | ||
prop_lamp_bulb:AttachTo(prop_lamp) | ||
prop_lamp_bulb:SetScale(Vector(0.175, 0.175, 0.175)) | ||
prop_lamp_bulb:SetRelativeLocation(Vector(-1.5, 0, 17.5)) | ||
prop_lamp_bulb:SetMaterialColorParameter("Emissive", color * 50) | ||
prop_lamp:SetValue("Bulb", prop_lamp_bulb) | ||
|
||
-- Spawns a Point Light, with the color | ||
local intensity = 100 | ||
local light = Light(Vector(), Rotator(), color, LightType.Spot, intensity, 1000, 25, 0.975, 2000, false) | ||
|
||
-- Attaches the lamp to the prop, offseting 25 downwards | ||
light:AttachTo(prop_lamp) | ||
light:SetRelativeLocation(Vector(0, 0, 30)) | ||
light:SetRelativeRotation(Rotator(90, 0, 0)) | ||
|
||
-- If to attach to an entity, otherwise creates and attaches to a fixed invisible mesh | ||
if (entity) then | ||
prop_lamp:AttachTo(entity, AttachmentRule.KeepWorld) | ||
prop_lamp:SetGrabbable(false) | ||
end | ||
|
||
prop_lamp:SetValue("Light", light) | ||
prop_lamp:SetRotation(rotation) | ||
|
||
-- Calls the client to add it to his spawn history | ||
Events:CallRemote("SpawnedItem", player, {prop_lamp}) | ||
|
||
Particle(spawn_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst"):SetParameterColor("Color", color) | ||
end) | ||
|
||
-- Adds this tool to the Sandbox Spawn Menu | ||
AddSpawnMenuItem("NanosWorld", "tools", "LampTool", function() return SpawnGenericToolGun(Vector(), Rotator(), Color.YELLOW) end) |
Oops, something went wrong.