Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Is there a way to make a sign display the players name?

(1 edit)

Yeah, just include the value of global.player_name in the message.

Easiest way would probably be to make a new type of signpost (a child of the obj_signpost so it "just works" with the existing interaction code) whose interact_script is cis_npc_polyliner and then give it a new expression-typed variable "my_messages". For each sign you place you'd then give it a messages value like:

[tsprintf("This is %'s house!",global.player_name)]

(So it contains an array of strings, with only 1 value - this is different from just a regular string, since cis_npc_polyliner loops over the array of messages, so don't forget the []'s around it)

(The reason the default signpost doesn't work is that it has a string-type variable, so it'll just include the variable / tsprintf call as text instead of running the code. You could of course change it to expression-type in the base sign instead, but that breaks all existing signposts unless you manually add quotation marks around their text...)

(+1)

Your the best thank you.

i get this when i do what you sugested. 

Instance Code in Room: rm_overworld_5 at line 1 : invalid token '

Undefined variable 'This' referenced in room rm_overworld in instance inst_16EAE0C0's variable 'my_message'

Undefined variable 'is' referenced in room rm_overworld in instance inst_16EAE0C0's variable 'my_message'

Did you:

  1. turn it into an Expression variable?
  2. put quotes (") around the text?
  3. put square brackets ([ at the start, ] at the end) around the resulting string?

The error message makes it sound like it's trying to interpret plaintext (the stuff that's supposed to be in a string) as an expression so it sounds like you missed the quotes.

I copied exzactly what you had typed. Maby i missed where i need to change to an expresion var

It should look like this:

Thank you! found the problem i selected the parent as the sign not the overworld so the error was from the extra my_message being blank.  one other quick question. How do you format text to go to the next line? :>

Add \n where you want the newline. (A backslash followed by the letter n)

so now i get this.

You should change the interaction script to cis_polyliner. cis_oneliner uses a different variable (which has an empty message).

(+1)

I dont want to talk about it. Thanks cant belive i missed that