Question about time implementation

Mareus
I have a clock in my inventory and obviously that raises a slight problem because people will want to look at clock at different points in game. Is there a simple code one can use on the object to show what time is it, or is there a viable alternative that does not require messing with the library?

Also, if it is possible I would like to avoid real time in my game. I don't want for example to advance 5 minutes in game each time I do something. Rather I would like to simulate time by dividing one day into 5-6 parts based on where you are located (something like early morning you are at home, morning you are in school, midday you are having a school break, afternoon you are out doing stuff, evening you are home again, midnight you are out partying or something) and then based on that having my clock show 5-6 different numbers (6 for early morning. 9 for morning, 12 for midday, 15 for afternoon, 19 for evening and 0 for midnight)

One solution that came to my mind is having a code like if player in room A then clock is 7, if in room B, clock is 9, etc. However I am not sure how that would work through out the whole game, because you can usually go back from one room to another and I do not want my clock from jumping back and forth all the time. Perhaps there is a more elegant solution.

Thanks in advance.

jaynabonne
You could update the clock value on each room's "first enter". Then it will update the first time but not after that.

Mareus
jaynabonne wrote:You could update the clock value on each room's "first enter". Then it will update the first time but not after that.

Yes, but I will probably come into a situation later in the game where I might enter room A at midnight for example. The only thing that comes to mind is to make a copy of the room then. Or perhaps use object flags for that specific time. Thanks for your help again.

Silver
Implementing time in a game seems a headache for very little reward. Must be a nightmare keeping track of where its at and not having conflicting descriptions.

HegemonKhan
time (and date) can be very simple or very complex coding

---------

a simple time method, just one type of example:

hours (24 hrs~military time) and (total tally of) days only

Hour: (0-23)
Day: 0+

<turnscript name="global_turnscript">
<enabled />
<script>
game.hour_integer = (game.hour_integer + 1) % 24
if (game.hour_integer = 0) {
game.day_integer = game.day_integer + 1
}
</script>
</turnscript>


oops....

mareus wrote:I don't want for example to advance 5 minutes in game each time I do something.


okay, never mind... lol

---------

here's a simple way to do what you want:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="changedparent" type="script">
if (this.parent = room_1) {
clock.hour_string = "dawn (6:00 am)"
} else if (this.parent = room_2) {
clock.hour_string = "noon (12:00 am to pm)"
} // etc etc etc
</attr>
</object>


oops... again... lol

mareus wrote:and I do not want my clock from jumping back and forth all the time.


as, my above code will change the clock's time 'back and forth' everytime you change between the rooms you put into the above script block.

---------

if you want, you can just use Pixie's Clock Library (just have Pixie's clock library file in the same location as your 'quest.exe' file, and then add the library to your game file's code, I don't know if or how it's done in the GUI~Editor, but for in code, see below):

<asl version="550">
<ref name="English.aslx" />
<ref name="Core.aslx" />
<ref name="Pixie's Clock Library.aslx" />
<game name="blah">
// blah code lines
</game>
// blah code lines
</asl>

jaynabonne
Just a note, HK: If you override changedparent in your player, then you will disable the "enter room" scripts being called unless you invoke them yourself. The Quest core uses changedparent itself for that purpose. You're much better off using the "enter room" scripts yourself than overriding changedparent.

HegemonKhan
my bad, I'm far off from understanding a lot of the internal coding of how quest works~operates, sighs.

they can also use Turnscripts instead, for when the parent changes, correct? (though, simply using the 'enter room' would be easiest)

I chose to post the 'changed' coding as it's a bit simplier than using turnscripts for new people, otherwise, I'd have shown it with using a turnscript... if I known the 'changedparent' is used internally... argh.

Pertex
You could also use the new game/Script "Script when entering a room"

jaynabonne
Turnscripts happen after each turn. They're not related to the parent changing. :)

jaynabonne
...though I think I see what you mean: you could use a turnscript to globally track the player parent/room without having to modify each room.

(Pertex, is this handled by what you said has been added?)

Pertex
It's not a turnscript, just a script which is called in the function OnEnterRoom in CoreDescription.aslx everytime you enter a room

jaynabonne
Very cool!

HegemonKhan
ya, with the turnscripts I meant indrectly via the 'if' scripts within the global turnscript:

<turnscript name="global_turnscript">
<enabled />
<script>
if (player.parent = "room_1") {
game.hour_string = "6 am (dawn)"
} else if // etc }
// do you need to use~end it with: game.turn = game.turn + 1, or not ???
</script>
</turnscript>

Silver
Pertex wrote:It's not a turnscript, just a script which is called in the function OnEnterRoom in CoreDescription.aslx everytime you enter a room


I've set a clear screen to that (for neatness), problem being it clears the room description. :D

You can remedy it by pasting the description into 'after entering room' which creates a bit more work but you also lose objects and directions.

Pertex
Silver wrote:
I've set a clear screen to that (for neatness), problem being it clears the room description. :D


Yep, there is this little problem when to execute such a script - before or after the script for the room description is executed. I decided to print the room description first because I think you would normally add more text after the description

Silver
it could be solved by a 'print description' script which would follow the clear screen. I might pop that in the suggestion box.

jaynabonne
You can show the room description again fully by calling (if my memory serves, since I'm at work) ShowRoomDescription.

If you create a base room type and put that there, then all your rooms will automagically have it.

Silver
You're gonna have to talk me through that unfortunately. Remember, I don't even know where to put code let alone write it!

I appreciate the help btw.

Edit: I don;t even know what code it is! lol Is it Java or Javascript? I could buy a book to rapidly give me an overview. I consume books.

jaynabonne
Actually, there's an easier way (I don't know what I was thinking). In the script where you have the clear screen, add another script line right after it to call the ShowRoomDescription function.

HegemonKhan
just download (and install and start up): notepad++

and at the top of its screen (once you got it up, aka are in, notepad++), under 'language' in the top horizontal bar, choose: XML

we can help you understand how to read, write, and troubleshoot quest's code (it's not XML, it is its own code, but it's structure is similar to XML's). I especially enjoy helping people with quest's code, as I was able to learn it from not having any coding ability nor knowledge beforehand.

------------

on the left side of the screen, click on 'advanced' in the 'tree of stuff', and click on: Object Types

Object Types is merely a grouping, for example analogy:

an Object Type is a 'basket' that can hold~have 'eggs' (Attributes), you can then give this basket to your Objects, and they'll have all the eggs (as inherited Attributes) that are held within the basket.

for example:

instead of mass code redundency, as seen below:

<object name="HK">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="dexterity" type="int">0</attr>
<attr name="agility" type="int">0</attr>
<attr name="speed" type="int">0</attr>
<attr name="luck" type="int">0</attr>
<attr name="piety" type="int">0</attr>
<attr name="intelligence" type="int">0</attr>
<attr name="spirituality" type="int">0</attr>
<attr name="mentality" type="int">0</attr>
<attr name="perception" type="int">0</attr>
<attr name="deception" type="int">0</attr>
<attr name="personality" type="int">0</attr>
<attr name="charisma" type="int">0</attr>
<attr name="leadership" type="int">0</attr>
<attr name="alignment" type="int">0</attr>
</object>

<object name="Silver">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="dexterity" type="int">0</attr>
<attr name="agility" type="int">0</attr>
<attr name="speed" type="int">0</attr>
<attr name="luck" type="int">0</attr>
<attr name="piety" type="int">0</attr>
<attr name="intelligence" type="int">0</attr>
<attr name="spirituality" type="int">0</attr>
<attr name="mentality" type="int">0</attr>
<attr name="perception" type="int">0</attr>
<attr name="deception" type="int">0</attr>
<attr name="personality" type="int">0</attr>
<attr name="charisma" type="int">0</attr>
<attr name="leadership" type="int">0</attr>
<attr name="alignment" type="int">0</attr>
</object>

<object name="Jay">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="dexterity" type="int">0</attr>
<attr name="agility" type="int">0</attr>
<attr name="speed" type="int">0</attr>
<attr name="luck" type="int">0</attr>
<attr name="piety" type="int">0</attr>
<attr name="intelligence" type="int">0</attr>
<attr name="spirituality" type="int">0</attr>
<attr name="mentality" type="int">0</attr>
<attr name="perception" type="int">0</attr>
<attr name="deception" type="int">0</attr>
<attr name="personality" type="int">0</attr>
<attr name="charisma" type="int">0</attr>
<attr name="leadership" type="int">0</attr>
<attr name="alignment" type="int">0</attr>
</object>

<object name="orc_1">
<inherit name="editor_object" />
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="dexterity" type="int">0</attr>
<attr name="agility" type="int">0</attr>
<attr name="speed" type="int">0</attr>
<attr name="luck" type="int">0</attr>
<attr name="piety" type="int">0</attr>
<attr name="intelligence" type="int">0</attr>
<attr name="spirituality" type="int">0</attr>
<attr name="mentality" type="int">0</attr>
<attr name="perception" type="int">0</attr>
<attr name="deception" type="int">0</attr>
<attr name="personality" type="int">0</attr>
<attr name="charisma" type="int">0</attr>
<attr name="leadership" type="int">0</attr>
<attr name="alignment" type="int">0</attr>
</object>


we can shorten it immensely via using an Object Type, as can be seen below:

<object name="HK">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_object_type" />
</object>

<object name="Silver">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_object_type" />
</object>

<object name="Jay">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_object_type" />
</object>

<object name="orc_1">
<inherit name="editor_object" />
<inherit name="character_object_type" />
</object>

<type name="character_object_type">
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="dexterity" type="int">0</attr>
<attr name="agility" type="int">0</attr>
<attr name="speed" type="int">0</attr>
<attr name="luck" type="int">0</attr>
<attr name="piety" type="int">0</attr>
<attr name="intelligence" type="int">0</attr>
<attr name="spirituality" type="int">0</attr>
<attr name="mentality" type="int">0</attr>
<attr name="perception" type="int">0</attr>
<attr name="deception" type="int">0</attr>
<attr name="personality" type="int">0</attr>
<attr name="charisma" type="int">0</attr>
<attr name="leadership" type="int">0</attr>
<attr name="alignment" type="int">0</attr>
</type>


also, I hope you notice that the '<inherit name="editor_object" />' and '<inherit name="editor_player" />' are Object Types too, these are built-in Object Types for telling the GUI~Editor that these things are Objects and Player Objects, giving them all of their proper GUI~Editor tabs and etc setup features.

----------

so, for Jay's 'base room type', here's an example:

<object name="room">
<inherit name="editor_object" />
<inherit name="editor_room" />
<inherit name="base_room_object_type" />
</object>

<type name="base_room_object_type">
<attr name="XXX" type="script">
// Jay can help with this, as I don't know what script it is, lol
</attr>
</type>

Silver
jaynabonne wrote:Actually, there's an easier way (I don't know what I was thinking). In the script where you have the clear screen, add another script line right after it to call the ShowRoomDescription function.


Yes, thanks, that worked. I need to learn about functions then and what are available.

HK, cheers for your help. I feel I should learn the basics of the editor before I delve into the complex stuff though.

HegemonKhan
a Function (and a Turnscript, Command, Timer, Verb, and etc Elements) holds scripts:

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<object name="character_button_object">
<inherit name="editor_object" />
<alias>character</alias>
<attr name="stats" type="script">
show_stats_function // in the GUI~Editor, you select the 'call function' (add a script -> scripts -> call function -> Name: show_stats_function, Parameters: ~leave this blank; don't add in parameters~)
<attr>
<inventoryverbs type="listextend">stats</attr>
</object>
</object>

<verb name="stats">
<property>stats</property>
<pattern>stats</pattern>
<defaultexpression>XXX</defaultexpression>
</verb>

<function name="show_stats_function">
ClearScreen
msg ("Strength: " + player.strength)
msg ("Endurance: " + player.endurance)
msg ("Dexterity: " + player.dexterity)
msg ("Agility: " + player.agility)
msg ("Speed: " + player.speed)
msg ("Luck: " + player.luck)
msg ("Piety: " + player.piety)
wait {
ClearScreen
}
</function>

Silver
I respect your enthusiasm. The problem is these codes you post may as well be written in Russian with regards to the layman.

HegemonKhan
take a look at them... they're not russian, wink... I think you can understand them... but if not... when you're ready, I'll help you with understanding them :D

think of a function as like a spell, which does something (has scripts), and then you need someone (well, something actually: such as a Verb or a Command) that can 'cast' (call upon) that 'spell' (function):

<object name="fireball_spell">
<inherit name="editor_object" />
<alias>fireball</alias>
<attr name="cast" type="script">
fireball_function
</attr>
</object>

<function name="fireball_function">
orc.hp = orc.hp - 500
msg ("You cast the fireball, doing 500 HP damage to the orc.")
</function>

Silver
It's like someone asking how to wire a plug and instead of being told "the brown wire goes here, the blue here and the green and yellow here" they're given a lecture on ohms law and eddy currents. And I'm sure you know all about ohms law and eddy currents, right?

HegemonKhan
if you can understand fluid dynamics and electrical currents~voltage~engineering (ohms law? ~ too lazy to look it up, lol), you can understand how to code in quest ;)

Silver
HegemonKhan wrote:if you can understand fluid dynamics and electrical currents~voltage~engineering (ohms law? ~ too lazy to look it up, lol), you can understand how to code in quest ;)


I will get round to it, and I'm intrigued and thankful for you bullying me into it (lol).

I actually wrote a text adventure entirely in code when I was aged pretty young (younger than ten or there abouts) but only on paper. It would have worked though. Basic was well easy.

10 Print "You are on a message forum. HK is bullying you again. What to do?

Type A to ignore him.

Type B to kick him in the nuts."

15 Input a$

20 If a$ = "A" then goto 30

25 if A$ = "B" then goto 40

30 Print "You ignore HK"

40 Print "You kick HK in the nuts"
_________________________________________

That's my memory of basic from over 30 years ago! :D

HegemonKhan
msg ("HK whimpers in pain, he'll not be bugging about code for quite awhile, instead he'll wait for being asked for help.")
// sorry, I'm just bored, and helping someone with code, would be something for me to do, lol. my apologies.

Silver
I will check it out and try to understand it. Your effort won't be in vain!

Silver
jaynabonne wrote:Actually, there's an easier way (I don't know what I was thinking). In the script where you have the clear screen, add another script line right after it to call the ShowRoomDescription function.


Doing this in a dark room just returns the description for the room being dark (as that's the default) even if the room is lit.

I can work around that by adding the room description text in the action that lights the room. But now I'm missing the objects. Is there a function similar to ShowRoomDescription for objects?

jaynabonne
ShowRoomDescription should show the dark description if the room is dark and the normal one if the room is lit. Also, ShowRoomDescription will show all the objects and exits (if they're visible, that is, not dark).

Where are you calling this? It sounds to me like you're calling while the room is still dark, so you're getting the dark description and none of the objects are visible. A sequencing problem?

ShowRoomDescription is what is called directly when you execute a "look" ("l") command. It should have all you need.

Silver
jaynabonne wrote:ShowRoomDescription should show the dark description if the room is dark and the normal one if the room is lit. Also, ShowRoomDescription will show all the objects and exits (if they're visible, that is, not dark).

Where are you calling this? It sounds to me like you're calling while the room is still dark, so you're getting the dark description and none of the objects are visible. A sequencing problem?

ShowRoomDescription is what is called directly when you execute a "look" ("l") command. It should have all you need.


Cheers for that, it works now. I must have placed the command in the wrong part of the string (?) - the room requires a match to be lit so if I placed that prior to me moving the lit match object to the player (which changes the room's lighting condition) then of course it would refer to the default description.

The other problem I've been having with light/dark is that examining an object in the dark gives a default "It's too dark to see" or similar and then prints the item's description when the room is lit. All well and good.

However, the same isn't true for other actions.

eg When the room is lit I discover a book. Read book will give me the response of that verb. But when the room returns to being dark I can still read it.

I guess that's normal as the game doesn't know what verb I'm using? But I'm sure it behaved one way on one occasion and another a different time. I solved it using flags anyway.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums