PDA

View Full Version : COP Addon Reference Guide


Torax
04-20-2010, 04:41 AM
Note: Addons will be available in the next patch.

Addons are written in the LUA programming language. Language reference can be found at http://www.lua.org/manual/5.1/. View the included dps.lua for an example script.

All addons are placed in the main/addons directory. Addons are a constant work in progress, developers please post requests for additional events and functions.

Reloading scripts while in-game:

Enter /reloadlua into the chat


COP Events:

onLoaded()
Called automatically when your character first spawns


onChatMessage(channel, text, senderName)

Channels
zone = 0;
group = 1;
raid = 2;
guild = 3;
say = 4;
emote = 5;
whisper = 6;
toWhisper = 7;
lootMessage = 8;
status = 9;
officers = 10;
system = 11;
combat = 12;
error = 13;
guildSystem = 14;
world = 15;
combatStatus = 16;
trade = 17;


onEnterCombat()


onExitCombat()


onKilled()


WhoListEntry(playerName, level, zone, guildName, isAFK)


onExpChange(currentExp, requiredExp)


onDamageTaken(damageDone, playerName, againstName, hitType, damageType)
onDamageDone(damageDone, againstName, playerName, hitType, damageType)
onHealingTaken(damageDone, playerName, againstName, hitType, damageType)
onHealingDone(damageDone, againstName, playerName, hitType, damageType)

Hit Types
miss = 0;
dodge = 1;
parry = 2;
block = 3;
resist = 4;
absorb = 5;
immune = 6;
dot = 20;
hit = 21;
crit = 22;
shared = 23;
neutral = 24;

damageType is the name of the damage/spell (swing, initiate heal, fireball, etc)


onExpGained(exp)


onInteractionStarted(time, barText, currentDuration)
barText is the caption displayed on the casting bar
time is the total time of interaction / cast
currentDuration is how much time has already elapsed


onEffectAdded(effectName, secondsRemaining)


onTargetSelected(targetname)


onTargetDeselected()


onGroupInvite(fromName)


onGroupJoin()


onGroupLeave()


LUA functions:

status("status text")

chatSay("message to send to say channel")

chatGuild("message to send to guild channel")

chatGroup("message to send to group channel")

chatWorld("message to send to world channel")

chatTrade("message to send to trade channel")


sendChatText("text")
Sends text to the current channel.
Example:
sendChatText("Hello") -- Sends "Hello" to the current channel
sendChatText("/dance") -- Starts dancing


cast("spell name")

Example:
cast("Blessing from Above")


addChatCommand("chat command")

Registers a chat command. When the chat command is used by the player, a function called chatcmd_[function] is called.

Example:
addChatCommand("testcommand")
function chatcmd_testcommand(args)

now doing /testcommand in game will execute the chatcmd_testcommand function. Any text added after the command will be passed as the first argument to the function.


playerInfo("type")

Returns information about the current player. Valid types:
name
level
isGrouped - returns "1" or "0" if the player is grouped
currentHealth
maxHealth


setTarget("target name")
Leave target name blank ("") to target self


checkSelfEffect("effect name")
checkTargetEffect("effect name")

Returns "1" if the effect exists on target, "0" if not


schedule("function", time in ms, args ...)

Example:
Cast Aegis after 1.5 seconds: schedule("cast", 1500, "aegis")


targetName() -- Returns the name of the current target

User Interface
GUI files should be placed inside the main/addons/ui folder.

Refer to the documents at http://docs.torquepowered.com/tge/official/index.html?content/documentation/Artists/GUI/Overview.html for help on creating a GUI.

You can download the free T3D demo at http://www.torquepowered.com/products/download/385 which has a built in GUI editor.


showDialog("dialog name")
hideDialog("dialog name")

Shows/hides a UI dialog. Dialog name is specified as the name of the first control inside the .gui file you want to show.
Example:
Inside your GUI file:
new GuiControl(MyAddonGui) {
Can be displayed by:
showDialog("MyAddonGui")

Common UIs:
GuiCTF - Capture the flag GUI
CharacterGui - Character stats/equipment GUI
GuildGui - Guild GUI
spellBookWindow - Spell Book GUI



setUiProperty("control", "field", "value")

Sets a field on a UI control to the specified value.
Example:
setUiProperty("myGuiButton", "text", "Click Me!")
will set the text field of button called myGuiButton to "Click Me!"


Calling LUA script functions from your GUI:
lua_event("FunctionName", args ...);

Example:
Button command: lua_event("DoSomething", "100", "player");
LUA: function DoSomething(myarg1, myarg2)

monaro
04-20-2010, 06:48 AM
Very nice, now, just need to make a macro center so people can create macros (for chat or spell purposes) and add them to the battlebars!

Recount for CoP FTW!

yneos
04-20-2010, 09:45 AM
sounds awsome. but now it looks like i may have to read up on how to write this language xD

mrxafiar
04-20-2010, 10:20 AM
w00t!! these are great news!! w00t!

Vigor
04-20-2010, 01:11 PM
Very nice, now, just need to make a macro center so people can create macros (for chat or spell purposes) and add them to the battlebars!

Recount for CoP FTW!

Lets not forget the ability to use hotkeys for not only whats on the battlebar.. but for things on the sidebar.

Note: I've been setup like this for a few days now, on my sidebar i have 4 spells that would normally be on my battlebar.. ie: lifespike, acid blast, immolate, death sentence... which then can be used by typing R for lifespike, F for acidblast, C for immolate, V for Death Sentence. This has completely freed up my right hand for nothing other then moving and its quite awesome despite the fact that i'm trying to learn a new BB setup.. but who says you can't teach an old dog new tricks!

While i have it done, its quite tricky and couldn't of done it alone, i'd like to see it more of a streamlined thing that was more user friendly. Thanks again to the guy who helped me!

Glad to see the game is headed in this direction.. customization is a beautiful thing.

Edit: Now all i need is a way to enable/disable the tabbing of pets and all of the -control- issues i have with this game are gone.

Ryuzaki
04-20-2010, 03:29 PM
DS is gonna get a boner when he gets online.

DeathStalker908
04-20-2010, 08:27 PM
DS is gonna get a boner when he gets online.

Lmfao...yeah I just had 1


Well, first of all wb Torax..it's nice to see you back here again.

Second of all, fml, 'cause I was already creating an addon of my own in Torquescript..and I think this resource will make things alot more simple lol


Third of all..I think I'll be busy recoding addons in .lua and selling to every1 for 1k pts ahahaha....

http://s396.photobucket.com/albums/pp50/Deathstalker908/?action=view&current=UpdatedAddon.jpg

DeathStalker908
04-20-2010, 08:31 PM
sounds awsome. but now it looks like i may have to read up on how to write this language xD

There is no need to fear, the coding master is here!

*points to self*

monaro
04-20-2010, 10:55 PM
Well, at least i know how you can tell everyones HP without hacking into the /stat mod command lol.

DeathStalker908
04-20-2010, 11:46 PM
Well, at least i know how you can tell everyones HP without hacking into the /stat mod command lol.

How?




@ Torax

Is there a way to integrate .lua and torquescript together? I think it would be great if it were possible to access my current addon by typing a command into the chat, rather than the method I'm using now, which can be..a bit harmful. This is my request..I can addons done alot more quickly for everyone if this were possible

Torax
04-21-2010, 02:46 AM
We have no plans for supporting TorqueScript at this time for addons. It should be much easier to develop addons with LUA.

You will be able to add chat commands easily, refer to the addChatCommand function in the reference.

spiker8420
04-21-2010, 07:33 AM
I dont know shit about scripts and tech language so someone want to explain exactly what this will do for cop?

Crow
04-21-2010, 08:10 AM
Its opportunity for poeple who are interested to help develop some more advanced things in cop

KingApocalypse
04-21-2010, 02:28 PM
which bad ass ****sucker mod deleted my comment?

i just asked Torax to check the 10 cc thread....dont act fcking like there arent problems

danzaiverx
04-21-2010, 03:40 PM
which bad ass ****sucker mod deleted my comment?

i just asked Torax to check the 10 cc thread....dont act fcking like there arent problems

Theres lots of ****sucker mod's out there KingApoc alot actually one of many reason's so many player's have quit this game or taking 6 month breaks cause of it and call the game"Corrupted" which i believe is 100% true i hope Torax is gonna be back and will totally change the way CoP is cause i used to enjoy it and i know it's a fun game.

KingApocalypse
04-21-2010, 05:09 PM
Theres lots of ****sucker mod's out there KingApoc alot actually one of many reason's so many player's have quit this game or taking 6 month breaks cause of it and call the game"Corrupted" which i believe is 100% true i hope Torax is gonna be back and will totally change the way CoP is cause i used to enjoy it and i know it's a fun game.

I hope so also mate....I miss the old modless days!

DeathStalker908
04-21-2010, 06:57 PM
We have no plans for supporting TorqueScript at this time for addons. It should be much easier to develop addons with LUA.

You will be able to add chat commands easily, refer to the addChatCommand function in the reference.

ooo you added the .gui part to your post..that's exactly what I wanted/needed. Thanks! :D

Paladin016
04-22-2010, 02:47 PM
i was creating an addon too :/ ds helped me :P

DeathStalker908
04-22-2010, 06:59 PM
i was creating an addon too :/ ds helped me :P

You mean you changed 1 button of my addon even after I told you not to screw around with it? ...

tripp
04-22-2010, 07:20 PM
You mean you changed 1 button of my addon even after I told you not to screw around with it? ...

rofl.. ds you must school me in the art of addons :D

pimpa
05-01-2010, 08:06 PM
Is there some way so that when you join a group you can retrieve all the group member names?

My idea was so that when you join a group it gets the group members names and classes(green/white for example) so then it would run through each group member and check for a certain buff like before a boss and if a buff is missing such as oak skin then it would send a message to the chat and say whos missing the buff and who can cast it.

If not i dont really care i just was looking through the guide you made at the start of the post and had a few ideas based on another game i play lol...

Billy.

yneos
05-23-2010, 03:58 PM
is the Lua thing out? i was looking in the main/ addon but there is no addon part there o.0

spiker8420
05-23-2010, 04:43 PM
Yea its out, but how do u apply the scripts to the actual game. Theres not addons folder...

Crow
05-24-2010, 01:07 AM
Make folder?

monaro
06-04-2010, 05:35 AM
Excellent job with the addon patch guys, looking forward to see what addons peope come up with.

Btw, DS said to spread the word, Helth addon comes out tomorrow!

bobsapp1
06-14-2010, 12:18 PM
onDamageTaken(damageDone, playerName, againstName, hitType, damageType)
onDamageDone(damageDone, againstName, playerName, hitType, damageType)
onHealingTaken(damageDone, playerName, againstName, hitType, damageType)
onHealingDone(damageDone, againstName, playerName, hitType, damageType)

Hit Types
miss = 0;
dodge = 1;
parry = 2;
block = 3;
resist = 4;
absorb = 5;
immune = 6;
dot = 20;
hit = 21;
crit = 22;
shared = 23;
neutral = 24;

damageType is the name of the damage/spell (swing, initiate heal, fireball, etc)




lier =)

(damageDone, attackerName, defenderName, hitType, damageType)and
(damageDone, defenderName, attackerName, hitType, damageType) is the corect syntax, if u use what is writen in the reference guide the player name and against name wil not work -_-

YES THIS CAUSED ALOT OF HOURS FOR ME TO FIGURE OUT WHY WASNT WORKIN SO IM KINDA PISSED :P you should update it so other ppl dont have to suffer like me =)

Crow
07-21-2010, 01:48 PM
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "1";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "1 1";
Extent = "40 40";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
noMouse = "0";
Command = lua_event("myFunction");
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
bitmap = ".somePicture";
};

Command = lua_event("myFunction"); doesnt work it wont call function

Part from mine lua script where function is:

function myFunction()
status("its working");
end

I was trying whole 1h and i cant figure out whats going on there.
Maybe i am doing something wrong i dont know, if anyone see wheres problem please help :eek::eek::eek:.
Thanks in advance
Nevermind i found a way to bypass this.

yneos
02-16-2011, 11:47 AM
ive got a problem with the

checkSelfEffect("Force of Flames")

right now im trying to make it see if FOF is on, and if its not on to cast it.
what ive tried

buff == CheckSelfEffect("Force of Flames")
if buff = 1 then
Status("FOF is on")
else
cast("Force of Flames")
end

ive tried

if CheckSelfEffect("Force of Flames") == 1 then
Status("FOF is on")
else
cast("Force of Flames")
end

ive tried

if function CheckSelfEffect("Force of Flames") == 1 then
Status("FOF is on")
else
cast("Force of Flames")
end

ive tried

if function(CheckSelfEffect("Force of Flames")) == 1 then
Status("FOF is on")
else
cast("Force of Flames")
end

and one last question does anyone else have retarded experiences with the
addChatCommand("fof");
function chatcmd_fof()
i swear sometimes it works and some times it doesn't. i can change one thing and it will make it no longer work.

and the one were i used
buff == CheckSelfEffect("Force of Flames")
if buff = 1 then

ive gotten an error '=' expected near 'buff' and a real weird one '=' expected near '=='

Crow
02-17-2011, 04:38 AM
Try this:

addChatCommand("fof")
function chatcmd_fof()
status("Checking effect")
SeeIfThereIsFOF= checkSelfEffect("force of flames")
if SeeIfThereIsFOF== "0" then
status("FOF doesnt exist")
else
status("FOF exist")
end
end

yneos
02-17-2011, 01:11 PM
that worked, what i had wrong was a stupid problem :/

i had buff=checkself effect

function chatcmd_fof()

then the IF statement and i geuss the buff=checkselfeffect needed to be after the function :/ my bad lol

Crow
02-17-2011, 01:39 PM
its inside functuin, if you put it out of function it wont be called when function is called, it will be executed just once when lua script is loaded, not when u type /fof.:D

yneos
02-17-2011, 10:04 PM
hmm just messing around some, im trying the
schedule("function", time in ms, args ...)

ok i get it to work, but as of now im trying it as
schedule("status" ,1000, test)

and it goes though the code and does
test
test
test
.etc it does it 13x

also what i noticed is if you have a few of them in your code it actually lags your game, right now i have 4 in one of my codes and it lags my game for 2-3sec.

blackfang
04-29-2011, 04:40 AM
playerInfo("type")

Returns information about the current player. Valid types:
name
level
isGrouped - returns "1" or "0" if the player is grouped
currentHealth
maxHealth



Is there any way to recieve the statistics information from a player?
Like, theyr intellect and stamina

yneos
04-30-2011, 02:55 PM
not with the options they give us.

Nastythyng
04-30-2011, 06:08 PM
not with the options they give us.

just have a mod make the addon, and get their login ;)