Team Spartan Cookies & Milk Forums
LocInt's SF Help & Request Thread - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: LocInt's SF Help & Request Thread (/thread-627.html)

Pages: 1 2


LocInt's SF Help & Request Thread - LocInt - 11-12-2014

Hello,

Im kind of bored and I want something do. I can simply help you with your script or write it for you.

There is certain restrictions:

-The script you're requesting is something cool.
-You post the whole function and all functions related to the function you have issue with.
-I do only screens and processors.


RE: LocInt's SF Help & Request Thread - Wirebuilder28 - 11-12-2014

hi loc,you asked me to post that (need help), THX! Big Grin
--@name Shuttle AI
--@author wirebuilder28
--@sharedscreen
--@model models/madman07/supergate_dhd/supergate_dhd.mdl

local Owner = ents.owner()
wire = loadLibrary("wire")
ents = loadLibrary("ents")
find = loadLibrary("find")
Red=Color(200, 57, 43, 255)
Green=Color(46, 204, 113, 255)
Blue=Color(41, 128, 185, 255)
White=Color(236, 240, 241, 255)
wire.createInputs( { "Shuttle" } , { "wirelink" } )

function transwarpdestination(target,pos)
if target and pos != Vector( 0,0,0 ) then
wire.ports.Shuttle["Transwarp Destination"] = pos+Vector( 0,0,500 )
wire.ports.Shuttle["Transwarp"]=1
printColor(Blue,"[TransWarp] ",White,"to",Red," "..target:name())
end
--if target:isPlayer() then
-- printColor(Green,"[Shuttle]",Blue," Transwarping to "..target:name())
-- end
end
function runCommand( t )
if t[1] =="/taxi" then
if find.playerByName( t[2] ) then
local target = find.playerByName( t[2] )
transwarpdestination(target:pos())
end
end
end


function Chat( msg, ply )
local t = {}
for i in string.gmatch(msg, "%S+") do --converting the message string into a table.
table.insert(t,i)
end
runCommand( t ) --send the command to do stuff.
end
chat.listen( Chat, ents.owner() )
--time.timer("chat",0.5,0,parseChat)


RE: LocInt's SF Help & Request Thread - LocInt - 11-12-2014

(11-12-2014, 06:13 PM)Wirebuilder28 Wrote: hi loc,you asked me to post that (need help), THX! Big Grin
--@name Shuttle AI
--@author wirebuilder28
--@sharedscreen
--@model models/madman07/supergate_dhd/supergate_dhd.mdl

local Owner = ents.owner()
wire = loadLibrary("wire")
ents = loadLibrary("ents")
find = loadLibrary("find")
Red=Color(200, 57, 43, 255)
Green=Color(46, 204, 113, 255)
Blue=Color(41, 128, 185, 255)
White=Color(236, 240, 241, 255)
wire.createInputs( { "Shuttle" } , { "wirelink" } )

function transwarpdestination(target,pos)
if target and pos != Vector( 0,0,0 ) then
wire.ports.Shuttle["Transwarp Destination"] = pos+Vector( 0,0,500 )
wire.ports.Shuttle["Transwarp"]=1
printColor(Blue,"[TransWarp] ",White,"to",Red," "..target:name())
end
--if target:isPlayer() then
-- printColor(Green,"[Shuttle]",Blue," Transwarping to "..target:name())
-- end
end
function runCommand( t )
if t[1] =="/taxi" then
if find.playerByName( t[2] ) then
local target = find.playerByName( t[2] )
transwarpdestination(target:pos())
end
end
end


function Chat( msg, ply )
local t = {}
for i in string.gmatch(msg, "%S+") do --converting the message string into a table.
table.insert(t,i)
end
runCommand( t ) --send the command to do stuff.
end
chat.listen( Chat, ents.owner() )
--time.timer("chat",0.5,0,parseChat)
Code:
--@name Shuttle AI --@author wirebuilder28 --@sharedscreen --@model models/madman07/supergate_dhd/supergate_dhd.mdl local Owner = ents.owner() wire = loadLibrary("wire") ents = loadLibrary("ents") find = loadLibrary("find") Red=Color(200, 57, 43, 255) Green=Color(46, 204, 113, 255) Blue=Color(41, 128, 185, 255) White=Color(236, 240, 241, 255) Shuttles = find.byClass( "st_shuttle_type11", function( Ent ) return Ent:owner() == ents.owner() end ) Shuttle = Shuttles[1]:getWirelink() function IsValid( Ent ) return Ent and Ent.isValid and Ent:isValid() end function transwarpdestination(Target,Pos) if (IsValid(Target) and IsValid(Shuttle) and Pos!= Vector( 0,0,0 )) then Shuttle["Transwarp Destination"] = Pos+Vector( 0,0,500 ) Shuttle["Transwarp"]=1 printColor(Blue,"[TransWarp] ",White,"to",Red," "..Target:name()) time.timer( "transWarp", 10, 1, function() Shuttle["Transwarp"]=0 end ) end --if target:isPlayer() then -- printColor(Green,"[Shuttle]",Blue," Transwarping to "..target:name()) -- end end function runCommand( t ) if (t[1] =="/taxi") then if(t[2] != nil) then local Target = find.playerByName( t[2] ) if(IsValid(Target)) then local TPos=Target:pos() time.timer( "transWarp", 1, 1, function() transwarpdestination(Target,TPos) end ) end end end end function Chat( msg, ply ) local t = {} for i in string.gmatch(msg, "%S+") do --converting the message string into a table. table.insert(t,i) end runCommand( t ) --send the command to do stuff. end chat.listen( Chat, ents.owner() ) --time.timer("chat",0.5,0,parseChat)

Here you go.


RE: LocInt's SF Help & Request Thread - Person8880 - 11-12-2014

I'd like to point out that the loadLibrary code you have is entirely pointless. What it's doing is essentially:

wire = wire
ents = ents
find = find

All libraries are in the global table already, loadLibrary should be avoided as it's useless, deprecated and will eventually be removed.

Also, for Starfall code on the forums, use the lua tags rather than the code tags as it formats nicely.


RE: LocInt's SF Help & Request Thread - LocInt - 11-12-2014

(11-12-2014, 07:21 PM)Person8880 Wrote: I'd like to point out that the loadLibrary code you have is entirely pointless. What it's doing is essentially:

wire = wire
ents = ents
find = find

All libraries are in the global table already, loadLibrary should be avoided as it's useless, deprecated and will eventually be removed.

Also, for Starfall code on the forums, use the lua tags rather than the code tags as it formats nicely.

I bet you know as a coder how hard is it to let go of coding habits. 8D


RE: LocInt's SF Help & Request Thread - Person8880 - 11-12-2014

Sure, but for wirebuilder as a new coder to Starfall, it's better for him not to learn the old, bad habits. Tongue


RE: LocInt's SF Help & Request Thread - LocInt - 11-12-2014

(11-12-2014, 07:40 PM)Person8880 Wrote: Sure, but for wirebuilder as a new coder to Starfall, it's better for him not to learn the old, bad habits. Tongue

Agreed. Im pretty sure the old habits came from me to T-16 and then to everyone else. Blush


RE: LocInt's SF Help & Request Thread - TheOneAndOnlyTee - 11-12-2014

yeah i may have passed that on but still Wirebuilder great progress


RE: LocInt's SF Help & Request Thread - Blackhawk - 11-12-2014

Also this isn't lua syntax:
if target and pos != Vector( 0,0,0 ) then ... end
Use "~=" instead of "!=". The correct syntax is:
if target and pos ~= Vector( 0,0,0 ) then ... end



RE: LocInt's SF Help & Request Thread - LocInt - 11-12-2014

(11-12-2014, 11:28 PM)_BL4CKH4WK Wrote: Also this isn't lua syntax:
if target and pos != Vector( 0,0,0 ) then ... end
Use "~=" instead of "!=". The correct syntax is:
if target and pos ~= Vector( 0,0,0 ) then ... end

I know that was for wire but my opinion:

I don't really care if its deprecated to use "!=" because this is not real lua we write here. If person would rename all functions like in lua and add those useful lua functions which person call "cheaty" then I would start to write correct lua.