Print Room description from a Script

Millie Jonasen
21 Apr 2019, 13:20

I want to keep the page tidy and remove actions but keep the room description displayed. How do I print the current rooms description to a page from a script?


mrangel
21 Apr 2019, 15:54

You can call the function ShowRoomDescription to show the current room description.


Millie Jonasen
21 Apr 2019, 20:06

Ah, that works, thankyou! :D

I did that with the Call function box in a script, I tried it in a Print expression box but that didn't work for me.
How would I use it there or can I not?


hegemonkhan
21 Apr 2019, 22:39

using GUI/Editor's the 'call function' Script (calling/doing/activating the built-in 'ShowRoomDescription' Function), in code (using a 'Function' Element as an example, and using the 'start' Script of the 'game' special/required Game Settings and Publishing Info Object/Element to call the 'example_function' Function in my example below. This is a special Script (Script Attribute), which is the first thing that is done/run/executed/activated when the game play begins):

'game' Object -> 'Script' Tab -> the 'start' Script -> add new script -> 'call a function' Script -> Name: example_function // or (if syntax doesn't work): Name: example_function ()

add/create Function -> Name: example_function -> add new script -> 'scripts' section/category -> 'call a function' Script -> Name: ShowRoomDescription // or (if syntax doesn't work): Name: ShowRoomDescription ()

<game name="NAME_OF_YOUR_GAME">

  <attr name="start" type="script">

    example_function
    // or (if the above syntax doesn't work):
    // example_function ()

  </attr>

</game>

<function name="example_function">

  ShowRoomDescription
  // or (if the above syntax doesn't work):
  // ShowRoomDescription ()

</function>

using the 'print message' Script (calling/doing/activating the built-in 'ShowRoomDescription' Function), in code (using a 'Function' Element as an example):

'game' Object -> 'Script' Tab -> the 'start' Script -> add new script -> 'call a function' Script -> Name: example_function // or (if syntax doesn't work): Name: example_function ()

add/create Function -> Name: example_function -> add new script -> 'output' category/section -> 'print a message' Script -> (see below)

print [EXPRESSION] ShowRoomDescription
// or (if the above syntax doesn't work):
print [EXPRESSION] ShowRoomDescription ()

<game name="NAME_OF_YOUR_GAME">

  <attr name="start" type="script">

    example_function
    // or (if the above syntax doesn't work):
    // example_function ()

  </attr>

</game>

<function name="example_function">

  msg (ShowRoomDescription)
  // or (if the above syntax doesn't work):
  // msg (ShowRoomDescription ())

</function>

// the print '[MESSAGE]' command ONLY allows for text (strings):
// msg ("hi")

// whereas, the print '[EXPRESSION]' command allows for:
//
// just text (strings):
// msg ("hi")
// or
// just VARIABLES:
// (using an 'Attribute' VARIABLE for the example below)
// create ("example_object")
// example_object.example_string_attribute = "hi"
// msg (example_object.example_string_attribute)
// or
// just Functions:
// msg (ShowRoomDescription)
// or (if syntax above doesn't work):
// msg (ShowRoomDescription ())
// or
// whatever combination you want, for examples:
//
// msg ("Room Descriptions: " + ShowRoomDescription)
// or (if syntax above doesn't work):
// msg ("Room Descriptions: " + ShowRoomDescription ())
//
// create ("example_object")
// example_object.example_string_attribute = "hi"
// msg ("Greeting String/Text: " + example_object.example_string_attribute)
//
// create ("example_object")
// example_object.example_string_attribute = "hi"
// msg ("Greeting String/Text: " + example_object.example_string_attribute + ", and Room Descriptions: " + ShowRoomDescription)
// or (if syntax above doesn't work):
// msg ("Greeting String/Text: " + example_object.example_string_attribute + ", and Room Descriptions: " + ShowRoomDescription ())

mrangel
21 Apr 2019, 23:38

I did that with the Call function box in a script, I tried it in a Print expression box but that didn't work for me.
How would I use it there or can I not?

You can't.

ShowRoomDescription() already has the msg (print expression) code built in. You can't separate them. So you call it using "Call function" and it sends output to the screen.

There is a way to intercept the output so that you can modify it before it's printed, but that method is really complex and not a good idea unless there's really no alternative.


hegemonkhan
22 Apr 2019, 00:48

wow, didn't realize that! (my apologizes for my previous post, wrongly stating/showing that it can be done, whoopsy --- due to being lazy, I don't test things, and thus get burned and confuse people with wrong assumptions in my posts)

(you can do some other/"normal" Functions/Scripts within the 'msg' Script/Function, just not the 'ShowRoomDescription' as mrangel explained to us, and corrected me on it)


DarkLizerd
22 Apr 2019, 03:47

OR... (And that's my specialty…)
Don't put your room description IN the room description box.
(I assume this is Quest, But T.E. only, not gamebook...)
(sub-or)
Change the Description [Text] to Description [Run script]
and describe the room with:
msg("You have entered the room, but everything is too dark to see!")
then you can have some code to tweek what the person sees or finds...
(original-or)
on the Scripts tab, you could describe the room in the Before entering the room, as msg("there")
You can even add bits for that happens when the player enters the room for the first time,
like... msg("the light bulb flashed brightly for a second before going out for good...")