Adding something to status pane (complex)

XanMag

I hate to ask this because it is quite complex but it's something that I really would like to add.

In the status pane I already have a percent completion bar, health, and score. I would love to add to this (or another reasonable place) a status named "Time of Day:" This third game I am making has lots of things that are dependent on what time of day it is. The times of day are dawn, morning, noon, afternoon, dusk, evening, and midnight.

I have an object named twentyfourhours with an attribute called changedHoursCount. Every 15 turns the player takes the time of day progresses. I figured if I can get "Time of Day:" in the status pane, I would add scripts to the changedHoursCount to change the "Time of Day:" accordingly. But, I have no clue how to do it. Jay (and others) helped a ton setting it up as it currently is.

If I need to post some game code, let me know. Specifically. Very specifically.

Help is greatly appreciated. Thank you!


Cr24

I'm ultra-new to this too and drowning even in simple code. But the way I learn is by trying to solve problems so I'm going to take a stab at this. If I'm wrong, be gentle!

So: getting something on the status pane is a matter of setting it as a status attribute on the player. I can think of two ways of doing this for your Time of Day.

  1. The easiest one (if it works) would be to call directly on "twentyfourhours"'s attribute. The key would look like "twentyfourhours.changedHoursCount". Then the value would be "Time of Day: !". Thing is, I don't know if a player status attribute can call on attributes from other objects like that. And I'm also assuming that you are storing the names of the times of day in the changedHoursCount field.

  2. Write a player attribute with a script that copies the result from changedHoursCount TO the player attributes. This would be an (expression or function?) that would just set the player attribute equal to the changedHoursCount. THEN you can just set the status attribute key to whatever you set the player attribute to and the value would still be "Time of Day: !".

I'm probably completely off the mark on this so I hope you get some real help soon. =)


hegemonkhan

the built-in 'statusattributes' String Dictionary (and it's corresponding status pane during game play) is only for Player Objects and the 'game' Game Settings Object, so this means that (aside from what magic Pixie, Jay, and other good coders can do), your Attributes must be within those Objects (Player Objects and/or the 'game' Game Settings Object), as the String Dictionary looks for its items as Attributes of its containing/parent Object (maybe you could change the built-in code of how it works to look at other Objects in whether they have the Attributes that match up with the String Dictionary's items --- again: Pixie, Jay, and good coders magic, lol). So, if you got your Attributes on another Object, you're going to also need to have those same Attributes (and keep them updated: you could use a 'changed' Script on the other Object's Attributes, setting/updated the same Attributes' values on your Player/'game' Objects) on some Player Object or the 'game' Game Settings Object, so that their 'statusattributes' String Dictionary can use them.

see here for a step by step guide demo game on the basics of Attributes (it includes status attribute usage):

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

ask if you got any questions, or need any help or further explanation of anything.


XanMag

Okay...

I'm slowly making progress on this.

I have successfully added a 'Status' Pane and the "Time of Day:" in this pane by:
Adding a Status attribute (statusattribute) to game attribute tab (Key: TOD, Value: "Time of Day:")

I also have added objects - TimeOfDay, morning, noon, evening, night - under the game in the tree of stuff.
On the "TimeOfDay" object, I have set the following attributes: HoursCount, changedHoursCount, and currentTOD.
HoursCount is an Integer set to 1.
changedHoursCount is an If/Else If script that checks for HoursCount integer. If 1 then set TimeOfDay.currentTOD to morning. If 6 then set to noon, etc.
currentTOD is an object attribute set to morning. With each new TOD I set it accordingly (see above).

Now, I'm not sure how to retrieve the currentTOD and display it next to "Time of Day:" in the status pane. I assume that is the next step. I'm doing this in a trial game before messing with it in X3. Below is the entire code if anyone wants to help me out with it!

<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Cycling a Day">
    <gameid>d249f751-fa06-4277-875e-79e19b7166aa</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <statusattributes type="stringdictionary">
      <item>
        <key>TOD</key>
        <value>Time of Day:</value>
      </item>
    </statusattributes>
    <object name="TimeOfDay">
      <inherit name="editor_object" />
      <HoursCount type="int">1</HoursCount>
      <changedHoursCount type="script">
        if (TimeOfDay.HoursCount = 1) {
          TimeOfDay.currentTOD = morning
          msg ("It is now morning.")
        }
        else if (TimeOfDay.HoursCount = 6) {
          TimeOfDay.currentTOD = noon
          msg ("It is now noon.")
        }
        else if (TimeOfDay.HoursCount = 11) {
          TimeOfDay.currentTOD = evening
          msg ("It is now evening.")
        }
        else if (TimeOfDay.HoursCount = 16) {
          TimeOfDay.currentTOD = night
          msg ("It is now night time.")
        }
        else if (TimeOfDay.HoursCount = 20) {
          TimeOfDay.HoursCount = 0
        }
      </changedHoursCount>
      <currentTOD type="object">morning</currentTOD>
      <object name="night">
        <inherit name="editor_object" />
      </object>
      <object name="evening">
        <inherit name="editor_object" />
      </object>
      <object name="noon">
        <inherit name="editor_room" />
      </object>
      <object name="morning">
        <inherit name="editor_object" />
      </object>
    </object>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="room2">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="room2">
    <inherit name="editor_room" />
    <exit alias="north" to="room">
      <inherit name="northdirection" />
    </exit>
    <exit alias="south" to="room3">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="room3">
    <inherit name="editor_room" />
    <exit alias="north" to="room2">
      <inherit name="northdirection" />
    </exit>
  </object>
  <object name="Warehouse">
    <inherit name="editor_room" />
  </object>
  <turnscript name="HoursCounter TS">
    <script>
      TimeOfDay.HoursCount = TimeOfDay.HoursCount + 1
    </script>
    <enabled />
  </turnscript>
  <walkthrough name="Test">
    <steps type="simplestringlist">
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
      wait
    </steps>
  </walkthrough>
</asl>

Thanks in advance!


Log in to post a reply.

Support

Forums