Nomi rep?

90 Night Elf Hunter
11270
Hey guys. I need some help figuring out my current rep with Nomi of the Tillers. His friendship is not on the rep list. What's more, you can only see your current level if you've already done his quest that day. I had a bug where I did not get credit properly, and I had to get a GM to fix it. Now, I'm coming up on the same problem, and I want to track it as I give it.

I KNOW there's got to be a script I can plug in to return the current rep level. Unfortunately, I'm not well versed in script writing enough to get it right. I'm thinking it's somewhere along the lines of GetFactionInfo(), but I can't figure out the correct syntax to get a script to work.

Any help would be greatly appreciated! I can't be the only one interested in this.

Thanks,

Kahless
Reply Quote
100 Dwarf Mage
11375
/run local _, fR, fM, fN, _, _, _, fT, nT = GetFriendshipReputation(1357) print(("Your current reputation with %s is %d/%d. The previous threshold was at %d and the next one is at %d."):format(fN, fR, fM, fT, nT))

Expanded for clarity:local friendID, friendRep, friendMaxRep, friendName, friendText, friendTexture, friendTextLevel, friendThreshold, nextFriendThreshold = GetFriendshipReputation(1357)

print(("Your current reputation with %s is %d/%d. The previous threshold was at %d and the next one is at %d."):format(friendName, friendRep, friendMaxRep, friendThreshold, nextFriendThreshold))


Edit: Forgot a [code] tag.
Edited by Choonster on 1/11/2013 6:14 PM PST
Reply Quote
90 Night Elf Hunter
11270
Thank you. This was fantastic.

Now, if only someone would teach me what it all means...
Reply Quote
100 Dwarf Mage
11375
Thank you. This was fantastic.

Now, if only someone would teach me what it all means...

The first line creates a bunch of local variables and assigns them to the values returned by the GetFriendshipReputation function (which we call with Nomi's factionID as the first and only argument).

The second line uses the string.format function (called here as a method of a string) to replace the placeholder tokens (%s, %d) in a string with the values of some of the variables we created above. The tokens are replaced from left to right with the corresponding arguments (the first token uses the first argument, the second token uses the second argument, etc.).

After the string has been formatted with the data from GetFriendshipReputation, it's passed as the first and only argument to the print function (which writes all of its arguments to the chat frame).

The abbreviated macro version uses underscores for the names of the variables we don't care about to save space (this is common practice when a function returns more values than you need).
Edited by Choonster on 1/11/2013 10:24 PM PST
Reply Quote
90 Night Elf Hunter
11270
Gonna have to study this for a while...
Reply Quote
100 Dwarf Mage
11375
If you want to learn more about Lua, there are a few resources available.

Programming in Lua is an online book targeted at programmers learning Lua and was written for Lua 5.0 (not 5.1 like WoW uses), but you may still find it useful:
http://www.lua.org/pil/

You can also purchase the second edition, which was written for 5.1.

There are some resources about learning Lua in general here:
http://lua-users.org/wiki/LearningLua

There's a tutorial on making AddOns here:
http://www.wowpedia.org/AddOn_programming_introduction

There's also a book targeted at people learning to write WoW AddOns you can purchase here:
http://wowprogramming.com/

I haven't bought the book myself, but I've heard that it's quite good.

If you have any questions, feel free to ask them here.
Edited by Choonster on 1/12/2013 6:08 PM PST
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]