Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Strings

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
*Worthy*
Critical Thinker




Joined: 11 Aug 2003
Posts: 186

PostPosted: Sun May 28, 2006 11:47 am    Post subject: Strings Reply with quote

I'm trying to allow the user to type in a password, and then I want to check that password to see if it is correct. Two questions:

1. How can I get the user to type information into a string? I tried using the "input string (1)" command, but that does not seem to be working.

2. How can I check the characters of the string to see if the password is correct? I could not find any way to return the ascii value of a character, so I am thinking of using the "string to globals" command.

Perhaps I am just being dumb and completely overlooking something, because I don't think this is very difficult task. I know in Java they have commands like charAt(index) to return the value of a character, but I didn't see anything ilke that here.

Thanks,

~Worthy
_________________
You can do whatever you want...but prison is full of people who make bad decisions.
Back to top
View user's profile Send private message Send e-mail AIM Address
Iblis
Ghost Cat




Joined: 26 May 2003
Posts: 1233
Location: Your brain

PostPosted: Sun May 28, 2006 12:13 pm    Post subject: Reply with quote

Quote:
. How can I get the user to type information into a string? I tried using the "input string (1)" command, but that does not seem to be working.


It's pretty simple to make your own input string function. Just use show string at to display the string on the screen, then check what keys the player presses and add those character to the string. This is also useful for keeping characters out that you don't want.

Quote:
2. How can I check the characters of the string to see if the password is correct? I could not find any way to return the ascii value of a character, so I am thinking of using the "string to globals" command.


I would REALLY REALLY like a "read ascii" command or something, that would let me know the ascii value of a certain character in the string.

This page talks about a "string compare" command which doesn't seem to be in the plotscripting dictionary. So you could probably try it, I think it's pretty clear how it'd work, probably just string compare (string1, string2) and returns true or false depending on whether they're the same.

The string to globals would also work though, and since a password should be reasonably short I doubt that'd be a problem.
_________________
Locked
OHR Piano
Back to top
View user's profile Send private message Send e-mail
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sun May 28, 2006 10:17 pm    Post subject: Reply with quote

Iblis wrote:
I would REALLY REALLY like a "read ascii" command or something, that would let me know the ascii value of a certain character in the string.


It already exists. The thing is, the string commands aren't documented very well so many people can't figure out how to use them, and a few commands aren't even mentioned at all.

asciifromstring(string id, position in string)

Returns the ASCII number 'n stuff from the position specified in the string.
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun May 28, 2006 11:01 pm    Post subject: Re: Strings Reply with quote

*Worthy* wrote:
1. How can I get the user to type information into a string? I tried using the "input string (1)" command, but that does not seem to be working.


Gulp. Could you please describe what happens when you try?
(input script is implemented as a script in plotscr.hsd BTW)

Iblis wrote:
Quote:
2. How can I check the characters of the string to see if the password is correct? I could not find any way to return the ascii value of a character, so I am thinking of using the "string to globals" command.


I would REALLY REALLY like a "read ascii" command or something, that would let me know the ascii value of a certain character in the string.

This page talks about a "string compare" command which doesn't seem to be in the plotscripting dictionary. So you could probably try it, I think it's pretty clear how it'd work, probably just string compare (string1, string2) and returns true or false depending on whether they're the same.


Whoops! stringcompare is indeed a command. Just do this:

Code:
$2="CorrectPassword"
if (string compare (1, 2)) then (...)



Quote:
It already exists. The thing is, the string commands aren't documented very well so many people can't figure out how to use them, and a few commands aren't even mentioned at all.


Yeah. I'll just go through the string commands and make sure they're all documentated now. Amongst other missing documentation, the HamsterSpeak definition hasn't been updated either.

W00t! Post 1500! Me setting myself demeaning tasks!
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
*Worthy*
Critical Thinker




Joined: 11 Aug 2003
Posts: 186

PostPosted: Mon May 29, 2006 5:23 am    Post subject: Reply with quote

When I put "input string (1)", nothing happens. The script will wait for the player to press "enter" before continuing, but when I display the string, nothing comes up.

~Worthy
_________________
You can do whatever you want...but prison is full of people who make bad decisions.
Back to top
View user's profile Send private message Send e-mail AIM Address
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Mon May 29, 2006 9:36 am    Post subject: Reply with quote

Inputstring has 3 arguments

the 1st argument is the string id you want to use.
the second is the length of input
3rd is if you want to add to the existing string, or if you want to start with a blank string.

Also, the function itself returns false if you press ESC.

Also since Mike did this command, I think he should add 3 more arguments to it.
4th being either 1 or 0, if its 1 then center the string, if 0 then don't center it.
5th would be the x position of the string on the screen
6th would be the y position.
the default values for 4th 5th and 6th would be, 1, 160,110
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Mon May 29, 2006 6:27 pm    Post subject: Reply with quote

Or you could just copy the script yourself. I'm far too busy to do menial tasks like adding a few simple parameters to a soft-coded script. I'm busy adding features to the engine (and thoroughly testing them, too)
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Mon May 29, 2006 7:00 pm    Post subject: Reply with quote

I guess I will do it myself then.

Gotta ask James for access to repositories, so that I can submit my own changes and features.

BTW Worthy, inputstring(1) doesn't work because the default value for input length is 0, thats why you can only press enter.
you would need something like this, inputstring(1,5). In this example you can type up to 5 letters.
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
*Worthy*
Critical Thinker




Joined: 11 Aug 2003
Posts: 186

PostPosted: Wed May 31, 2006 10:58 am    Post subject: Reply with quote

Thanks, I got it working now Happy.

~Worthy
_________________
You can do whatever you want...but prison is full of people who make bad decisions.
Back to top
View user's profile Send private message Send e-mail AIM Address
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Wed May 31, 2006 4:09 pm    Post subject: Reply with quote

Ysoft_Entertainment wrote:
I guess I will do it myself then.

Gotta ask James for access to repositories, so that I can submit my own changes and features.


Uh, yeah. Becuase we don't accept patches.

(that was sarcasm)

Ysoft_Entertainment wrote:
BTW Worthy, inputstring(1) doesn't work because the default value for input length is 0, thats why you can only press enter.
you would need something like this, inputstring(1,5). In this example you can type up to 5 letters.


In retrospect, I see no reason why the default is 0. I will fix it so that the default is 40 instead, the max length of a string.
_________________
I stand corrected. No rivers ran blood today. At least, none that were caused by us.

Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Wed May 31, 2006 4:16 pm    Post subject: Reply with quote

By the way worthy, inputstrings delete button doesn't work correctly.
you gonna have to go into plotscr.hsd and modify input string.
Just move count:=blabla(forgot exactly what it equals to but its crucial for delete button to work properly), into a while loop. That will make the delete button work correctly.

I got it fixed for the next release of ohr, and modified the inputstring to work as I posted above, meaning that its going to have 3 new arguments.
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group