link.mac (Item Link Storage)

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

link.mac (Item Link Storage)

Post by kagonis » Mon Oct 06, 2003 1:59 pm

This is the revamped code for link.mac.
It's untested, but it should work :)

*** PLEASE NOTE ***
This macro is not for generating links, it is to store existing links for later.
So you cannot use this script to generate a link of some obscure item, merely by knowing either name or id of said item.
What you can use this script for, is if you see a really cool link, that you want to be able to look at anytime, without having to ask a person for a link. You just store the link with this macro, and when you then later wants to view it, or show someone else the link, you just pull it out again with this macro.

The syntax is rather simple (and also explained within the macro, simply by typing "/macro link"):

Syntax: /macro link <add|edit|list> ["link"|key] ["link"]
Example: /macro link add "Some Item Link"
Example: /macro link edit 5 "Some Item Link"
Example: /macro link list

Step by step example to store a link is:
1. Open the link so you have the link window, with the link you wish to store open.
2. Type: /macro link add " do NOT press enter yet.
3. Click the item graphics in the link window, to paste a link to the area where you have allready typed the beginning of the command.
4. Now you should have a line looking something like this:
/macro link add "Some Item Link
5. End the line with another quote "
6. Your line should now look something like this:
/macro link add "Some Item Link"
7. Press enter to save the link.

Now you just retrieve a list of all your stored links by typing /macro link list


Edit:
Fixed the $defined parameter check, thanks Wishbringer :)
2003.10.15: Updated and tested.

Code: Select all

#turbo
#define INIPATH "d:\games\mq\ini\links.ini"
Sub Main
	/if "@Param0"=="add" {
		/if "$defined(Param1)"=="FALSE" /call Syntax
		/call ListKeys empty
		/if n $return==0 {
			/echo No empty keys were found.
			/endmacro
		}
		/ini "INIPATH" "Links" "$int($return)" "- @Param1 -"
		/echo Added: Key: $return - Value: @Param1
	} else /if "@Param0"=="edit" {
		/if n $strlen("@Param1")>3 /call Syntax
		/if "$defined(Param2)"=="FALSE" /call Syntax
		/ini "INIPATH" "Links" "$int(@Param1)" "- @Param2 -"
		/echo Updated: Key: @Param1 - Value: @Param2
	} else /if "@Param0"=="list" {
		/call ListKeys echo
	} else {
		/call Syntax
	}
/return

Sub ListKeys
	/if "@Param0"!="echo" /if "@Param0"!="empty" {
		/echo Syntax: /call ListKeys <echo|empty>
		/endmacro
	}
	/declare l0 local
	/varset l0 0
	:Loop
		/varadd l0 1
		/if "@Param0"=="echo" /if n $strlen("$ini("INIPATH","Links","$int(@l0)")")>8 /echo Key: $int(@l0) // $ini("INIPATH","Links","$int(@l0)")
		/if "@Param0"=="empty" /if n $strlen("$ini("INIPATH","Links","$int(@l0)")")==8 /return $int(@l0)
	/if n @l0<100 /goto :Loop
/return 0

Sub Syntax
		/echo Syntax: /macro link <add|edit|list> ["link"|key] ["link"]
		/echo Example: /macro link add "Some Item Link"
		/echo Example: /macro link edit 5 "Some Item Link"
		/echo Example: /macro link list
		/endmacro
/return
Last edited by kagonis on Wed Oct 15, 2003 2:18 pm, edited 4 times in total.

Wishbringer
Contributing Member
Contributing Member
Posts: 230
Joined: Thu Nov 14, 2002 7:00 am

Post by Wishbringer » Thu Oct 09, 2003 5:26 am

Code: Select all

/if !$defined(@Param1) /call Syntax
Should be

Code: Select all

/if !$defined(Param1) /call Syntax
same for Param2!

else it would be parsed as
if Param1 is not declared: /if !$defined("") /call Syntax
if Param1 is "add": /if !$defined(add) /call Syntax

@Param1 refers to content of var.

Milten
a hill giant
a hill giant
Posts: 176
Joined: Thu Oct 09, 2003 11:40 am

Post by Milten » Fri Oct 10, 2003 7:40 am

next to tradeskills, this is like the best idea I've seen so far.. would just be awesome, if you could spew out links.. could you give some info on handling? just by looking at the code I'm a tidbit confused :)

Edit:

I understood exactly what it was for.. of course I'll have to collect the links first, but at least I can link this and that to anyone that wants, on request.. thats what I meant for spewing out links :) thanks a ton for the "manual" to it :)

Ecchi_User
orc pawn
orc pawn
Posts: 18
Joined: Fri Aug 30, 2002 6:34 am

Nothing

Post by Ecchi_User » Wed Oct 15, 2003 12:20 am

Since last patch...

I noticed the date of this macro been last edited on the 10th, the day after the last break went live. Does this still work?

I have a working recompiled MQ running, but nothing is happening when I run this.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Wed Oct 15, 2003 2:25 pm

The above version works for sure, just make sure to change the INIPATH to where you are storing your file.

Ecchi_User
orc pawn
orc pawn
Posts: 18
Joined: Fri Aug 30, 2002 6:34 am

I missing something...

Post by Ecchi_User » Thu Oct 16, 2003 7:03 pm

Hmmm....

Just to make sure... I recompiled MQ using the latest "IRC-latest.zip", cut and pasted the updated link.mac above.

Deleted my old links.ini file. Paths are correct. Anything I type just shows the default syntax.

I tried adding a new link... shows the 'Syntax Help'. Tried edit and list as well... even tho there is no links.ini file, shows the same 'Syntax Help'

Ecchi_User
orc pawn
orc pawn
Posts: 18
Joined: Fri Aug 30, 2002 6:34 am

All good!

Post by Ecchi_User » Thu Oct 16, 2003 7:10 pm

Hehe....

Figures. My cut and paste chop'd 2 lines up in the code.

Of corse, it was on the 2 long lines, right at the /echo and /return part so it looked like it was a new command.

But it's working now. Thanks!

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Sun Nov 02, 2003 6:29 pm

Anyone having problems using this? i cant get it to work with my newest compiled CVS. deleted old ini, defined path still no go

wondering if its just me

Yalp

Guest

Post by Guest » Sat Nov 29, 2003 11:41 pm

Same Problem Here... /macro links add works, but not /macro links list

Sixes
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Nov 06, 2003 6:21 pm

Post by Sixes » Sun Nov 30, 2003 7:31 am

There appears to be a problem in the latest build with defining the name of a .ini file and then calling $ini(). If you substitute the "INIPATH" with the name of the file, it works.

Crun
orc pawn
orc pawn
Posts: 12
Joined: Wed Dec 03, 2003 12:16 am

Post by Crun » Wed Dec 03, 2003 4:49 am

wouldn't there be a way to populate the ini file from magello? Might be a bit time consuming if it had to be done manually..... would be cool though =)

Crun

fishez
orc pawn
orc pawn
Posts: 19
Joined: Tue Dec 09, 2003 3:42 pm

Post by fishez » Mon Jan 26, 2004 10:03 am

So all that is getting save is the name of the link, not actual information from the link? I do a link add "link" and if saves it to the ini file and displays in the MQ window. However, that is all I can see, just the name link. If I click on the link in the MQ window I do not get the link popup window like pops up when left clicking on a normal link.

Is that the proper way for this to respond? Or is the normal windows with the item information supposed to pop up also?

This is an important point to me because it may assist me in a project idea I am considering.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Jan 26, 2004 10:07 am

Use autolink.mac. The reason you aren't able to click the link in your mq2chatwnd is because item links appear to be broken right now. In autolink.mac I redirect to communication channels and it works fine.

fishez
orc pawn
orc pawn
Posts: 19
Joined: Tue Dec 09, 2003 3:42 pm

Post by fishez » Mon Jan 26, 2004 10:13 am

Ah Thanks had missed that mac somehow.