How do I update dialogue through slice collection?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

I'm inclined to agree with Bob here. I thought it sounded inefficient, but it actually wouldn't be much harder than creating and editing new actual textboxes.

@bis_senchi, I recommend you disregard everything I've said up until now and make the text boxes manually, rather than with scripting.

Since you can copy and paste slices, this shouldn't be too difficult or even that tedious.

First, make the first Container slice a child of the first Rectangle slice.

Next, select the Rectangle slice with the cursor and press CTRL+C.

Then, move to the next empty slice collection and press CTRL+V.

Now you have the template for your textboxes saved in Slice Collection 5. Every time you make a new text box, copy the Rectangle slice from Slice Collection 5 and paste it into the next empty slice collection.

For each new textbox, simply edit each sprite in the Grid to be the appropriate character and palette. In order to load one of these textboxes, all you will need to do is call 'load slice collection(id)' in a script, where 'id' is the specific collection that has the textbox you want.

This will be just as effective as storing the text somewhere else and less complicated, too.
My pronouns are they/them
Ps. I love my wife
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

How does child count work

Post by bis_senchi »

Thanks for you answer. I'll get back to my first idea and use slice codes. There are a lot of slice lookp up code avaliable and I only need 42 of them.
Slice code allow me to do exactly what I would like to before starting to search for another way
to save up some of them.

Just like tags or strings, you need to know when (you really need) to use them while implementing a gameplay. They have been made for that!

I still have trouble to undertand how child count works. Let's say that there a slice collection menu. One of the sub menu is composed of various text, a cusor sprite, a rectangle and text line (for menu names) like the one I've made in my post last september.

Let's say it's a battle menu that the player uses to make the hero attack.
So in the slice tree you would something like

battle ground pic/ background 320.200 image

hero 1 pic
-> selected/ unselected sprite

[...]


<--- hero 1 attack menu-->
Rectangle
container
sub menu cursor
Attack
Defend
Items
run

How to I use child count and other plotscript commands to access all the elements of my slice collection? Again, slice look up code would be useful in this case.

You also need to take into account that the menu appears when the key is pressed and disappears when the battle turn is validated... How you kylekrack would tackle this "problem"?

A always thanks in advance for your help kylekrack and also thank to Bob The Hamster for noticing that those coding attempts were heading the wrong direction.
Last edited by bis_senchi on Sat Jan 30, 2021 8:44 am, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

you could code a japanese text generator in the engine, that can export the japanese text (as a slice collection) for using in menus and textboxes.
you can have a kanji selector, for example, and some gui tools like mode toggle for hira/kata and so on.

it may be easier if you are not confident in scripting everything directly

to access the element of your slice collection:

- assign a lookup to a slice so you can get its handle
- store the handle of a slice in a (global) variable
https://hamsterrepublic.com/ohrrpgce/ni ... g%20Slices
(most of these commands return the handle of a slice which you can store in a variable)

- after getting the parent, you can access the children with various commands
https://hamsterrepublic.com/ohrrpgce/ni ... ice%20Tree
Last edited by SwordPlay on Sat Jan 30, 2021 8:53 am, edited 1 time in total.
"Imagination. Life is your creation."
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

i have a prototype working, it reads a string in romaji, but its not finished yet

you can write in Capital letters/Upper Case for Katakana or Lower Case for Hiragana, but I need to add the katakana glyphs

a bit difficult to add dakuten/handakuten and case for ...y... cluster (rya, gya, nya... etc.,) but its basically added

then i will add a way to change palette perhaps, and then later a way to write kanji if i can figure it out
Attachments
supposed to say &amp;quot;aeiou kakekikoku naneninonu nnn baba gyu pu bu&amp;quot; but it doesnt handle &amp;quot;n&amp;quot; and &amp;quot;gyu&amp;quot; properly
supposed to say &quot;aeiou kakekikoku naneninonu nnn baba gyu pu bu&quot; but it doesnt handle &quot;n&quot; and &quot;gyu&quot; properly
Japanese Font0003.png (1.99 KiB) Viewed 3498 times
this is just a test. it works kinda
this is just a test. it works kinda
Japanese Font0000.png (1.95 KiB) Viewed 3499 times
it supposed to say domo arigatou gozaimasu, but its broken :P
it supposed to say domo arigatou gozaimasu, but its broken :P
Japanese Font0001.png (1.67 KiB) Viewed 3499 times
Last edited by SwordPlay on Sat Jan 30, 2021 11:04 am, edited 1 time in total.
"Imagination. Life is your creation."
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

WARNING: Very broken messy and incomplete. Feel free to use whatever you like.
you need to import the box border sets into the right place, or offset it in the code

Sorry I didn't do a good job, I'm so very tired right now. I might come back to this later on.

Code: Select all

global variable&#40;1000, Scons&#41;
global variable&#40;1001, Cons&#41;
global variable&#40;1002, Vowel&#41;
global variable&#40;1003, Dak&#41;
global variable&#40;1004, Y&#41;
global variable&#40;1005, Modal&#41;

# you can run this script to test it out.
plotscript, test j text, begin
#$1="nandeyo baka shitenjiryo soka mashunembupi aabarai oo noomi kaazekii"
$1="nani nandeyo nannonekinin"
process string&#40;1&#41;
end

    # vowel list
define constant&#40;0, eVwl&#41; # special case for N
define constant&#40;1, AV&#41; # 0
define constant&#40;2, IV&#41; # 8
define constant&#40;3, UV&#41; # 20
define constant&#40;4, EV&#41; # 4
define constant&#40;5, OV&#41; # 14

    # consonant list. their ascii number and offset
define constant&#40;0, VC&#41; # just a vowel
define constant&#40;1, KC&#41; # 75 107... 10 AND G AND GY
define constant&#40;2, SC&#41; # 83... 18   AND Z AND J

define constant&#40;3, TC&#41; # 84... 19 AND D AND DJ
define constant&#40;4, NC&#41; # 78... 13
define constant&#40;5, HC&#41; # 72... 7 AND B AND P AND BY AND PY

define constant&#40;6, MC&#41; # 77... 12
define constant&#40;7, RC&#41; # 82... 17

define constant&#40;8, YC&#41; # 89... 24
define constant&#40;9, WC&#41; # 87... 22
define constant&#40;10, N&#41; # 78 again... 13



# ascii codes
# 65 to 90 is capitals... hiragana
# 97 to 122 is lower case... katakana


plotscript, process string, str, begin
    # will contain the new japanese text sprites
variable&#40;grid&#41;
grid&#58;=create grid&#40;320,200&#41;
set grid rows&#40;grid,10&#41;
set grid columns&#40;grid,16&#41;

    # this is data read from the ascii string &#40;input&#41;
variable&#40;cas,offset&#41; 
# upper and lower case from 65 and 97 respectively
# offset to the letter from 

variable&#40;pos,i,ascii&#41; # position in string while reading it

for&#40;pos,1,string length&#40;str&#41;,1&#41;do&#40;
ascii&#58;=ascii from string&#40;str,pos&#41;

# exit script when no more ascii to read
IF&#40;ascii==0&#41;THEN&#40;exit returning&#40;grid&#41;&#41;

# a space. end the cluster start a new one
ELSEIF&#40;ascii==32&#41;THEN&#40;
set parent&#40;create container,grid&#41;
cons&#58;=0,vowel&#58;=0,dak&#58;=0,y&#58;=0
&#41; # insert a space

IF&#40;97>=ascii && ascii>=65&#41;THEN&#40;cas&#58;=65&#41;
IF&#40;122>=ascii && ascii >=97&#41;THEN&#40;cas&#58;=97&#41;
show value&#40;cas&#41;

# create a branch if stored consonant is special...
VARIABLE&#40;sscons&#41;

sscons&#58;=scons
scons&#58;=cons
cons&#58;=0
vowel&#58;=0

switch&#40;ascii--cas&#41;do&#40;
case&#40;0&#41;
do&#40;vowel&#58;=AV&#41;
case&#40;8&#41;
do&#40;vowel&#58;=IV&#41;
case&#40;20&#41;
do&#40;vowel&#58;=UV&#41;
case&#40;4&#41;
do&#40;vowel&#58;=EV&#41;
case&#40;14&#41;
do&#40;vowel&#58;=OV&#41;


case&#40;10&#41; # K
do&#40;cons&#58;=KC&#41;
case&#40;6&#41; # G
do&#40;cons&#58;=KC,dak&#58;=1&#41;

case&#40;18&#41; # S
do&#40;cons&#58;=SC&#41;
case&#40;9&#41; # J
do&#40;cons&#58;=SC,dak&#58;=1,y&#58;=1&#41;
case&#40;25&#41; # Z
do&#40;cons&#58;=SC,dak&#58;=1&#41;

case&#40;19&#41; # T
do&#40;cons&#58;=TC&#41;
case&#40;3&#41; # D
do&#40;cons&#58;=TC,dak&#58;=1&#41;

case&#40;13&#41; # N
do&#40;cons&#58;=NC&#41;

case&#40;7&#41; # H
do&#40;cons&#58;=HC&#41;
case&#40;1&#41; # B
do&#40;cons&#58;=HC,dak&#58;=1&#41;
case&#40;15&#41; # P
do&#40;cons&#58;=HC,dak&#58;=2&#41;

case&#40;12&#41; # M
do&#40;cons&#58;=MC&#41;
case&#40;17&#41; # R
do&#40;cons&#58;=RC&#41;
case&#40;24&#41; # Y
do&#40;cons&#58;=YC&#41;
case&#40;22&#41; # W
do&#40;cons&#58;=WC&#41;

&#41;

variable&#40;spr&#41;
IF&#40;vowel&#41;THEN&#40; # the end of the cluster
IF&#40;scons==yc&#41;THEN&#40;
spr&#58;=find char&#40;sscons,vowel,dak,1,modal&#41;
&#41; # a ...y... case
ELSE&#40;spr&#58;=find char&#40;scons,vowel,dak,0,modal&#41;&#41;
&#41;
ELSE&#40;
IF&#40;scons==NC&#41;THEN&#40;spr&#58;=find char&#40;cons,-1,0,0,modal&#41;&#41; # N Case
&#41;
IF&#40;spr&#41;THEN&#40;
set parent&#40;spr,grid&#41;,
spr&#58;=0, 
cons&#58;=0,vowel&#58;=0,dak&#58;=0,y&#58;=0&#41;

# vowel with no consonant before it. push!
# 2 consonants in a row! this is for nY- cases. push!
# consonant and vowel! push!
# consonant and no vowel! push Except "N"

# dont check N first. it doesnt appear at the front of words

# maximum case. dak. + Y
# special N case    
# special Y case
# cons on their own
# at the end. dak



&#41; # for each character in the string

subscript, wChar, where, begin # which car
return&#40;ascii from string&#40;str,pos+where&#41;&#41;
end

subscript, clcl, begin # clear cluster
cons&#58;=-1
vowel&#58;=-1
dak&#58;=-1
end

end

plotscript, find char, cnsnt, vwl, dakt, ym, mde, begin

variable&#40;sprset, frame, count&#41;

sprset&#58;=1
count&#58;=cnsnt
while&#40;count>0&#41;do&#40;count-=1, frame+=5&#41;
while&#40;frame>15&#41;do&#40;frame-=15,sprset+=1&#41;
frame+=&#40;vwl--1&#41;


IF&#40;vwl==-1 && cnsnt==NC&#41;THEN&#40;sprset&#58;=4,frame&#58;=10&#41;
variable&#40;spr&#41;

spr&#58;=load border sprite&#40;sprset&#41;
set sprite frame&#40;spr,frame&#41;


IF&#40;dakt&#41;THEN&#40;
variable&#40;d&#41;
d&#58;=load border sprite&#40;4&#41;
set sprite frame&#40;d,10+dakt&#41;
set parent&#40;d,spr&#41;
center slice&#40;d&#41;
&#41;
IF&#40;Ym&#41;THEN&#40;
variable&#40;yp&#41;
yp&#58;=load border sprite&#40;4&#41;
set sprite frame&#40;yp,frame&#41;
set parent&#40;yp,spr&#41;
center slice&#40;yp&#41;
set slice x&#40;yp,15&#41;
set sprite frame&#40;spr,IV&#41;
&#41;
set slice extra&#40;spr,0,cnsnt&#41;
set slice extra&#40;spr,1,vwl&#41;
set slice extra&#40;spr,2,frame&#41;

return&#40;spr&#41;

end
Attachments
Japanese Font boxborder set 1.bmp
Japanese Font boxborder set 1.bmp (2.12 KiB) Viewed 3493 times
Japanese Font boxborder set 2.bmp
Japanese Font boxborder set 2.bmp (2.12 KiB) Viewed 3493 times
Japanese Font boxborder set 3.bmp
Japanese Font boxborder set 3.bmp (2.12 KiB) Viewed 3493 times
Japanese Font boxborder set 4.bmp
Japanese Font boxborder set 4.bmp (2.12 KiB) Viewed 3493 times
Last edited by SwordPlay on Sat Jan 30, 2021 11:48 am, edited 3 times in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Accents through strings

Post by bis_senchi »

Thanks sword play for your offer but the solution I have I mind will work better for me.

Always linked to languages, I have another question. It's linked to string and
accents


end #end for the tag

Code: Select all

Global variable &#40;12, box&#41;	
#-------------------------------------------------------------------------
plotscript, Npc script, begin

switch &#40;dialogue update&#41;, do, begin

case &#40;0&#41;, do begin
$3= "Hello! How are you?"
show string at &#40;3, 10, 10&#41;
#slice is rect &#40;box&#41;	
box&#58;= create rect &#40;320, 35, 0&#41; #witdh, height style style number from 0 to 14,
#set slice x &#40;box, 10&#41;
#set slice y &#40;box, 10&#41;
set rect trans &#40;box, false&#41;

end #end for the case

end #end for the switch
end #end of the plotscript

#-------------------------------------------------------
Let's stay, I want to put in spanish. How are you? -> Hola ¿Que Tal?
If I write $"Hola ¿Que Tal?" there will problems with the ¿

The only way I know would be to write Hola ¿Que Tal? in a text box and use the string from textbox.I drew the fonts for spanish and no problems whatsoever when keying the text under custom.exe
But if need be, I would like to be able to, just like with the english language (with only a string and slice rectangle) to make it appear this on screen.

My question is the following, is there a way using scancode or the code custom.exe use for the font table (e.g char 97 => a) to be able to entre accents through strings. The font ¿ is on the
table so it shouldn't be impossible with a coding system to make it pass though a string...

As always thank you very much for your pieces of advice.
Last edited by bis_senchi on Sun Feb 07, 2021 3:44 pm, edited 1 time in total.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Text in the OHR will only be able to use the characters in the game's font. Eg. Edit Graphics > Edit Font. That page will show you what all the characters available are and what index number they have, from 32 - 255. If the character is not represented there, you will not be able to write it in the game.

As for how the script interpreter translates strings into the game font, I'm not sure.
My pronouns are they/them
Ps. I love my wife
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

Ascii characters and symbols

Post by bis_senchi »

Kylecrack
. That page will show you what all the characters available are and what index number they have, from 32 - 255.
-> that's what I'm asking about. I would like to know if you can use the index code in plotscripting.

In this example above I called them show index code and clear index code but you get
the idea.

A command with make appear one screen a font according to its place on the font table.
After some search, the command append ascii seems to be quite close to this.

If I could store a ascii into a string and make appear that would be perfect....

Code: Select all


Global variable &#40;12, box&#41;   
#-------------------------------------------------------------------------
plotscript, Npc script, begin

switch &#40;dialogue update&#41;, do, begin

case &#40;0&#41;, do begin

show index code &#40;144&#41; # display message Hola ¿Que Tal?" inde code 255 is ¿
show index code &#40;145&#41;

clear index code &#40;144&#41;
clear index code &#40;145&#41;

#slice is rect &#40;box&#41;   
box&#58;= create rect &#40;320, 35, 0&#41; #witdh, height style style number from 0 to 14,
#set slice x &#40;box, 10&#41;
#set slice y &#40;box, 10&#41;
set rect trans &#40;box, false&#41;

end #end for the case

end #end for the switch
end #end of the plotscript

#------------------------------------------------------- 
So has someone seen something like this in the plotscripting dictionnary? If not what
about making a submission for this?

I think developping such a command would be useful in case like the one I'm talking about. Languages apart you may want to be able to use the symbols you put in your font table directly on screen, without having to use a line of the text and put everything into a string.

As always thanks for answering so quickly!
Last edited by bis_senchi on Mon Feb 08, 2021 6:57 am, edited 3 times in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

i think thats a good idea. it would be cool to have a text code that loads symbols from the font table into strings... is that what you mean? so you can make a code like "[Q" for to load a specific ascii character like ¿
then when you want ¿ you write it like $="[Q Que pasa ?" and it will be read when you want to display it by another script that will replaces the [Q with ¿
actually you could just ask for the ascii codes like "[148" for number 148 in the font table
you could use another punctuation mark other then open bracket, or you could even add a closed bracket... like [n]. but this would result in an argument to make this optional
maybe it should be an unusual combination which users are unlikely to accidentally type... maybe like !{n or !.n or something like that


you could also assign your members of the font table as constants, so you can call them by name... !{UpsideDownQuestionMark or !{UQ or !{Que} or whatever
Last edited by SwordPlay on Tue Feb 09, 2021 3:10 am, edited 2 times in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

After some search, I wanna use append ascii

Post by bis_senchi »

Great news.

After some searches the command I was searching for already exists. It's called "append ASCII"
Combine with show string at, you can pick up and search for any font and make it appear on screen.

Code: Select all

switch &#40;dialogue advance&#41; do, begin

case &#40;0&#41; do, begin
suspend player
suspend npcs

append ascii &#40;10, 176&#41; #ascii 176 177 et 178 are spanish writing specifics é,¿,Ñ
show string at &#40;10, 10, 10&#41;
append ascii &#40;12, 177&#41; 
show string at &#40;12, 20, 10&#41;
append ascii &#40;13, 178&#41; 
show string at &#40;13, 30, 10&#41;

box&#58;= create rect &#40;320, 35, 0&#41; #1rst number witdh, 2nd number height, 3rd number style &#40;can take value ony from 0 to 14&#41;
set rect trans &#40;box, true&#41;
wait &#40;3&#41;

wait for key &#40;key&#58; space&#41;
if &#40;key is pressed &#40;key&#58; space&#41;&#41; then, begin
clear string &#40;10&#41;
clear string &#40;12&#41;
clear string &#40;13&#41;
free slice &#40;box&#41;

end #end for the if

Now my question has changed. I would like to use only a few strings and store a bunch of appended ascii and make them appear all the same time.

Let's take back the previous example. With the English sentence : 'Hello! How are you?" I use only one string $3= "Hello! How are you?"

To do the same with spanish, it appears that I have to use ascii because if I write
$3= "Hola ¿Que Tal?" the buffer won't work correctly.

To get the same result my current knowledge, I need to do this: append ascii one by one and show them one by one

Code: Select all

append ascii &#40;10, 72&#41; #letter H
append ascii &#40;11, 111&#41; #letter o
append ascii &#40;12, 108&#41; #letter l
append ascii &#40;13, 97&#41; #letter a
append ascii &#40;14, 176&#41; # sp font ¿
append ascii &#40;15, 81&#41; #letter Q
append ascii &#40;16, 177&#41; #letter u
append ascii &#40;17, 101&#41; #letter e
append ascii &#40;18, 116&#41; #letter t
append ascii &#40;19, 97&#41; #letter a
append ascii &#40;20, 108&#41; #letter l
append ascii &#40;21, 63&#41; #question mark

show string at &#40;10, 10, 10&#41; #show the above sentence on screen
show string at &#40;11, 20, 10&#41;
show string at &#40;12, 30, 10&#41;
show string at &#40;13, 40, 10&#41;
show string at &#40;14, 50, 10&#41;
show string at &#40;15, 60, 10&#41;
show string at &#40;16, 70, 10&#41;
show string at &#40;17, 80, 10&#41;
show string at &#40;18, 90, 10&#41;
show string at &#40;19, 10, 20&#41;
show string at &#40;20, 20, 20&#41;
show string at &#40;21, 30, 20&#41;

The problem is that for a simple phrase I used 11 strings for the spanish sentence instead
of only one for the english one.

I would like to create a system would use much less strings and get the same result
make appear a simple sentence with using a text box content.

I was thinking about using a global variable to store the value of the ascii with the command: ascii from string. (Each font is associated with a figure which is its place in the font table
so you may be able to store this value in a variable.)

This way, by using 11 variables instead of string, I can save up strings for other things.
you have 4095 global variables available but only 99 strings, so it's better this way...
But I don't see how to make ascii pile up in a string.

Code: Select all


variable &#40;spanish letter1, spanish letter2, spanish letter3&#41;

spanish letter&#58;= ascii from string &#40;10, 72&#41;  #string 10 is for appending ascii characters
spanish letter2&#58;= ascii from string &#40;10, 111&#41;
spanish letter3&#58;= ascii from string &#40;10, 118&#41;  

Could someone tell how to add several ascii characters in a single string, just like the
buffer does?

Thanks in advance for your help!
Last edited by bis_senchi on Tue Feb 09, 2021 7:01 am, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

I think you just do it like this:

Code: Select all

$3= "Hola "
append ascii &#40;3, 176&#41;
$3+"Que Tal?"
this makes it all appear in one string, i hope

append ascii adds the ascii to the end of a string.
so write whatever string you want as a string, then use append ascii on that string
then if you want to write more, use $+ to add more to the string
Last edited by SwordPlay on Tue Feb 09, 2021 1:36 pm, edited 1 time in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

It works! Thanks a lot!

Post by bis_senchi »

You idea worked... :) Thank you very much!

So you need to simple text and the command append ascii.... After all these questions
I can know make dialogues in whatever languages without even having to be afraid of the text box limitation!

My next question will be this time more linked with figures but still has to with appending and recording value

As my knowledge regarding slice collection has improved, I would like to embetter my card machine script.

Image

For thoses who don't don't the card machine in a yugioh game in a machine that game let you try for $1000 to enter a password. (The password is in a fact a number written in each card in real life)

A lot of password are recorded in the machine one for each card. There are now aroung 500 of them but I would like to focus on these three below first

For example

"Blue Eyes White Dragon" card number/ password 89631139
"Mystical Elf" card number/ password 15025844
"Hitostu-Me Giant" card number/password 76184692

Last year I try to made on using the command imput string and string compare but
it didn't have to the same quality of game design. So I would like another one which look like more the one I used while playing YuGiOh! Game

Code: Select all


global variable &#40;collection&#41;

plotscript, card machine version2, begin


if &#40;pay money&#40;1000&#41;&#41; then, begin

collection &#58;= load slice collection &#40;8&#41;

end, else, begin
	show text box &#40;55&#41; # Not enough money
	wait for text box

end #end of the if


end #end of the script

So the trickier part here is that you have to linked the fact the player press a figure (let's say 4)
the sprite palette changes (to notify on screen the action of the player) and appear in the correct place on the upper part (= the one in the red rectangle)

Other problem is that this number is part a series of 8 figures that have to be stored in a global variable and then check....

Any advise on where to start and what commands to use is more than welcomed!
Last edited by bis_senchi on Wed Feb 10, 2021 7:34 am, edited 1 time in total.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

You need to make a keypress handler plotscript in order to track inputs like that. Make the plotscript called keypress handler, then set it to the map's keypress handler script in the general map settings. The script should look something like this.

Code: Select all

plotscript, keypress handler, begin
    if&#40;keypress&#40;key&#58;1&#41;&#41; then&#40;pressNumber&#40;1&#41;&#41;
    if&#40;keypress&#40;key&#58;2&#41;&#41; then&#40;pressNumber&#40;2&#41;&#41;
    if&#40;keypress&#40;key&#58;3&#41;&#41; then&#40;pressNumber&#40;3&#41;&#41;
    if&#40;keypress&#40;key&#58;4&#41;&#41; then&#40;pressNumber&#40;4&#41;&#41;
    if&#40;keypress&#40;key&#58;5&#41;&#41; then&#40;pressNumber&#40;5&#41;&#41;
    if&#40;keypress&#40;key&#58;6&#41;&#41; then&#40;pressNumber&#40;6&#41;&#41;
    if&#40;keypress&#40;key&#58;7&#41;&#41; then&#40;pressNumber&#40;7&#41;&#41;
    if&#40;keypress&#40;key&#58;8&#41;&#41; then&#40;pressNumber&#40;8&#41;&#41;
    if&#40;keypress&#40;key&#58;9&#41;&#41; then&#40;pressNumber&#40;9&#41;&#41;
    if&#40;keypress&#40;key&#58;0&#41;&#41; then&#40;pressNumber&#40;0&#41;&#41;
end
The script "pressnumber" is whatever action you want pressing the key to take. Maybe it'd look something like

Code: Select all

script, pressNumber, number, begin
    if&#40;string length&#40;stringid&#41; >= 8&#41; then&#40;exit script&#41;
    append number&#40;stringid, number&#41; # stringid is the id of the string you're using to store the number
    set slice text&#40;texthandle, stringid&#41; # update the slice that displays the number
end
You can use the "append number" command to add numbers on the end of a string. Later, you can use "number from string" to compare what the player input against correct values.
My pronouns are they/them
Ps. I love my wife
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

you can see an example i have posted here.
feel free to look at the scripts. it is very messy though
I attempted to make this without global variables or lookups
https://www.slimesalad.com/forum/viewtopic.php?p=139275
Attachments
numpad0001.gif
numpad0001.gif (10.83 KiB) Viewed 3361 times
Last edited by SwordPlay on Wed Feb 10, 2021 8:33 pm, edited 5 times in total.
"Imagination. Life is your creation."
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

As always thanks for the pieces of advice

Post by bis_senchi »

Thanks for your script SwordPlay! I took a look and indeed the script look messy. But it seems to work, so I'll take it as back up. I'm more at ease with global variables and look up!

To KylerKrack, I have a little problem. When I include

Code: Select all

script, pressNumber, number, begin

    if&#40;string length&#40;stringid&#41; >= 8&#41; then&#40;exit script&#41;
    append number&#40;stringid, number&#41; # stringid is the id of the string you're using to store the number
    set slice text&#40;texthandle, stringid&#41; # update the slice that displays the number

end
Hspeak says:
expocted number but found number
Could you please what number is supposed to be? A constant? A variable?
On the plotscript dictionnary it is mentionned under the category
Math, Comparison, and Logic Operators

Is it a simple figure like 12, 58?

As always thanks everybody for their replies!
Last edited by bis_senchi on Thu Feb 11, 2021 6:32 am, edited 1 time in total.
Post Reply