[Ohrrpgce] string syntax in plotscripting

TeeEmCee teeemcee at gmail.com
Thu May 12 18:17:04 PDT 2005


Reviving an old topic, I just wanted to complain that if solely the
syntax $#$"..." was used for strings and converted into a specific
command to set a sting, how could you direct the output to other uses?

What I mean is, say you are creating a string giving the player's
current location, so you want to append " west, and " to the end of
it, and additionally you couldn't be sure that you have a free string.
I seems that you would have to create a mess such as:

define constant (900, buffer offset)

...
variable (temp len)
temp len := string length (31)
string to globals (31, buffer offset, temp len)
$31$" west, and "
concatenate strings (31, mystring)
globals to string (31, buffer offset, temp len)

That's why I like the idea of being able to use a string as an
argument to some wrapper script, which will be converted in a series
of arguments.

TMC

> > > > > > >   copy string (source string ID, dest string ID)
> > > > > > >   concatenate strings (source string ID, dest string ID)
> > > > > > >   string length (string ID)
> > > > > > >   replace char (string ID, position, ascii)
> > > > > > >   delete char (string ID, position)
> > > > > > >   ascii from string (string ID, position)
> > > > > > >   string to globals (string ID, starting global ID, length)
> > > > > > >   globals to string (string ID, starting global ID, length)


On 4/26/05, Bob the Hamster <Bob at hamsterrepublic.com> wrote:
> On Sun, Apr 24, 2005 at 11:07:07PM +1200, TeeEmCee wrote:
> > >There is a maximum number of arguments that a script can have... 16,
> > >IIRC, so in some cases a single string assignment will have to be
> > >converted into multiple commands
> >
> > Sure? I just tested passing out to 150 arguments, and everything worked.
> 
> Really? ... maybe that 16 arg limitation was something in the older
> quickbasic implementation of HSPEAK. it has been awhile since I worked
> on that code :)
> 
> > So, exactly what will $ID$"Some text" convert to?
> 
> I was thinking originally that it would convert to:
> 
> clear string (ID)
> add ascii (ID,83)
> add ascii (ID,111)
> add ascii (ID,109)
> add ascii (ID,101)
> add ascii (ID,32)
> add ascii (ID,116)
> add ascii (ID,101)
> add ascii (ID,120)
> add ascii (ID,116)
> 
> But now I am thinking that
> 
> set string(ID,83,111,109,101,32,116,101,120,116)
> 
> Might be better, where the definition of "set string" is something like:
> 
>   n,setstring,40,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
> 
> Where the -1 default arguments are ignored.
> 
> ---
> Bob the Hamster
> 
> > TMC
> >
> > On 4/24/05, Bob the Hamster <Bob at hamsterrepublic.com> wrote:
> > > On Sat, Apr 23, 2005 at 03:34:25PM +1200, TeeEmCee wrote:
> > > > What about adding an operator such as $= which would translate a line such as
> > > >
> > > > 25 $= "my string"
> > > >
> > > > to
> > > >
> > > > set string(25, "my string")
> > > >
> > > > (I assume thats what you meant by $25$)
> > > >
> > > > which would then wind up as
> > > >
> > > > setstring (25, 'm', 'y'...)
> > > >
> > > > where setstring is a wrapper script
> > >
> > > There is a maximum number of arguments that a script can have... 16,
> > > IIRC, so in some cases a single string assignment will have to be
> > > converted into multiple commands
> > >
> > > > Now, some problems:
> > > >
> > > > -spaces are removed, people would have to use something like _ instead
> > > > of a space
> > > > -capitalisation is also removed. It would be necessary to put a
> > > > character infront of every capitalised letter, like . \ % ` ~ or
> > > > somesuch
> > > > -ascii is not 100% equivalent to the ohr font! For instance, numbers
> > > > have different codes. Prehaps a constant lookup table? (eg, char:a,
> > > > char:1)
> > >
> > > HSPEAK will need to convert strgs right after it strips out comments,
> > > but right before it drops caps and collapses spaces (which comes before
> > > splutting commas and parenthesis)
> > >
> > > I drecree that the syntax shall be:
> > >
> > > $ID$"Some text"
> > >
> > > Any char such as , ( and ) is allowed. A double quote can be included as
> > > \"
> > >
> > > > More misc ideas:
> > > >
> > > > Prehaps there could be a way to include special characters such as (,
> > > > similiar to \n for a newline in other languages.
> > > > But, what about a way to pass the length of the string, without having
> > > > to manually count it? Maybe more special codes, like %L will add the
> > > > length of the string, or %F10% would pad the string up to some fixed
> > > > length.
> > > >
> > > > On 4/23/05, Mike Caron <caron.mike at gmail.com> wrote:
> > > > > Perhaps we could do something like this: "$25$My string!!!!!!11"
> > > > >
> > > > > The quotes clearly delimit the string, and it would not clash with any
> > > > > old symbols. We can safely embed symbols that would otherwise be
> > > > > interpreted for other things, so long as hspeak inteprets strings
> > > > > before the symbols in question.
> > > > >
> > > > > On 4/22/05, Bob the Hamster <Bob at hamsterrepublic.com> wrote:
> > > > > > On Thu, Apr 21, 2005 at 07:50:13PM -0400, Mike Caron wrote:
> > > > > > > I was thinking, to make strings easier, is that the compiler could
> > > > > > > fake strings like this:
> > > > > > >
> > > > > > > Let's say we have "set string(reg, str)". The compiler would turn this
> > > > > > > command into these commands:
> > > > > > >
> > > > > > > clear string (reg)
> > > > > > > add ascii (reg, str[0])
> > > > > > > add ascii (reg, str[1])
> > > > > > > add ascii (reg, str[2])
> > > > > > > ... until the end of the string
> > > > > > > add ascii (reg, 0)
> > > > > > >
> > > > > > > The 0 at the end to to mark the end of the string, so it'll be more
> > > > > > > efficient than saving the size somewhere.
> > > > > >
> > > > > > No, the string registers would be ordinary quickbasic strings, so they
> > > > > > would naturally store their size. No need to store it manually or add a
> > > > > > terminator.
> > > > > >
> > > > > > Anyway, yes. Some sort of HSPEAK-implemented shortcut syntax for
> > > > > > building strings would be cool, as long as it can be done in a way that
> > > > > > doesn't break compatability with existing scripts (not too badly,
> > > > > > anyway ;)
> > > > > >
> > > > > > Perhaps a syntax like:
> > > > > >
> > > > > >   $N$line of text
> > > > > >
> > > > > > Which would be easy to identify and parse in HSPEAK, and does not look
> > > > > > like any existing commonly used symbols. It would cause problems for
> > > > > > anybody who already has symbols that start with $25$ or something like
> > > > > > that, but I think that will be a fairly small slice of the
> > > > > > plotscript-writing population.
> > > > > >
> > > > > > A disadvantage of note, is the fact that however we might implement a
> > > > > > string syntax in HSPEAK, there will be a problem with including , and )
> > > > > > and ( characters
> > > > > >
> > > > > > > I like the textbox idea. That would be an easy way to have constants.
> > > > > > > However, I don't know about embedding the meta-strings into any
> > > > > > > string. For example, what happens in this situation:
> > > > > > >
> > > > > > > Hero #1's name: ${H2}
> > > > > > > Hero #2's name: ${H1}
> > > > > > >
> > > > > > > or even:
> > > > > > >
> > > > > > > Hero #1's name: ${H1}
> > > > > >
> > > > > > Recursive strings can be limited. Both those cases would result in a
> > > > > > hero who's name in the game actually displays as the text ${H1}.
> > > > > > In fact, limiting strings to one level of substitution is actually
> > > > > > easier than implementing the problematic recursive case.)
> > > > > >
> > > > > > > >> the string inside a variable is totally different, but doable
> > > > > > > thing.  why not build the string
> > > > > > > >> using the buildstring(num,type), and then instead of setting asside
> > > > > > > globals, you could
> > > > > > > >> just put inside a textbox an entire string.  and yes, I know about
> > > > > > > the numeric variable
> > > > > > > >> inside textbox, I wanted to implement that too. but I haven't
> > > > > > > bothered looking into a
> > > > > > > >> textbox code.
> > > > > > > >>
> > > > > > > >> and on the other note, we could make array of 255 or more size
> > > > > > > 40(or whatever amount
> > > > > > > >> of characters fits the entire line inside ohr) strings.  inside of
> > > > > > > memory its gonna   take up
> > > > > > > >> to 10k(each character takes one byte I assume) if its 255 strings.
> > > > > > >
> > > > > > > I'm not sure what you're saying here.
> > > > > > >
> > > > > > > >> anyway, this is actally the first attemp into adding strings into
> > > > > > > ohr. it may not be the
> > > > > > > >> best solution but at least its something.
> > > > > > >
> > > > > > > Agreed. However, I doubt the OHR will ever support real strings, so we
> > > > > > > need to take what we have!
> > > > > > >
> > > > > > > >> and mike, what OS are you running that you cannot compile ohr?  I
> > > > > > > am running ME and
> > > > > > > >> it compiles fine for me.
> > > > > > >
> > > > > > > I am running Windows 2000 (on my main computer) and Windows XP (on my
> > > > > > > other computer). I have no clue why it won't compile. However, on the
> > > > > > > Windows 98 computer in the Yearbook lab at school, I can compile it
> > > > > > > fine. However, I don't usually have access to it for extended periods
> > > > > > > of time, so it's not very convenient for development...
> > > > > > >
> > > > > > > On 4/21/05, Bob the Hamster <Bob at hamsterrepublic.com> wrote:
> > > > > > > > Cool. I am glad to see people thinking about strings. I had originally
> > > > > > > > dismissed them as impractical, but I am reconsidering that stance.
> > > > > > > >
> > > > > > > > However, I would prefer to do strings differently. Building strings from
> > > > > > > > a series of plotscripting commands adding ascii characters one-by-one
> > > > > > > > would be a big pain. For simple things it would work, but for anything
> > > > > > > > elaborite, it would make for horribly complicated scripting (and you
> > > > > > > > just know somebody would want to make a whole game using strings for
> > > > > > > > everything, in some bizzare way that none of us would ever thing about)
> > > > > > > >
> > > > > > > > So here is what I propose.
> > > > > > > >
> > > > > > > > There would be a certain number of "String Registers". We will say 32 of
> > > > > > > > them. You could manipulate them with plotscripting commands similar to
> > > > > > > > what Draknight is suggesting:
> > > > > > > >
> > > > > > > >   show string (string ID)
> > > > > > > >   clear string (string ID)
> > > > > > > >   append ascii (string ID, ascii code)
> > > > > > > >   append number (string ID, number)
> > > > > > > >
> > > > > > > > And these strings could be embedded into text boxes using the ${S#} that
> > > > > > > > Mike suggests.
> > > > > > > >
> > > > > > > > Now, how about better ways to work with strings than "append ascii" and
> > > > > > > > "append number"?
> > > > > > > >
> > > > > > > >   copy string (source string ID, dest string ID)
> > > > > > > >   concatenate strings (source string ID, dest string ID)
> > > > > > > >   string length (string ID)
> > > > > > > >   replace char (string ID, position, ascii)
> > > > > > > >   delete char (string ID, position)
> > > > > > > >   ascii from string (string ID, position)
> > > > > > > >   string to globals (string ID, starting global ID, length)
> > > > > > > >   globals to string (string ID, starting global ID, length)
> > > > > > > >
> > > > > > > > I think those would be sufficient to to all the string manipulation you
> > > > > > > > would want. More complicated string manipulation could be done with
> > > > > > > > wrapper scripts.
> > > > > > > >
> > > > > > > > Okay, but here is where it gets cool.
> > > > > > > >
> > > > > > > >   string from text box (string ID, text box, line)
> > > > > > > >
> > > > > > > > So you could make a text box that says:
> > > > > > > >  ------------------------
> > > > > > > >  North
> > > > > > > >  East
> > > > > > > >  South
> > > > > > > >  West
> > > > > > > >  -----------------------
> > > > > > > > And then you could say:
> > > > > > > >
> > > > > > > >   string from text box (0,N,hero direction(me))
> > > > > > > >
> > > > > > > > And it would fill string 0 with the textual value of the hero's current
> > > > > > > > direction. There could be similar commands for other strings:
> > > > > > > >
> > > > > > > >   string from hero name (string ID, hero position)
> > > > > > > >   string from enemy name (string ID, enemy ID)
> > > > > > > >   string from map name (string ID, map ID)
> > > > > > > >
> > > > > > > > All these commands are a little bloaty, but fortunately each of them can
> > > > > > > > be implemented with very little quickbasic code, so overall the memory
> > > > > > > > usage shouldn't rise too much to be a problem.
> > > > > > > >
> > > > > > > > Another closely related idea is the possibility to embed ${?#} into
> > > > > > > > other types of text besides text boxes. For example, being able to put
> > > > > > > > ${H#} into hero names would create interesting possibilities, such as a
> > > > > > > > way to seamlessly replace a custom-named young hero with an older
> > > > > > > > version of himself who has different abilities.
> > > > > > > >
> > > > > > > > ---
> > > > > > > > James Paige
> > > > > > > >
> > > > > > > > On Thu, Apr 21, 2005 at 05:04:26PM -0400, Mike Caron wrote:
> > > > > > > > > It seems like an interesting idea, but you can do just about anything
> > > > > > > > > with the textboxes already. You store the numbers in globals, and then
> > > > > > > > > use a text box with the ${V#} meta-string.
> > > > > > > > >
> > > > > > > > > Now, if you wanted to put variable text into a text box, that's
> > > > > > > > > different. I think that this might be a more practical (and OHRistic)
> > > > > > > > > solution:
> > > > > > > > >
> > > > > > > > > The plotscripter sets aside a couple globals. 20 should be fine. Or,
> > > > > > > > > maybe some globals are set aside for him as a "text buffer" or
> > > > > > > > > something.
> > > > > > > > >
> > > > > > > > > Then, there's a textbox meta string ${S#} (or just ${S} if the buffers
> > > > > > > > > are pre-made) or something. The interpreter, upon encountering this
> > > > > > > > > meta-command, would then read the globals, starting from #, and
> > > > > > > > > interpreting the globals as character values. It would stop when it
> > > > > > > > > encounters a 0.
> > > > > > > > >
> > > > > > > > > I think this is a more elegant and customizable solution, as to use
> > > > > > > > > it, you would just need to set a couple globals before showing the
> > > > > > > > > text box. If the buffers are set aside for you, so as not to infringe
> > > > > > > > > on your regular globals, then you would use the ${S} command, and
> > > > > > > > > maybe "set string(num,val)" or some such command.
> > > > > > > > >
> > > > > > > > > On the flip side, it would be more difficult to implement, and it's
> > > > > > > > > not already done. Perhaps we could do both. "build string()" now, and
> > > > > > > > > the ${S#} meta-string in the next version. I myself would implement
> > > > > > > > > the meta-string (repeat after me!) if-I-could-compile-the-OHR.
> > > > > > > > >
> > > > > > > > > On 4/21/05, Draknight2 at wmconnect.com <Draknight2 at wmconnect.com> wrote:
> > > > > > > > > > ok, I have an idea for 3 new plotscripting commands, they all have to do
> > > > > > > > > > with strings.
> > > > > > > > > >
> > > > > > > > > > 1. buildstring(number,type) where type is either 0, ascii character, or 1
> > > > > > > > > > number.  basically what it does is lets you build the string of any size.
> > > > > > > > > > 2. showstring: displays the string where showvalue normally shows number.
> > > > > > > > > > 3. clear string:  clears that string.
> > > > > > > > > >
> > > > > > > > > > I already implemented and tested it, and it works great, haven't run into a
> > > > > > > > > > problem yet.  now I know you can display the text into a textbox, but this
> > > > > > > > > > is for the advanced plotscripters who might find a use for this one, I
> > > > > > > > > > already see one use for it, and it has to do with displaying characters to
> > > > > > > > > > the string.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > example: in dragon warrior, there is this item called Lora's Love, which
> > > > > > > > > > basically displayes your coordination from the main castle.  like if you are
> > > > > > > > > > in the north east, it would say something like "I am 2 to the North, and 3
> > > > > > > > > > to the east of you.  now all this would have to use up like up to 8
> > > > > > > > > > textboxes.  with show string, it will only take one textbox(if you want),
> > > > > > > > > > and thats it.  It will take couple lines of code to do so.
> > > > > > > > > > example of the above commands.
> > > > > > > > > > script,showlocation,begin
> > > > > > > > > > buildstring(78,0)#this 0 indicates thats its ascii character 78 indicates
> > > > > > > > > > ascii character number
> > > > > > > > > > buildstring(58,0)
> > > > > > > > > > buildstring(32,0)
> > > > > > > > > > buildstring(3,1)#this 1 indicates thats its the actual number
> > > > > > > > > > buildstring(32,0)
> > > > > > > > > > buildstring(69,0)
> > > > > > > > > > buildstring(58,0)
> > > > > > > > > > buildstring(32,0)
> > > > > > > > > > buildstring(300,1)
> > > > > > > > > > showstring#shows the message N: 3 E:300
> > > > > > > > > > clear string#clears the string
> > > > > > > > > > shownovalue#clears the message
> > > > > > > > > > end
> > > > > > > > > >
> > > > > > > > > > so, as you can see, very useful little command.
> > > > > > > > > > however I am not sure how, but it would be even better if showstring would
> > > > > > > > > > have x,y coordinates to put the string anywhere on the screen.  but for now,
> > > > > > > > > > my knowledge of how scriptout$ works is very limited.
> > > > > > > > > >
> > > > > > > > > > well tell me what you think, I will get subversion and make patch for this
> > > > > > > > > > code, and probably extra file need to be created for letters and keyboard
> > > > > > > > > > character values.
> > > > > > > > > > sort of like scancodes.hsi, only asciicodes.hsi
> > > > > > > > > > (short example)
> > > > > > > > > > define constant, begin
> > > > > > > > > > 78,char:N
> > > > > > > > > > end
> > > > > > > > > > _______________________________________________
> > > > > > > > > > Ohrrpgce-motherhamster.org mailing list
> > > > > > > > > > ohrrpgce at lists.motherhamster.org
> > > > > > > > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Mike Caron
> > > > > > > > > Final Fantasy Q
> > > > > > > > > http://finalfantasyq.com
> > > > > > > > > _______________________________________________
> > > > > > > > > Ohrrpgce-motherhamster.org mailing list
> > > > > > > > > ohrrpgce at lists.motherhamster.org
> > > > > > > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > > > > > > _______________________________________________
> > > > > > > > Ohrrpgce-motherhamster.org mailing list
> > > > > > > > ohrrpgce at lists.motherhamster.org
> > > > > > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Mike Caron
> > > > > > > Final Fantasy Q
> > > > > > > http://finalfantasyq.com
> > > > > > _______________________________________________
> > > > > > Ohrrpgce-motherhamster.org mailing list
> > > > > > ohrrpgce at lists.motherhamster.org
> > > > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > > > >
> > > > >
> > > > > --
> > > > > Mike Caron
> > > > > Final Fantasy Q
> > > > > http://finalfantasyq.com
> > > > > _______________________________________________
> > > > > Ohrrpgce-motherhamster.org mailing list
> > > > > ohrrpgce at lists.motherhamster.org
> > > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > > >
> > > > _______________________________________________
> > > > Ohrrpgce-motherhamster.org mailing list
> > > > ohrrpgce at lists.motherhamster.org
> > > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > > _______________________________________________
> > > Ohrrpgce-motherhamster.org mailing list
> > > ohrrpgce at lists.motherhamster.org
> > > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> > >
> > _______________________________________________
> > Ohrrpgce-motherhamster.org mailing list
> > ohrrpgce at lists.motherhamster.org
> > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
> _______________________________________________
> 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