Thread Tools Display Modes
10-03-08, 05:50 AM   #1
icaruscollapse
A Defias Bandit
Join Date: Oct 2008
Posts: 2
Noob Needs Help With Slash Commands

So forgive me for being a complete and total noob at this, but I can't figure this out for the life of me.

My guild is working on a new DKP system that is based on a natural log scale, so the more DKP you have, the less DKP you earn. In trying to find numbers that work to assign for how much a boss kill is worth, how much items are worth to purchase, I wanted to create a simple mod (My first, surprise surprise) that just lived in the chat window, where you would type /dkpformula X or /dkpf X and it would output how much your X is worth when the player has 0, 50, 100, 250, 500, and 750 DKP, using the formula we have decided to use.

The formula isn't the issue. I can't get the damn slash command to work at all, and I feel so dumb that that is where I'm getting hung up on this whole thing.

I hope someone with a kind heart could look this over and tell me what I'm doing wrong... (I can probably figure out other errors going forward if I could just get the slash command to work in the first place)

Code:
## Interface: 20400
## Title: DKP Formula
## Notes: by |cffff7d0aMailah
## Dependencies:
DKPFormula.lua
DKPFormula.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://www.blizzard.com/wow/ui/ 
 ..\..\FrameXML\UI.xsd">
	<Script file="DKPFormula.lua"/>
	<Frame name="DKPFormulaCore" frameStrata="LOW" enableMouse="false" hidden="false">
			<Scripts>
					<OnLoad>DKPFormula_OnLoad();</Onload>
			</Scripts>
	</Frame>
</Ui>
Code:
function DKPFormula_OnLoad()
	SlashCmdList["DKPFORMULA"] = DKPFormula_Command(var);
	SLASH_DKPFORMULA1 = "/dkpformula";
	SLASH_DKPFORMULA2 = "/dkpf";
	CONSTANT_E = 2.71828182845904523536;
	DKP_ZERO = 0;
	DKP_FIFTY = 0;
	DKP_ONE_HUNDRED = 0;
	DKP_TWO_FIFTY = 0;
	DKP_FIVE_HUNDRED = 0;
	DKP_SEVEN_FIFTY = 0;
end	

function DKPFormula_Command(var)
	DKP_ZERO = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-0)/1000)+var) / 300 ));
	DKP_FIFTY = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-50)/1000)+var) / 300 ));
	DKP_ONE_HUNDRED = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-100)/1000)+var) / 300 ));
	DKP_TWO_FIFTY = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-250)/1000)+var) / 300 ));
	DKP_FIVE_HUNDRED = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-500)/1000)+var) / 300 ));
	DKP_SEVEN_FIFTY = 1000 - (1000 * CONSTANT_E ^ ( -(-300 * math.log((1000-750)/1000)+var) / 300 ));
	DEFAULT_CHAT_FRAME:AddMessage("With an award of "..var.." base DKP, you would be awarding as follows:",1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 0 DKP: "..DKP_ZERO,1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 50 DKP: "..DKP_FIFTY,1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 100 DKP: "..DKP_ONE_HUNDRED,1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 250 DKP: "..DKP_TWO_FIFTY,1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 500 DKP: "..DKP_FIVE_HUNDRED,1,1,0);
	DEFAULT_CHAT_FRAME:AddMessage("To someone with 750 DKP: "..DKP_SEVEN_FIFTY,1,1,0);
end
I realize this is probably horribly organized and everything, but I don't care if it's not "efficient" or whatever, I just want it to work, or at least not give me the "Type /help for a list of commands" when I use the /dkpf or whatever... Any pointers would be MUCH appreciated.
  Reply With Quote
10-03-08, 07:23 AM   #2
slizen
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 15
I think this is what's causing it not to work
Code:
SlashCmdList["DKPFORMULA"] = DKPFormula_Command(var);
You need to specify a function that will be called when you type the slash command, instead of assigning SlashCmdList["DKPFORMULA"] with whatever value DKPFormula_Command returns when called with the var arg.

It should look like this instead:
Code:
SlashCmdList["DKPFORMULA"] = DKPFormula_Command;
  Reply With Quote
10-03-08, 12:01 PM   #3
icaruscollapse
A Defias Bandit
Join Date: Oct 2008
Posts: 2
Still nothing, with that change. Any other ideas?
  Reply With Quote
10-03-08, 01:19 PM   #4
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
The oddity I noticed is calling the LUA file in the TOC and then again from the XML, which is pushing a 2nd load of the file...which may or may not be doing something to mess it up (ie. overwriting existing global slashes, etc).

If you're calling the LUA in the XML, you only need to load the XML from the TOC, IIRC. I don't ever tinker with XML, I load all my frames locally from within the LUA.

Also, the defined values you declaring in your OnLoad (ie. DKP_ZERO), why not just declare them as locals in your LUA? Same effect without having to declare their load values because every time DKPFormula_Command fires, it will reset the value based on the calculation.

You should check to ensure it's loading a well. Before you do anything in DKPFormula_OnLoad, push a message into the DEFAULT_CHAT_FRAME to ensure it's loading properly. This might prove valuable in troubleshooting the right problem (ie. might not be the slash commands because it's not loading properly).
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Noob Needs Help With Slash Commands


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off