Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2011-03-09 07:07:56

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Text strings

is there any way to store text stings? i've seen  level names being read from $LEVEL_NAME. is that a variable like any other?


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#2 2011-03-09 12:31:21

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Text strings

unfortunately no. these are predefined constants.

you'll need some smart trickery to store strings.

if you don't need variables to change, you can store constant strings in the .lng files (languages/ folder). then you can use some trickery to use them:

in the .lng file: (preferably in english.lng)

MYTEXT_1    "Hello, humans"
MYTEXT_2    "We come in peace"

in the .obj:

...
let $i=1
textout default 0 0 $MYTEXT_$i
let $i=2
textout default 0 50 $MYTEXT_$i
...

never tested it, but it should work. please let me know of any results you get.

Offline

#3 2011-03-09 21:06:19

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: Text strings

from my previous experiences, something like

$MYTEXT_$i

produced an error in the nanoparser, probably because of calling two variables in one.

i'll see if your tricks work


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#4 2011-03-09 21:17:29

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Text strings

KZR wrote:

from my previous experiences, something like

$MYTEXT_$i

produced an error in the nanoparser, probably because of calling two variables in one.

i'll see if your tricks work

it's because $MYTEXT_1 isn't a variable. nanocalc, the guy who solves the math formulas in scripts, does not know what $MYTEXT_1 is. He does know, however, what $i is.

only later, when calling textout and printing text to the screen, after doing all the math, the game will look in the .lng file for a MYTEXT_1 constant. It should work, give it a try. Please let me know of the results.

Offline

#5 2011-03-09 23:35:23

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: Text strings

no, what i meant was using a variable for numbering other variables.

for example i want to call $variable_1 and $variable_2 depending on the value of $number like:

$variable_$number

and if $number == 1 it uses $variable_1

unfortunately this does not happen, and that's what i was referring to in last post.


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#6 2011-03-10 00:34:07

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Text strings

did it work for texts?

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org