using arguments (for custom textboxes) and jibberjabber

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

Moderators: marionline, SDHawk

Post Reply
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

using arguments (for custom textboxes) and jibberjabber

Post by SwordPlay »

could someone briefly take me through using arguments?
EDIT: Did I already ask about arguments? I forget. Probably because it's Ramadhan :p

(As a side note, this could also be used on the wiki to explain plotscripting a little bit (possibly))


I want to take a textbox number as an argument, turn it into a string, then put it into a text slice?
I also want to use optional arguments to change how the slice will be laid out.
I also want to be able to call and display a graphic as an argument.

Should I use pre-set arrangements and load them?
If I want to change settings (such as text outline, wrap, or have the text slice display on a rectangle) it would be much easier to do within the slice editor I feel.

I want to do something like this:

...
...
...

Code: Select all

Call:
  "textslice (46, R, heroangry)"

plotscript, textslice, textbox, direction, image, begin

suspend player, suspend npcs

##(if argument direction = L,R,U,D, load the appropriate arrangement)

variable(txtbx)
txtbx := (load or create a slice or arrangement of slices)

##(I would like it if there were different arguments corresponding to the different sprite types, so they could be called and loaded simply, like "s32=small enemy 32", "h9=hero 9"

variable(img)
img := (load or create the sprite)

textbox text (string ID, 46, expand)
set slice text(txtbx, string id)

wait for key (any key)
free slice (txtbx)
free slice (img)
resume player, resume npcs
...
...
...


I'm not sure if this has much point, textboxes are going to be overhauled at some point, right?
Still, someone can preconfigure slices to make "textboxes" (slice collections) appear however they wish, including images for the textbox background, text colour etc.,)

I'm still a little unsure how to use arguments, so maybe if this goes well it can be added to the wiki as a plotscript teaching guide?

As a side note, I would like to be able to call a script that can transform slices, with arguments for its speed, rate, size, etc., or to have a utility script that quickly loads slices.

something like:
"plotscript, expand, target slice, final size, steps, ticks, begin"


Another idea might be a slice that clips or obscures another slice and reveals it over time, with various arguments.
"plotscript, reveal, target slice, direction, speed, begin"

Another idea might be to call a script to create a multiple choice menu of some kind. It could take the options(text) and effects(tag) as arguments.
"plotscript, options, option1, tag1, option2, tag2, etc., etc., begin"

It would probably be a pain to manage lots of slices without handles, but one might get around it by freeing all slices and reloading them to keep the correct ones displayed. Dunno.

It's not a big deal or important, I'm just curious and it could provide potential fodder for wiki tutorials re: scripting and especially slices.

These are just some vague-ish ideas. I'm far more interested in having select slices cycle through their children forward, backwards and cyclically and adding appearance/disappearance animations to various slices.
I would like if text slices could appear a letter at a time, for instance.

Sorry, rambling. Excuse me. I also didn't want to clog up the request thread. I know that animations are not planned for other than sprite slices.
Last edited by SwordPlay on Sat May 27, 2017 6:29 pm, edited 2 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Arguments are special local variables, which get an initial value from the place that the script is called or triggered. You can also make arguments optional by giving them default values, like so:

Code: Select all

script, buy item, item id, how many = 1, begin
 ...
Warning: default values are ignored when the engine triggers a script, instead default values of 0 are used.

For example if you want to add an argument to optionally show a portrait, add a "portrait" argument and make it default to -1. Then do "if (portrait <> -1) then ( #load the portrait"

Normally you would use the existing constants up, left, right, down, to specify a direction. If you wanted, you could define new constants U, D, L, R.

Don't wait around for the textbox overhaul! It might still take a long time. You can do lots of stuff now by scripting your own textboxes, either from scratch, or by modifying the slices of a normal textbox. Defining a template for the box appearance as a slice collection of course makes sense.
I want to take a textbox number as an argument, turn it into a string, then put it into a text slice?
Luckily, Wendigo recently added a new script command to get the text of a textbox: "textbox text".
Last edited by TMC on Sun May 28, 2017 11:55 am, edited 2 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

##(I would like it if there were different arguments corresponding to the different sprite types, so they could be called and loaded simply, like "s32=small enemy 32", "h9=hero 9"
Oh, also, to specify an arbitrary sprite set, use two argument: the spriteset type and the spriteset ID. So "my script(spritetype:smallenemy, 32)".

I've just added a new command (actually a script), loadsprite, to make that easy. It's just a wrapper around the load...sprite commands. I could have sworn that that command was on the wiki somewhere; so I added it.
It would probably be a pain to manage lots of slices without handles, but one might get around it by freeing all slices and reloading them to keep the correct ones displayed. Dunno.
Do what the engine does: use lookup codes.
Post Reply