Making userfunction...

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Making userfunction...

#1 Post by botje » Wed Aug 17, 2011 12:32 pm

Code: Select all

function CleanBag(sellprize)
	for i, item in pairs(inventory.BagSlot) do
		if item.SlotNumber >= settings.profile.options.INV_AUTOSELL_FROMSLOT and
			settings.profile.options.INV_AUTOSELL_TOSLOT >= item.SlotNumber then
			if (item:isType("weapons") or item:isType("armor")) and sellprize > item.Worth then
				printf("Deleting Item:  "..item.Name.."\n");
				item:delete()
			end
		end
	end
end
Trying to make a userfunction to clean my bags, but it doesnt work at ll, no errors though.

also would llike to drop on color...

Botje

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Making userfunction...

#2 Post by lisa » Wed Aug 17, 2011 9:02 pm

at first glance I don't see why it wouldn't work, when and how do you call the userfunction?
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Making userfunction...

#3 Post by rock5 » Thu Aug 18, 2011 12:30 am

I see a problem with the line I think I gave you. I'm notorious for not double checking my code as Lisa knows. :)

"weapons" and "armor" should be "Weapons" and "Armor". Sorry.

Code: Select all

         if (item:isType("Weapons") or item:isType("Armor")) and sellprize > item.Worth then
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Making userfunction...

#4 Post by lisa » Thu Aug 18, 2011 4:33 am

I guess we could add in a string.lower so caps or no caps would make no difference.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Making userfunction...

#5 Post by botje » Thu Aug 18, 2011 4:52 am

oh nice, gonna test that ^^

and how are things like chains rings etc called?

i cant seem to find anything related to those in the item file O.o

Botje

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Making userfunction...

#6 Post by rock5 » Thu Aug 18, 2011 5:09 am

What do you mean by "chains rings"? Do you mean, how to identify if the item is an Accessory? You can use

Code: Select all

item:isType("Accessories")
BUT accessories are a sub type of armor so checking for "Armor" will include accessories.

You can find all the "types" in the file itemtypestable.lua in the cache folder.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Making userfunction...

#7 Post by botje » Thu Aug 18, 2011 7:21 am

oh i see, so armor will work regardless, nice :)

so thats where that info is, and here i was looking at items file all the time xd

Botje

Hexacore
Posts: 3
Joined: Fri Jun 17, 2011 9:04 am

Re: Making userfunction...

#8 Post by Hexacore » Mon Aug 22, 2011 9:23 am

lootomatic is a gread addon so you dont have to mess with scripting :P just record items and drop them ;) i use it for KS

btw i have a noob question about userfunctions :P

if you write a function like function DoSomething()
...................
end

can i call the function by name like <waypoint>DoSomething()</waypoint>
and another noob question what programming language does micromacro understands and what one is used for .lua and .xml files

ty (didnt want to start another thread)

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Making userfunction...

#9 Post by botje » Mon Aug 22, 2011 9:35 am

but i use a lootfilter too, thats not the point, now i can set what stuff to drop.

more control :)

Botje

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Making userfunction...

#10 Post by rock5 » Mon Aug 22, 2011 9:51 am

Both the game and lua files use the .lua language. Micromacro is for executing lua scripts like the rombot. .xml files have xml code in them and are basically just a way to store information using tags. It can have lua in between the xml tags. The lua reference can be found here.
http://www.lua.org/manual/5.1/

If you create a function it needs to be put somewhere so that it gets loaded and becomes available for you to use like you said
<waypoint>DoSomething()</waypoint>
You can put functions in a number of places.

If you want to make a function that you will use in many scripts, you can place it in the "userfunctions.lua" file(you will have to create it if it doesn't already exist).

If you want to create a function that you will share, you can create a file for it in the "userfunctions" folder. The name of the file should be prefixed with "userfunction_", eg. "userfunction_myfunction.xml".

If you want to create a function for a specific need in a particular waypoint file you can put it in the onLoad section of the waypoint file.

There are probably a few other places you can put them but you get the idea.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests