PDA

View Full Version : BUG: Checkmind



Danical
09-24-2008, 09:02 AM
Checkmind needs to be updated for saturated status at rank 9.


K>;e echo checkmind(10)
--- Lich: exec1 active.
[exec1: Checkmind error! You must provide an integer ranging from 1-9 (7 is fried, 8 is 100% fried, 9 is extremely rare and is impossible through normal means to reach but does exist), the common abbreviation of how full your head is, or provide no input to have checkmind return an abbreviation of how filled your head is.]

Your mind is completely saturated. It is imperative that you rest immediately!

K>;e echo checkmind
--- Lich: exec1 active.
[exec1: fried]

>;e echo checkmind(9)
--- Lich: exec1 active.
[exec1: false]
--- Lich: exec1 has finished

Audriana
09-24-2008, 12:25 PM
from what I remember, Lich is dead. no further updates.

There's quite a few things that need to be fixed and probably won't be.

Shaelun
09-26-2008, 03:34 PM
from what I remember, Lich is dead. no further updates.

There's quite a few things that need to be fixed and probably won't be.

No, it isn't dead, but its only developer doesn't have anywhere near the amount of free time he did when he originally wrote most of the program.

Perhaps it will help explain this list of "quite a few things that need to be fixed," if I point out that I don't consider broken or bugged scripts to be a significant problem. The program is, above all else, a way for users to implement their own features -- the vast majority of scripts that I wrote for the program aren't an integral part of that goal, and so I don't consider a broken script a bug in the program (I just consider it a broken script).

It's a distinction that most people seem to overlook... the scripts can implement features that appear, for all intents and purposes, to be built-in to the program itself; that's not the case though. The only analogy I can come up with is that Lich is like a CD player, and the scripts are like individual CDs that came with the player -- as long as the CD player itself works properly, I don't see it as a major problem for an individual CD to occasionally not play flawlessly (whether it's my creation or the creation of a user I've never spoken to.)

That's not what I consider a "dead project," but ultimately you can define that however you like.

As for the checkmind thing, that's a built-in function that should be working even with a saturated mind (but that obviously doesn't seem to be in SF.) Put this at the beginning of your script (or toss it into a "custom function definition" script, so to speak, that you have on your favorites list and that runs every time you log in):



# Make sure we only make an alias to the function the first time, otherwise we'll overwrite the reference to the original "checkmind" with our altered "checkmind" anytime this code is seen more than once in a single login session
if not defined?(:builtin_checkmind)
alias :builtin_checkmind :checkmind
end

def checkmind(arg = nil)

if arg != nil and arg == 9
mindState = builtin_checkmind
if mindState =~ /saturated/
return true
else
return false
end
else
return builtin_checkmind(arg)
end

end


That will make "builtin_checkmind" a command that is identical to "checkmind" -- calling "builtin_checkmind" will call the function as it was when the "alias" command was evaluated.

Then we just replace the existing "checkmind" function with a new function -- if the new "checkmind" command is called as "checkmind(9)", we return "false" if the character is not saturated, and "true" if the character is saturated. If the "checkmind" function is called in any other way, we just call the original "checkmind" (meaning the one that I wrote, that's built right into Lich) as though nothing had changed.

I realize the vast majority of users aren't experienced programmers, but the program is meant to allow for this sort of customizing of its inner workings. As long as you make sure that the new function(s) take the same parameters, and return the same sort of value, you can change or altogether replace anything you want and the program will just "magically" keep working properly (unless your new code doesn't work properly, in which case nothing that uses your code will work right, of course.)

Danical
09-29-2008, 05:05 AM
I put it in my script and this was the result when trying to call checkmind(9)

>;e echo checkmind(9)
--- Lich: exec1 active.
--- Exception: undefined local variable or method `builtin_checkmind' for main:Object
--- Lich: exec1 has exited.
>;e echo checkmind
--- Lich: exec1 active.
--- Exception: undefined method `builtin_checkmind' for main:Object
--- Lich: exec1 has exited.
>;e echo mind?
--- Lich: exec1 active.
[exec1: becoming numbed]
--- Lich: exec1 has finished.

Shaelun
10-11-2008, 09:25 AM
I wish I knew what to tell you... I just tested the code in IRB (Interactive Ruby, it's a Ruby shell [basically]), and it should work just fine:



irb(main):001:0> def checkmind; "old checkmind"; end; alias :builtin_checkmind :checkmind; def checkmind(arg=nil); if arg.nil? then builtin_checkmind else "new behavior" end; end
=> nil
irb(main):002:0> checkmind
=> "old checkmind"
irb(main):003:0> checkmind(true)
=> "new behavior"


Offhand, I don't know what the problem you're having is caused by.