PDA

View Full Version : What am I doing wrong?



Tgo01
04-19-2013, 05:28 PM
I was trying to write up a script for herb bounties where it would have all rooms for that location (like all rooms that are in the 'Ice Plains') and go through each room and when it comes upon a room where the herb can't be found it would add that to a list of rooms not to visit in the future. I was just testing what I have so far before I finished writing the script and I'm already stuck. Here is the relevant part giving me trouble.



result = dothistimeout "forage for pine cone", 2, /(You wonder if it could even be found in this terrain|you can find no trace of what you are looking for|You are not even sure it could be found in this type of climate)/i
if result = /(You wonder if it could even be found in this terrain|you can find no trace of what you are looking for|You are not even sure it could be found in this type of climate)/i
Settings['unacceptable_room'].push(Room.current.id)
wander.call
elsif result.nil?
pause 1
wander.call
end

The script is working great as far as moving to the correct room, foraging, adding unacceptable rooms to the list of rooms not to visit in the future and it won't visit those rooms anymore either. Only problem is it's adding every single room to the list of unacceptable rooms whether I get the correct messaging or not. Any ideas?

Tillmen
04-19-2013, 08:13 PM
You've used "if result =" instead of "if result =~". So, instead of doing a regexp match, you're assigning a value to result, and then testing that value. Since result is not false or nil, it's true.

Tgo01
04-19-2013, 08:19 PM
You've used "if result =" instead of "if result =~". So, instead of doing a regexp match, you're assigning a value to result, and then testing that value. Since result is not false or nil, it's true.

<insert forehead smack here>

I totally didn't even notice that, thanks Tillmen.

Tgo01
04-19-2013, 09:50 PM
While you're here Tillmen, is there an easier way to get a list of all room numbers in a particular area? I'm still using that wander rooms code you posted in another thread where you list all acceptable rooms rather than setting up boundaries like bigshot does for hunting, it works great. Only thing is getting the list of rooms in the first place whenever I have to setup another hunting ground, right now I just go through each room and jot down the number. For the script I'm writing now I thought I could just do ";go2 ice plains" and see a list of all rooms in the ice plains but I noticed some rooms in some areas don't necessarily have the name of the area in the room name. Also if I were to do ";go2 the rift" I would get 235 matches with no way of seeing which rooms are on which planes.

I don't mind the way things are now, just wondering if there was a quicker/easier way that I'm unaware of.

Tillmen
04-19-2013, 10:07 PM
room_list = Map.list.find_all { |room| (room.location == needed_location) and (room.tags.include?(needed_herb)) }
while (room = room_list.pop) and (herb_count < needed_herb_count)
start_script 'go2', [ room.id.to_s ]
wait_while { running?('go2') }
# forage and stuff / increment herb_count
end

Tillmen
04-19-2013, 10:13 PM
To get room numbers for a hunting ground, I wouldn't go by the location stored in the map database. It's usually a larger area than you want to wander, and might include climbing or areas where there are herbs but nothing to kill, or something that will kill you. I usually just write a quick exec script and manually walk around the area I want.

;e $temp = Array.new; room_count = XMLData.room_count; loop { wait_while { room_count == XMLData.room_count }; room_count = XMLData.room_count; $temp.push(Room.current.id.to_s) unless $temp.include?(Room.current.id.to_s) }

;e echo $temp.inspect

Tgo01
04-19-2013, 10:45 PM
room_list = Map.list.find_all { |room| (room.location == needed_location) and (room.tags.include?(needed_herb)) }
while (room = room_list.pop) and (herb_count < needed_herb_count)
start_script 'go2', [ room.id.to_s ]
wait_while { running?('go2') }
# forage and stuff / increment herb_count
end

That's awesome, didn't even know you could do that. I don't want to sound ungrateful or anything though but the herb tags don't seem very accurate, for example it had two rooms listed in thyrils in Icemule for rockberry when just about every room in that area has rockberry in it. How are herb tags updated? Does lich keep track of which room people find herbs in? I noticed it was updating my map as I was finding rockberry.


;e $temp = Array.new; room_count = XMLData.room_count; loop { wait_while { room_count == XMLData.room_count }; room_count = XMLData.room_count; $temp.push(Room.current.id.to_s) unless $temp.include?(Room.current.id.to_s) }

;e echo $temp.inspect

That's perfect, exactly what I needed. Thank ya.

Tillmen
04-19-2013, 11:15 PM
That's awesome, didn't even know you could do that. I don't want to sound ungrateful or anything though but the herb tags don't seem very accurate, for example it had two rooms listed in thyrils in Icemule for rockberry when just about every room in that area has rockberry in it. How are herb tags updated? Does lich keep track of which room people find herbs in? I noticed it was updating my map as I was finding rockberry.


lnet watches you forage and updates your map database, but doesn't save it, and also adds to a database on the server. Eventually it'll make it into the map database on the server. It will probably never have every room for every herb, but it has about 32,809 herb locations for 365 herbs (or plants or something), so it's not that bad.

Tgo01
04-20-2013, 10:05 PM
room_list = Map.list.find_all { |room| (room.location == needed_location) and (room.tags.include?(needed_herb)) }
while (room = room_list.pop) and (herb_count < needed_herb_count)
start_script 'go2', [ room.id.to_s ]
wait_while { running?('go2') }
# forage and stuff / increment herb_count
end

What exactly do I put in the needed_location part? I tried putting like Abandoned Farm and I couldn't get it to work.

Tillmen
04-20-2013, 10:49 PM
the Abandoned Farm

DaCapn
04-21-2013, 02:54 AM
;e echo Room.current.location

Tgo01
05-17-2013, 08:08 PM
I got another problem that I can't figure out.



cast = proc{
if checkmana < 26 and checkspirit >= 6
cast 'sign of wracking'
end


This is just the beginning of the procedure, I have the end bracket at the end, everything else with this procedure works just fine.

This gives me an error that says something like "Invalid number of arguments (0 for 1)" when my mana is below the threshold, otherwise the rest of the script runs just fine.

I really don't understand what is wrong. I've tried breaking it up so it checks for mana in one if statement then checks for spirit in another if statement, same problem. I tried making it call up another procedure to cast sign of wracking, same problem.

Any ideas?

Tillmen
05-17-2013, 08:44 PM
The only thing I see wrong with that is you named your proc cast. Then you try to use cast, inside cast... which cast are you using? That doesn't completely explain the error message though. Line numbers would probably help.

Tgo01
05-18-2013, 03:22 AM
The only thing I see wrong with that is you named your proc cast. Then you try to use cast, inside cast... which cast are you using? That doesn't completely explain the error message though. Line numbers would probably help.

I changed the name of the proc to spell and I'm still getting the same error.



spell = proc{
if checkmana < 26 and checkspirit >= 6
cast 'sign of wracking'
end

Here is the error message:



--- Exception: wrong number of arguments (1 for 0)
dup:7:in `cast'

Line 7 is cast 'sign of wracking'

Tillmen
05-18-2013, 12:06 PM
I think you must have put "def cast" somewhere, in this script or any other script that has been started since you logged on.

Tgo01
05-18-2013, 12:41 PM
I think you must have put "def cast" somewhere, in this script or any other script that has been started since you logged on.

Yup that was it, it was from one of my older scripts before I knew any better.

Thanks Tillmen.