Page 2 of 3

Re: 774 Changelog

Posted: Thu May 15, 2014 5:09 am
by lisa
my guess is andor training and only 2 romscripts in it.

RoMScript("UseExtraAction(1)")

repeat yrest(1000) until not RoMScript("TimeKeeperFrame:IsVisible()")

Actually it looks like it has finished the event and then interacted with the NPC, maybe doing options?

Code: Select all

Command> player:target_NPC("Mar")
We try to find NPC Mar:
We successfully target NPC Marliss Sister and try to open the dialog window.
Command> ChoiceOptionByName("open my bank")
Command> player:target_NPC("Mar")
We try to find NPC Mar:
We successfully target NPC Marliss Sister and try to open the dialog window.
Command> ChoiceOptionByName("a house")
Command> ChoiceOptionByName("prev")
they worked fine for me.

*goes back to sleep*

Re: 774 Changelog

Posted: Thu May 15, 2014 5:37 am
by ZZZZZ

Code: Select all

function DailyNotesActivate(questid);
		if RoMScript("DailyNotes") then
			local realm = string.match((RoMScript("GetCurrentRealm()") or ""),"(%w*)$") or ""
			local realmset = RoMScript("(DN_Options_Of_Char."..realm.." ~= nil)")
			if realmset then
				RoMScript("} DN_Options_Of_Char."..realm..".autoquest=true a={")
			else
				RoMScript("} DN_Options_Of_Char."..realm.." = {autoquest=true) a={")
			end

			local aq_accept = RoMScript("(DN_Options_Of_Char."..realm..".aq_accept ~= nil)")
			if aq_accept then
				RoMScript("} DN_Options_Of_Char."..realm..".aq_accept["..questid.."]=1 a={")
			else
				RoMScript("} DN_Options_Of_Char."..realm..".aq_accept={["..questid.."]=1} a={")
			end
			cprintf(cli.blue,"\nDaily Notes Addon is installed and working!\n")
			DailyNotesActiveID = questid
			DailyNotesActive = true
		else
			cprintf(cli.red,"\nDaily Notes Addon is not installed!\n")
			DailyNotesActive = false
		end
end
^ is the function that was being run with the first error print I got.

2nd one might have been RoMScript("StaticPopup_OnClick(StaticPopup1, 1);") or until RoMScript("StaticPopup1:IsVisible()"). They are the only RoMScript it uses once as its leaving.

Re: 774 Changelog

Posted: Thu May 15, 2014 5:52 am
by rock5

Code: Select all

RoMScript("DailyNotes")
DailyNotes is actually a table so now it actually returns the table and it's probably complex enough that it causes some error. Try changing it to

Code: Select all

RoMScript("DailyNotes~=nil")
Because all you are really checking is if it exists.

Re: 774 Changelog

Posted: Thu May 15, 2014 7:03 am
by ZZZZZ
rock5 wrote:DailyNotes is actually a table so now it actually returns the table and it's probably complex enough that it causes some error
Holy crap. You got that right lol, I tried a simple print(RoMScript("DailyNotes")). Took agesssss to do anything, but when it did it was a massive wall of text which I couldn't even scroll back to the top of haha.

Re: 774 Changelog

Posted: Thu May 15, 2014 10:22 pm
by rock5
I've committed those fixes for the party options in revision 775.

Re: 774 Changelog

Posted: Fri May 16, 2014 9:29 am
by lisa
ZZZZZ wrote:

Code: Select all

[string "return {_uilua.lightuserdate="userdata: 33B4D..."]:1: '}' expected near '='
I updated my KS bots to 775, got this exact same error (diff userdata) on the first player:merchant, didn't seem to affect the selling though.
Getting it on every bot, every time.

Re: 774 Changelog

Posted: Fri May 16, 2014 10:34 am
by rock5
Seems that RoMScript("CloseWindows()") returns a table when closing windows. First question would be, why would it error? I'll have to look into it. Second problem is, this is an issue that a command unexpectedly returns a table. This happens to be a small table but it could cause performance issues if a command unexpectedly returned a massive table. I think it may have to become common practice to use RoMCode when executing a command and not expecting a return value. That way if there is an unexpected returned value such as a table, it will be ignored. But I expect this will cause some problems in the short term. I'm open to other suggestions for solving this.

Re: 774 Changelog

Posted: Fri May 16, 2014 11:50 am
by botje
yep, got it too here lisa.

selling goes tru nonetheless :)

Re: 774 Changelog

Posted: Fri May 16, 2014 5:19 pm
by lisa
rock5 wrote:I think it may have to become common practice to use RoMCode when executing a command and not expecting a return value.
So basically if you want a value returned use RoMScript and if you are just executing a function use RoMCode ?

That will be relatively easy to use notepad++ and it's search in files option,

replace all RoMScript with RoMCode and then do

search for
= RoMCode
replace with
= RoMScript

That will probably get them easily.
issue would only be if they have varying spaces
=RoMScript
= RoMScript
but could just do a search for them afterwards, I doubt there would be any.

Hmm then need to check for
if RoMScript
and
not RoMScript


ugggh

Re: 774 Changelog

Posted: Fri May 16, 2014 5:54 pm
by lisa
Manually went through and replaced about 85 RoMScript with RoMCode and ran a little WP, seemed to work ok.

Re: 774 Changelog

Posted: Fri May 16, 2014 9:09 pm
by rock5
Good work. Looks like you missed a couple in functions.lua (lines 1599,1609), 1 in settings.lua (line 1058).

You have to be careful with that method you described as romcode can return a value so you have to make sure that no existing romcodes get changed to romscripts. Eg.

Code: Select all

var = RoMCode("some code a={return value}")
Also you have to make sure no old romscript code gets changed to a romcode, eg.

Code: Select all

RoMScript("} some code z={")
Although they could probably be modified to use romcode.

I couldn't find any instances of these happening so that's good, although I'll probably find some in my userfunctions.

Re: 774 Changelog

Posted: Fri May 16, 2014 9:24 pm
by lisa
I actually just did a search for RoMScript and looked at all 192 myself.

A couple of them were interesting though, I didn't expect them to have issues but they did for some reason.

These errored when changed to RoMCode

Code: Select all

RoMScript("xxxx; ChatFrame1:AddMessage(\"MACRO test: successful\");")

Code: Select all

		RoMScript("ToggleBackpack(), BagFrame:Hide()"); -- Make sure the client loads the tables first.
		RoMScript("GoodsFrame:Show(), GoodsFrame:Hide()"); -- Make sure the client loads the tables first.
Maybe because it is doing 2 different functions in the last 2.

Re: 774 Changelog

Posted: Fri May 16, 2014 10:27 pm
by rock5

Code: Select all

RoMScript("xxxx; ChatFrame1:AddMessage(\"MACRO test: successful\");")
That's a strange one. I know why it errors but I don't know why it sends "xxxx". As far as I can tell that does nothing. It can probably just be changed to

Code: Select all

RoMCode("ChatFrame1:AddMessage(\"MACRO test: successful\");")

Code: Select all

      RoMScript("ToggleBackpack(), BagFrame:Hide()"); -- Make sure the client loads the tables first.
      RoMScript("GoodsFrame:Show(), GoodsFrame:Hide()"); -- Make sure the client loads the tables first.
The reason these fail when changed to RoMCode is because as RoMScripts they effectively become

Code: Select all

a={function1(), function2()}
which is valid. But as RoMCode it becomes

Code: Select all

a={} function1(), function2() z={}
The comma now becomes a syntax error.

This should work

Code: Select all

      RoMScript("ToggleBackpack() BagFrame:Hide()"); -- Make sure the client loads the tables first.
      RoMScript("GoodsFrame:Show() GoodsFrame:Hide()"); -- Make sure the client loads the tables first.
And still I missed those two. You're obviously being more thorough than me. :)

Re: 774 Changelog

Posted: Sat May 17, 2014 12:12 am
by lisa

Code: Select all

		RoMCode("ChatFrame1:AddMessage(\"MACRO test: successful\");");


		RoMCode("ToggleBackpack() BagFrame:Hide()"); -- Make sure the client loads the tables first.
		RoMCode("GoodsFrame:Show() GoodsFrame:Hide()"); -- Make sure the client loads the tables first.
These seemed to work ok.

Re: 774 Changelog

Posted: Sat May 17, 2014 1:28 am
by rock5
In regards to the error that CloseWindows() caused, it was because of the dot in the key names, eg. _uilua.lightuserdate=. I'm of 2 minds on what to do about this. I've already made a change that turns _uilua.lightuserdate= into ["_uilua.lightuserdate"]= which works but it brings up the issue that a key name can be made of nearly any characters even special characters that would cause errors unless used with ["name"]. To be absolutely sure that a table is converted to a valid load string we could just use [" and "] with every string key but that would add 4 characters for every table entry to the length. It would be good if there was a way to tell if the name is valid, if so it could use name=, if not it can use ["name"]. Maybe I could just check for any non alpha/numeric/underscore character. I'd also have to check if the first character is a letter. Hm.. can be done.

Re: 774 Changelog

Posted: Sat May 17, 2014 11:43 am
by cibervagos
Hi ppl! IDK if I'm posting in the right place. I have a problem with sendPartyChat. With the new revision sendPartyChat dosn't work. Error coming in line 270 of party.lua (_whispname is a nil value). So I change my party.lua from

Code: Select all

function sendPartyChat(_msg)
	if settings.profile.options.MONITOR_WHISPERS then
		
	else
		RoMScript("SendChatMessage('".._msg.."', 'WHISPER',0,'".._whispname.."')")
	end
	cprintf(cli.blue,_msg.."\n")
end
to

Code: Select all

function sendPartyChat(_msg)
	if settings.profile.options.MONITOR_WHISPERS then
		RoMScript("SendChatMessage('".._msg.."', 'WHISPER',0,'".._whispname.."')")
	else
		RoMScript("SendChatMessage('".._msg.."', 'PARTY')")
	end
	cprintf(cli.blue,_msg.."\n")
end
Now work fine.

I cant be more especific becouse I'm pretty bad with english languaje. Sorry for that. :oops:

Re: 774 Changelog

Posted: Sat May 17, 2014 6:04 pm
by lisa
Not sure how that happened, the file I uploaded was exactly like that, so not Rock's fault but for me to upload that is just embarrasing.


I would add in an extra line, _whispname is gotten from who ever whispers you but if for some reason the bot is told to post a message before someone whispers it then it won't have a name to whisper.

Code: Select all

function sendPartyChat(_msg)
	if settings.profile.options.MONITOR_WHISPERS then
		if not _whispname then cprintf(cli.red,"You don't have a name for someone to whisper.\n") return end 
		RoMCode("SendChatMessage('".._msg.."', 'WHISPER',0,'".._whispname.."')")
	else
		RoMCode("SendChatMessage('".._msg.."', 'PARTY')")
	end
	cprintf(cli.blue,_msg.."\n")
end

Re: 774 Changelog

Posted: Sat May 17, 2014 7:03 pm
by rock5
lisa wrote:so not Rock's fault
One that's not my fault, what a relief. :)

Re: 774 Changelog

Posted: Tue May 20, 2014 12:00 am
by lisa
My head is a little less gooey now, so working on fixing this whisper issue.

Reason I haven't just commited the code I posted earlier is because I just don't like it.
The way I have it set up is that if someone whispers you then that name is used when you use sendPartyChat but if no one has whispered you then it has no name to send the whisper to, only way this could happen is if you use sendPartyChat it yourself in a WP or userfunction. The other issue is that if some random player whispers you then when you use sendPartyChat it will send it to them.
Example.
Using party bot and from leader char you tell the party bots to use a NPC to repair and such, they start to repair and this may take 5-10 second, in that short time if some random whispers you then the _whispname changes to them and so when the party bot is done repairing it whispers that random player that it has finished selling.

Note that all of this hinges on the profile having MONITOR_WHISPERS set to true, if it isn't set to true then there is no issue and it will just use party chat as I always intended.

Chances of this happening is pretty small but it is possible, generally people use party bot when they are controlling the leader character in the party aswell so this can be picked up on. If not manually playing leader then this could cause an issue.

So in short I don't like it but there is a very very very very small chance it may cause issues and to avoid that chance would require more work and effort than I feel is needed for this.

I guess I just talked myself into commiting this very minor fix.

Bah now I remember the biggest issue, anyone can give your party bot commands, so guess I won't be commiting just yet.

Re: 774 Changelog

Posted: Tue May 20, 2014 2:04 am
by rock5
Might have to do a rewrite and try to avoid using a global variable like _whispname. checkEventParty returns the senders name, why not use that to send the response? ie.

Code: Select all

_message , _name = checkEventParty()
sendPartyChat("response", _name)
As for anyone sending you commands, the only thing I can think of is to check if they are in your party or in your guild or in a white list.