PDA

View Full Version : problem with reget



SaroAfk
09-15-2006, 05:13 PM
There's a problem with reget, I cant say for sure but it seems like the buffe it uses is fucked up, the command seems to work more or less its just weird, this code works, but when you re-use it, it fucks up. It just works really weird any tips on figuring the buffer or something so this command works correctly?

check:
put "look"
match "spellupcheck1", "Table"
match "look", "A sun-bleached skull"
matchwait

spellupcheck1:
check = reget(20, "Spirit Shield")
put "spell active"
waitfor "You currently have the following active spells:"
pause 2
echo "#{check}"
if "#{check}" == "Spirit Shield"
goto "spellupcheck2"
else
echo "goto empathpoke"
end

spellupcheck2:
checkt = reget(20, "Thurfel's Ward")
if "#{checkt}" == "Thurfel's Ward"
echo "goto spellcheck3"
goto "spellupcheck3"
else
echo "wizardpoke"
echo "goto wizardpoke"
end

spellupcheck3:
check102 = reget(20, "Spirit Defense")
if "#{check102}" == "Spirit Defense"
echo "toworker"
goto "toworker"
else
echo "103"
put "incant 103"
pause 2
goto "tonpc"
end

empathpoke:
put "poke empath"
waitfor "A dim aura surrounds you."
goto "spellupcheck2"

wizardpoke:
put "poke wizard"
waitfor "wizard whispers,"
goto "spellupcheck3"

cast103:
put incant 103
goto tonpc

tonpc:


I realise there's better ways to do this buff checking, like with checkspell but I would like to use reget for other things, like a random check for someone coughs or ambushes

npcpwn:
put "prep 702"
put "cast npc"
put "stance defensive"
if reget 20, "You hear someone cough."
echo "move on"
else
echo "go ahead and fight"
end
if reget 20, "leaps from hiding to attack!"
echo "move on"
else
echo "go ahead and fight"
end
match "npcpause", "...wait"
match "flee#{counter}", "You are in no condition"
match "stunned", "You are still stunned"
match "npcpause", "You don't have a spell prepared!"
match "deadnpc", "dies."
#match "deadnpc", "dead."
match "deadnpc", "motionless."
match "npcpause2", "Cast Roundtime 3 Seconds."
match "npcpause", "Wait"
match "look", "Cast at what?"
match "look", "What were you referring to?"
match "deadnpc", "already dead"
match "deadnpc", "But it is dead!"
matchwait

Shaelun
09-15-2006, 07:58 PM
It's not fucking up. You're trying to use it a way it doesn't work. I should point out that the buffer is cleared every 60 game lines now (or maybe it's 64... I don't remember what number I used) as opposed to every 2 minutes.



>;man reget
--- Lich: man active.
Command: regetall
Synonyms: none
Returns: an array of strings, or nil.
Example(s):
regetall "Shaelun"
Description:
Takes a string and returns an array of all game lines (since login) that match as having contained the given string (absolutely every single line since you logged in, Lich remembers them all). If a script is set as receiving the status data that doesn't show in the game window, those lines are also matched for; if the script is only being fed normal game data, that's the only history this command checks. If no matching lines were found, returns 'nil' (which is false in a logical comparison). As well as returning the matches, it also adds them to the script's game data stack so that subsequent 'get' commands will fetch them in order. The string to match for is actually optional, and if omitted, all lines are considered 'matching'.
---
Command: reget
Synonyms: none
Returns: an array of strings, or nil.
Example(s):
reget 3
reget 5, "Shaelun"
Description:
Similar to 'regetall' in behavior, but it only checks the current RAM cache (every 2 minutes, Lich's 'memory' of game data is emptied out of RAM and stored in a temporary file on the hard disk so that the program doesn't take up more resources than is necessary -- these files are deleted when the program closes); it also takes an optional integer, which represents how many game lines back to check ('reget 5' would scan the last 5 lines from the game that are still in RAM). If the integer is omitted, will scan the entire existing RAM buffer (again, cleared every 2 minutes).
--- Lich: man finished.

SaroAfk
09-15-2006, 09:39 PM
If its a way its not intended... what is it good for? also, 60 lines is fine, im checking like 20 lines behind me hence the reget 20,. I read the manual and tutorials, from what I am reading it looks like this is exactly what its supposed to do, even the manual you posted seems to say I could do this. all im trying to do is scan the last 20 lines for a string, if its there: do this else: do this. If this isnt the intended use I dont understand what the use actually is? Any other idea's on how to accomplish this coding with something thats intended to be used with it?

Shaelun
09-16-2006, 07:59 PM
Here's the problem: every 64 game lines, the RAM cache is emptied, and that 64th line could happen a millisecond before you check the "reget" command or it could happen exactly the way you'd like it to.

You're right, that's what I intended its use to be, but I made the feature 8-10 months ago and have since changed things a bit -- despite its unpredictable nature, I left it in since it does what it's "supposed" to do just fine.

If you don't like the command's behavior, try having a second script track specific information -- your primary script there doing whatever it is you want it to do, and a secondary script that just sits there and watches the game so it can keep a few global variables that tell the primary script what's going on updated.

Don't forget that a script can pause another script, or itself, or send another script information, or simulate game lines to "fake-out" other scripts, etc., etc..

If you want any decent measure of reliability, I think that's your best bet. Or just use the regetall command, stick it in a variable, and then dump everything except the last 20 lines. e.g.:



history = regetall
clear
what_i_care_about = history[0..20]
if what_i_care_about.find { |line| line =~ /Something just tried to smoosh you!/ }
echo "We got attacked in the past 20 lines"
end

... shamefully lame example, but hopefully you get my point. That code just ignores everything except the last 20 lines, even though regetall returns possibly thousands. The clear is to make sure previous stuff doesn't confuse the script into thinking it's happening currently (it clears the "stack" that the script checks anytime you use match commands or waitfors, etc.).

SaroAfk
09-16-2006, 10:12 PM
Thx for the advice, i figured out running a 2nd script and using globals about an hr after I made the 2nd post, thinking outside the box isnt exactly my strong point :P I have another question tho, am I doing something wrong with these lines or are they just bugged?

#################################################
hourly_bounty = Autotimer.new(0, 960, 'echo "going for bounty"')
waitingforado = Watchfor.new("player has arrived", "echo 'die'")

start:
pause 0.5
goto "start"
#################################################
I can get neither of those commands to work, the output is:
--- Exception: uninitialized constant Autotimer
And for watchfor, its:
--- Exception: wrong number of arguments (2 for 0)

Any idea's? wrong usage? wrong verbage? anything?

Shaelun
09-17-2006, 02:33 AM
Excerpt from the changelog (no, it hasn't been rewritten yet):

4-30-06:
(v3.34)

[snip-snip, several notes are being left out for brevity]

- The in-script "Watchfor" commands are all screwy, I've removed them all until I've fixed them so as to avoid users wondering why it isn't working right.

SaroAfk
09-17-2006, 02:43 AM
Thank you for clarifying how much of an idiot I am, I think I'll just go shoot myself now.

Shaelun
09-17-2006, 03:06 AM
... I get asked questions a *lot*, and sometimes it's hard for me to be as patient as I should be. If I made you feel that bad, I'm sorry man -- that wasn't my intention. There's a sickeningly bloated collection of documentation with the program, and I can't blame people for not wanting to read half an encyclopedia before they ask the guy who wrote the prog.

It's not perfect; infact it's the first large project I ever actually put up for download by others. I kinda wasn't such a good programmer when I started it a year ago, so things change from update to update as I fix or clean-up stuff.

SaroAfk
09-19-2006, 07:27 AM
lol, dont be sorry, the documentation is out there, people want to be lazy and not read, fuck'em, lazyness never got anything done, it sure didnt get lich written in the 1st place, if the question has been answered you shouldnt have t come back and answer it again. i was more pissed at myself for not looking harder, felt like and idiot, nothing you said really.