[Ohrrpgce] Input String command

Bob the Hamster Bob at HamsterRepublic.com
Wed Jun 1 11:40:37 PDT 2005



On Wed, Jun 01, 2005 at 02:27:04PM -0400, Mike Caron wrote:
> I was thinking about implementing a routine to give the player a
> chance to input an arbitrary string (without the use of name hero()),
> and I came up with this routine (or two).
> 
> It's not done, but you can enter all the letters* (upper and lower
> case), numbers (both the numbers, and their respective symbols),
> space, backspace and enter (which doesn't get put in the stream, but
> instead says "ok, done").
>
> * - with the exception of "j", since that brings up the joystick
> calibration menu. Perhaps a bitset to disable that would be in order
> 
> The other routine (which is actually above it) essentially translates
> the key codes into ascii values. Of course, this would all be simpler
> if game remembered the ascii code entered (or even the last key code)
> instead of having to check *each* key.
> 
> I'm going to finish this up tonight. The only reason I'm sending it
> like this is because I'm at school right now, and need to transport it
> home. :) So, I thought I'd ask for some C&C in the mean time.

I was thinking that something like this would be useful (you just know 
everybody would want it) but I had been thinking along the lines of a 
hard-coded function, very much like "rename hero" ... but actually, I 
like what you are doing here better. it looks good.

By coding it as a script, it reduces bloat, and it will be more 
flexible.

As for the problem with "j" bringing up the joystick config screen, I 
suggest the following two changes:

1) Make CTRL+J bring up the joystick screen, not plain J
2) the same bitset used by "suspend player" should also disable CTRL+J

---
Bob the Hamster

> script, last ascii, begin
> 	variable(code, shift)
> 
> 	shift := keyispressed(42)==true, or, keyispressed(54)==true
> 
> 	if(keyispressed(30)) then (code := 65)
> 	if(keyispressed(48)) then (code := 66)
> 	if(keyispressed(46)) then (code := 67)
> 	if(keyispressed(32)) then (code := 68)
> 	if(keyispressed(18)) then (code := 69)
> 	if(keyispressed(33)) then (code := 70)
> 	if(keyispressed(34)) then (code := 71)
> 	if(keyispressed(35)) then (code := 72)
> 	if(keyispressed(23)) then (code := 73)
> 	if(keyispressed(36)) then (code := 74)
> 	if(keyispressed(37)) then (code := 75)
> 	if(keyispressed(38)) then (code := 76)
> 	if(keyispressed(50)) then (code := 77)
> 	if(keyispressed(49)) then (code := 78)
> 	if(keyispressed(24)) then (code := 79)
> 	if(keyispressed(25)) then (code := 80)
> 	if(keyispressed(16)) then (code := 81)
> 	if(keyispressed(19)) then (code := 82)
> 	if(keyispressed(31)) then (code := 83)
> 	if(keyispressed(20)) then (code := 84)
> 	if(keyispressed(22)) then (code := 85)
> 	if(keyispressed(47)) then (code := 86)
> 	if(keyispressed(17)) then (code := 87)
> 	if(keyispressed(45)) then (code := 88)
> 	if(keyispressed(21)) then (code := 89)
> 	if(keyispressed(44)) then (code := 90)
> 	if(keyispressed(2)) then (if(shift) then (code :=33) else (code :=49))
> 	if(keyispressed(3)) then (if(shift) then (code :=64) else (code :=50))
> 	if(keyispressed(4)) then (if(shift) then (code :=35) else (code :=51))
> 	if(keyispressed(5)) then (if(shift) then (code :=36) else (code :=52))
> 	if(keyispressed(6)) then (if(shift) then (code :=37) else (code :=53))
> 	if(keyispressed(7)) then (if(shift) then (code :=94) else (code :=54))
> 	if(keyispressed(8)) then (if(shift) then (code :=38) else (code :=55))
> 	if(keyispressed(9)) then (if(shift) then (code :=42) else (code :=56))
> 	if(keyispressed(10)) then (if(shift) then (code :=40) else (code :=57))
> 	if(keyispressed(11)) then (if(shift) then (code :=41) else (code :=48))
> 	if(keyispressed(41)) then (if(shift) then (code :=126) else (code :=96))
> 	if(keyispressed(12)) then (if(shift) then (code :=95) else (code :=45))
> 	if(keyispressed(57)) then (code := 32)
> 
> 
> 	if(code <= 90, and, code >= 65) then, begin	
> 		if(shift == false) then (code += 32)
> 	end
> 
> 	return (code)
> 
> end
> 
> script, input string, str, useexist, begin
> 	variable(done, key)
> 	if(useexist==false) then (clear string(str))
> 	while(done == false) do, begin
> 		center string at(str,160,110)
> 		wait for key
> 		if(key is pressed(28)) then (done := true) else, begin
> 			if(key is pressed(14)) then (delete char(str,string length(str)))
> 			key := last ascii
> 			if(last ascii) then(append ascii(str,key))
> 		end
> 	end
> end
> _______________________________________________
> Ohrrpgce-motherhamster.org mailing list
> ohrrpgce at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org




More information about the Ohrrpgce mailing list