How do I get time to work?

I plan on making it so every 5 turns, "time" is added +3,600 (seconds that represent 1 hour) and once the value for "time" has reached 79,200 (10 PM), the player becomes cold and loses health unless the player enters the "shelter" object - in which case "time" becomes 21,600 (6 am). I also want the value for time to reset after it has reached 86,400 (24 hours) but continue damaging the player until "time" is 21,600.

I should note that I never script the game manually, I only use the options available within Quest as I do not know the coding language.


K.V.

Hello,

There are many ways...

This is the easiest:

http://docs.textadventures.co.uk/quest/time.html


If you want something more complicated, and you're using the desktop editor, check this out:

https://github.com/ThePix/quest/wiki/Clock-Library


If you have any questions after checking out the first link (or both links), let us know! (We'll be watching this thread...)


Thank you!


Counting time by seconds may be easy for a computer, but it becomes too big of a number for us simple minded humans...
If you track:
game.time.days
game.time.hours
game.time.minutes
Then your time in the game can be anything.
Then, add time taken to any action, then add that time to minutes.
{If minutes>60){
game.time.minutes=game.time.minutes-60
game.time.hour+1
// the only problem would be if the task took more than 1 hour. Then you would need to add time to hour instead of to minutes.
}
then check for hours>24


K.V.

the only problem would be if the task took more than 1 hour.

You ain't lying, DL!

If you're keeping 'real' game time, you'll probably want to use Pixie's ClockLibrary thing. (Peruse the code one day when you have a minute. You'll see how simple/complex it is. It's a little crazy!)


(filler for getting edited post, updated/posted)
(again, filler for getting edited post, updated/posted)
(again, filler for getting edited post, updated/posted)


"I plan on making it so every 5 turns, "time" is added +3,600 (seconds that represent 1 hour) and once the value for "time" has reached 79,200 (10 PM), the player becomes cold and loses health unless the player enters the "shelter" object - in which case "time" becomes 21,600 (6 am). I also want the value for time to reset after it has reached 86,400 (24 hours) but continue damaging the player until "time" is 21,600. I should note that I never script the game manually, I only use the options available within Quest as I do not know the coding language (Enpherdean)"


10 pm (civilian) = 20 (military hr) = 3600 * 20 = 79200 seconds // okay, so your day starts at midnight (24/0 military hours), lol (I had to figure out when you were starting your day/seconds-count time, lol)


HK ignores: "I should note that I never script the game manually, I only use the options available within Quest as I do not know the coding language (Enpherdean)"

lol, sorry... but it's easier/faster for me to do/show in code:

IMPORTANT:

  • this code only works if you ONLY increase your 'time' by '+3600', and that you initially start the game and the day, at '0' (midnight), and end the day at '86400 ---> 0' (midnight)

  • since I'm using the special 'changed' Script Attributes, there might be some issues due to 'order of operations'... let me know if you notice this code not working as you intended (the main possible issue, that I notice so far, is that maybe the 'player.cold' Boolean Attribute doesn't get it's Boolean Value set/re-set to 'false', due to hitting an increment of the '+5 turns' and the 'player' Player's Object's 'parent' Object reference/pointer Attribute's object reference/pointer Value changing to 'shelter', at the same time, as this could add the '+3600' to time before the the scripting for the 'if (player.time = 21600)' is able to act, aka before its able to its action of: player.cold = false).

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="changedparent" type="script">
    if (player.parent = shelter) {
      player.time = 21600
    }
  </attr>

  <attr name="cold" type="boolean">false</attr>

  <attr name="turns" type="int">0</attr>

  <attr name="changedturns" type="script">
    if (player.cold) {
      player.health = player.health - 100 // you can change the '100' Integer Value to whatever (Integer: any non-decimal number) you want
    }
    if (player.turns % 5 = 0) {
      player.time = player.time + 3600
    }
  </attr>

  <attr name="time" type="int">0</attr>

  <attr name="changedtime" type="script">
       if (player.time = 21600) {
        player.cold = false
      } else if (player.time = 79200) {
        player.cold = true
      } else if (player.time = 86400) {
        player.time = 0
      }
  </attr>

  <attr name="health" type="int">0</attr>

  <attr name="changedhealth" type="script">
    <![CDATA[
      if (player.health < 1) {
        msg ("You died or were killed.")
        msg ("GAME OVER")
        finish
      }
    ]]>
  </attr>

</object>

<object name="room">

  <inherit name="editor_room" />

</object>

<object name="shelter">

  <inherit name="editor_room" />

</object>

<turnscript name="global_turnscript">

  <attr name="enabled" type="boolean">true</attr>

  <attr name="script" type="script">
    // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
    player.turns = player.turns + 1
  </attr>

</turnscript>

I'm lazy.... someone else can help you do all this through the GUI/Editor, yes, HK is very lazy.


Looking at the complexity of this, I realize I'm too much of a novice to be attempting such coding lol. Thanks for the further help, if I don't get it by now then I'm applying for computer programming next semester. xD


Time is not that hard, you are just taking the most accurate path...
IE: the current time is 11:34...
it take 30 minutes to do a task...
minutes=minutes+30. (was 34, now it is 64)
minutes>60...
minutes=minutes-60
hour=hour+1
The time is now: 12:04.


Hmm, it's more about the rest and more specifically how to write it all in.


There is no time.

Time is a construct of man.

Once you've grasped that, you can bend it to your will!


@DarkLizerd

One piece of ten
A riddled shard
Can you find it in a timely manner?
It lies... within a crate! (You need a token to get to Crate Mart!)

ENPHERDAEN: IF YOU CAN READ ALL OF THIS INVISIBLE TEXT, I'M SORRY! WE'RE PLAYING A GAME WHERE WE HIDE CLUES IN THE FORUM! (Shh! Don't point this out to anyone, please!)


But seriously, folks...

I've been playing around with time in a game I'm currently porting, and the library linked to above works very well.

https://github.com/ThePix/quest/wiki/Clock-Library

NOTE: You can't use libraries in the web editor.


Pixie even has a way to display the current time in a side pane!

If you'd like to see it in action, you can play my port in progress here:
http://textadventures.co.uk/games/view/rr9vezzxkeaovamsaqgxcw/they-call-ya-mister-quest-prototype-in-progress

All the stuff with time works.

You can WAIT, which takes one minute.

NOTE: You may see testing messages during play. Again: this is a port in progress.

The complete, original Glulxe version is here:
http://textadventures.co.uk/games/view/ogj8kixyx0emjknru3nckg/they-call-ya-mister

...or you can WAIT 60, which waits an hour...


@ Enpherdean:

  1. create a new text adventure game
  2. name it and save it somewhere you can find it (for example, on the desktop)
  3. now, right click on your 'xxx.aslx' game file (that you just created) and choose to open it up, using a text editor software (notepad, wordpad, notepad++, Apple: text editor, etc)
  4. this is your entire game, which hopefully looks the same as my still use of an older version of quest: v550, whereas Pixie's current version of quest is v570, so Pixie might have it's default new game code looking different than mine, hopefully they'll look the same, lol. If you get errors when trying to open up into the GUI/Editor with my code, let me know)
  5. highlight ALL of it, and delete it ALL
  6. copy and paste in ALL of my code (in the code box below) to it
  7. save and close/exit out of it
  8. open it up in the GUI/Editor (hopefully it'll work, if not, let me know), and now you can see/study it in the GUI/Editor and play it
<asl version="550"> <!-- this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570"> -->

  <include name="English.aslx" /> <!-- HUGE CREDIT TO K.V. for this correction, as I had again used 'inherit' instead of 'include' -->
  <include name="Core.aslx" /> <!-- HUGE CREDIT TO K.V. for this correction, as I had again used 'inherit' instead of 'include' -->

  <game name="example_game">

    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

  </game>

  <object name="room">

    <inherit name="editor_room" />

    <exit name="exit_1A" alias="east" to="shelter">
      <inherit name="eastdirection" />
    </exit>

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

    <attr name="changedparent" type="script">
      if (player.parent = shelter) {
        player.time = 21600
      }
    </attr>

    <attr name="cold" type="boolean">false</attr>

    <attr name="turns" type="int">0</attr>

    <attr name="changedturns" type="script">
      if (player.cold) {
        player.health = player.health - 100 // you can change the '100' Integer Value to whatever (Integer: any non-decimal number) you want
      }
      if (player.turns % 5 = 0) {
        player.time = player.time + 3600
      }
    </attr>

    <attr name="time" type="int">0</attr>

    <attr name="changedtime" type="script">
      if (player.time = 21600) {
        player.cold = false
      } else if (player.time = 79200) {
        player.cold = true
      } else if (player.time = 86400) {
        player.time = 0
      }
    </attr>

    <attr name="health" type="int">999</attr>

    <attr name="changedhealth" type="script">
      <![CDATA[
        if (player.health < 1) {
          msg ("You died or were killed.")
          msg ("GAME OVER")
          finish
        }
      ]]>
    </attr>

  </object>

  <object name="shelter">

    <inherit name="editor_room" />

    <exit name="exit_1B" alias="west" to="room">
      <inherit name="westdirection" />
    </exit>

  </object>

  <turnscript name="global_turnscript">

    <attr name="enabled" type="boolean">true</attr>

    <attr name="script" type="script">
      // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
      msg ("(TESTING) Turns: " + player.turns)
      msg ("(TESTING) Time: " + player.time)
      msg ("(TESTING) Cold: " + player.cold)
      msg ("(TESTING) Time: " + player.health)
      player.turns = player.turns + 1
      msg ("(TESTING) Turns: " + player.turns)
      msg ("(TESTING) Time: " + player.time)
      msg ("(TESTING) Cold: " + player.cold)
      msg ("(TESTING) Time: " + player.health)
    </attr>

  </turnscript>

</asl>

K.V.

HK,

Some object reference is not set to an object somewhere in that code (couldn't pinpoint it)...


it probably has to do with me trying to do the Exits in code, try removing them, then adding them back in via the GUI/Editor...

or... maybe I also need the code that toggles/reveals the 'health' Attribute... in the 'game' Game Object... hmm...

or... try changing the Turnscript to this:

  <turnscript name="global_turnscript">

    <enabled />

    <script>
      // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
      player.turns = player.turns + 1
    </script>

  </turnscript>

I got too lazy to read all of that^ so...

I would:
Add an object called Time.
Add an Attribute (select Integer) and call it TimeCount and set it to some number equal to the number of turns you feel are appropriate to end the game.
Add a changed attribute script.
Add an IF script to this and choose object attribute equals and put Time in the Object box and TimeCount = 'n' where you want 'n' to be the number of turns where you want a message to pop up.
Add as many ELSE IFs as you want as you did above set to the number of turns you want different messages to pop up.

Add to the section 'after every turn in the game' a set object attribute: Object 'Time' attribute 'TimeCount' = Time.TimeCount + 1 ---- I cannot remember if this is exactly the stuff you throw in there, but I hope you get the point.

If you want to try this route, let me know and I'll clarify. It's not too hard and may be easier for what you are trying to do.

Good Luck.


Thanks thanks and thanks again. Looks like I got a lot to try out.


XanMag I was thinking of making "time" an object and adding attributes to it. Wasn't exactly sure how to do all that jazz though. You like jazz?


(filler for getting this edited post, updated/posted)


just tested my game code, it works for me, though it can be refined a bit (in the design that I used for testing it: I died of cold / game ended while still showing me with 99 health --- so this might need to be "refined", as an example of what I mean), of course.


@ Enpherdaen:

follow my steps in my previous post, and let me know if it works or not for you? If you need any help with any of the steps, let me know. As it should hopefully work for you too... unless the current version needs some changing up of my code for it to work


K.V.

First, I get this:

image

Then I changed that first line from

<asl version="550"> // this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570">

to

<asl version="550"> <!-- // this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570"> -->

Then, I get this:

image

I can't figure out what keeps throwing it, but I created a new game, then copied all of the code EXCEPT FOR THE FIRST ROOM, I got this to load in the editor as well as the player:

<!--Saved by Quest 5.7.6404.15496-->
<!--
<asl version="550"> // this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570">    //this asl version threw things off, so I used the HTML noting style (it still threw the object error, though)
 -->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="example_game">
    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <showhealth />
    <turnscript name="global_turnscript">
      <enabled />
      <script>
        // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
        player.turns = player.turns + 1
        OutputTextNoBr ("{player.turns}")
      </script>
    </turnscript>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <exit name="exit_1A" alias="east" to="shelter">
      <inherit name="eastdirection" />
    </exit>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <cold type="boolean">false</cold>
      <turns type="int">0</turns>
      <time type="int">0</time>
      <health type="int">0</health>
      <changedparent type="script">
        if (player.parent = shelter) {
          player.time = 21600
        }
      </changedparent>
      <changedturns type="script">
        if (player.cold) {
          player.health = player.health - 100
        }
        if (player.turns % 5 = 0) {
          player.time = player.time + 3600
        }
      </changedturns>
      <changedtime type="script">
        if (player.time = 21600) {
          player.cold = false
        }
        else if (player.time = 79200) {
          player.cold = true
        }
        else if (player.time = 86400) {
          player.time = 0
        }
      </changedtime>
      <changedhealth type="script"><![CDATA[
        if (player.health < 1) {
          msg ("You died or were killed.")
          msg ("GAME OVER")
          finish
        }
      ]]></changedhealth>
    </object>
  </object>
  <object name="shelter">
    <inherit name="editor_room" />
    <exit name="exit_1B" alias="west" to="room">
      <inherit name="westdirection" />
    </exit>
  </object>
</asl>

I still can't figure out what the difference is.

...even with a DIFF:

CLICK HERE TO VIEW THE DIFF
<!--Saved by Quest 5.7.6404.15496-->
							      |	<asl version="550"><!-- // this is my version, so if you can'
								
<asl version="550">
							      |	  <inherit name="English.aslx" />
								
  <include ref="English.aslx" />
							      |	  <inherit name="Core.aslx" />
								
  <include ref="Core.aslx" />
							      <
  <game name="example_game">
								  <game name="example_game">
								
    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
								    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
								
    <version>1.0</version>
								    <version>1.0</version>
								
    <firstpublished>2017</firstpublished>
								    <firstpublished>2017</firstpublished>
								
    <showhealth />
							      <
    <turnscript name="global_turnscript">
							      <
      <enabled />
							      <
      <script>
							      <
        // you can put other desired global scripting here (o
							      <
        player.turns = player.turns + 1
							      <
        OutputTextNoBr ("{player.turns}")
							      <
      </script>
							      <
    </turnscript>
							      <
  </game>
								  </game>
								
  <object name="room">
								  <object name="room">
								
    <inherit name="editor_room" />
								    <inherit name="editor_room" />
								
    <exit name="exit_1A" alias="east" to="shelter">
								    <exit name="exit_1A" alias="east" to="shelter">
								
      <inherit name="eastdirection" />
								      <inherit name="eastdirection" />
								
    </exit>
								    </exit>
								
    <object name="player">
							      |	  </object>
								
      <inherit name="editor_object" />
							      |	  <object name="player">
								
      <inherit name="editor_player" />
							      |	    <inherit name="editor_object" />
								
      <cold type="boolean">false</cold>
							      |	    <inherit name="editor_player" />
								
      <turns type="int">0</turns>
							      |	    <attr name="parent" type="object">room</attr>
								
      <time type="int">0</time>
							      |	    <attr name="changedparent" type="script">
								
      <health type="int">0</health>
							      |	      if (player.parent = shelter) {
								
      <changedparent type="script">
							      |	        player.time = 21600
								
        if (player.parent = shelter) {
							      |	      }
								
          player.time = 21600
							      |	    </attr>
								
        }
							      |	    <attr name="cold" type="boolean">false</attr>
								
      </changedparent>
							      |	    <attr name="turns" type="int">0</attr>
								
      <changedturns type="script">
							      |	    <attr name="changedturns" type="script">
								
        if (player.cold) {
							      |	      if (player.cold) {
								
          player.health = player.health - 100
							      |	        player.health = player.health - 100 // you can change
								
        }
							      |	      }
								
        if (player.turns % 5 = 0) {
							      |	      if (player.turns % 5 = 0) {
								
          player.time = player.time + 3600
							      |	        player.time = player.time + 3600
								
        }
							      |	      }
								
      </changedturns>
							      |	    </attr>
								
      <changedtime type="script">
							      |	    <attr name="time" type="int">0</attr>
								
        if (player.time = 21600) {
							      |	    <attr name="changedtime" type="script">
								
          player.cold = false
							      |	      if (player.time = 21600) {
								
        }
							      |	        player.cold = false
								
        else if (player.time = 79200) {
							      |	      } else if (player.time = 79200) {
								
          player.cold = true
							      |	        player.cold = true
								
        }
							      |	      } else if (player.time = 86400) {
								
        else if (player.time = 86400) {
							      |	        player.time = 0
								
          player.time = 0
							      |	      }
								
        }
							      |	    </attr>
								
      </changedtime>
							      |	    <attr name="health" type="int">999</attr>
								
      <changedhealth type="script"><![CDATA[
							      |	    <attr name="changedhealth" type="script">
								
							      >	      <![CDATA[
								
        if (player.health < 1) {
								        if (player.health < 1) {
								
          msg ("You died or were killed.")
								          msg ("You died or were killed.")
								
          msg ("GAME OVER")
								          msg ("GAME OVER")
								
          finish
								          finish
								
        }
								        }
								
      ]]></changedhealth>
							      |	      ]]>
								
    </object>
							      |	    </attr>
								
  </object>
								  </object>
								
  <object name="shelter">
								  <object name="shelter">
								
    <inherit name="editor_room" />
								    <inherit name="editor_room" />
								
    <exit name="exit_1B" alias="west" to="room">
								    <exit name="exit_1B" alias="west" to="room">
								
      <inherit name="westdirection" />
								      <inherit name="westdirection" />
								
    </exit>
								    </exit>
								
  </object>
								  </object>
								
							      >	  <turnscript name="global_turnscript">
								
							      >	    <attr name="enabled" type="boolean">true</attr>
								
							      >	    <attr name="script" type="script">
								
							      >	      // you can put other desired global scripting here (or 
								
							      >	      msg ("(TESTING) Turns: " + player.turns)
								
							      >	      msg ("(TESTING) Time: " + player.time)
								
							      >	      msg ("(TESTING) Cold: " + player.cold)
								
							      >	      msg ("(TESTING) Time: " + player.health)
								
							      >	      player.turns = player.turns + 1
								
							      >	      msg ("(TESTING) Turns: " + player.turns)
								
							      >	      msg ("(TESTING) Time: " + player.time)
								
							      >	      msg ("(TESTING) Cold: " + player.cold)
								
							      >	      msg ("(TESTING) Time: " + player.health)
								
							      >	    </attr>
								
							      >	  </turnscript>
								
</asl>								</asl>



I still don't know what object reference wasn't set to an instance of an object...


my code is only 81 lines long... your post said you had an error on line 105 ...


I did re-type my code that I tested... so I probably got some typo in my code that I posted online....

unfortunately the 'missing object reference' error, is the worst error, as it could literally be anything... (everything is actually an OBJECT of the underlying quest code, not to be confused with the 'Object' Element. All Elements are OBJECTS in the underlying quest code).

So, it could be some stupid missing ending tag's: '/' or '>', somewhere.... or whatever... the error is completely ambigious (the worst type of error), and so it could be anything causing the issue/problem/error.


I scoured my code quite closely as humanly possible, but couldn't find anything...

maybe you could post the code you used, and I can see if I can find an error in it? You can also try taking out part by part of the code to try to find the source of the error too... one of the direct manual ways of finding an error in code, lol.

Like a physician/surgeon, keep taking body parts out, until you find the source of the problem/infection-invasion/etc...


spotted one thing with your code (so far), but it's not (well I don't think it is) the source of the problem with your code not working:

like I did (I just recently spotted this in my own code and edited it in, so my previous code has this same mistake), I think you used my previous code, which in it, I forgot to give a starting/initial amount of health:

I had wrongly:

<object name="player">
  <attr name="health" type="int">0</attr> // the '0' Value is WRONG
</object>

this is because, I also have code that ends the game when health is 'less than 1', lol. Ooopsy... But, this shouldn't prevent you from being able to load and play the game (it'll only cause the game to immediately end as soon as you start playing the game).


since, you copied my previous code before I fixed it up:

you got the same 'health = 0', so just change it to, say, '999', like I did, lol:

<object name="player">
  <attr name="health" type="int">999</attr>
</object>

also, with this:

  <game name="example_game">
    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <showhealth />
    <turnscript name="global_turnscript">
      <enabled />
      <script>
        // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
        player.turns = player.turns + 1
        OutputTextNoBr ("{player.turns}")
      </script>
    </turnscript>
  </game>

I'd try these changes:

first, try just removing the 'showhealth' tag line, to see if this is the cause of the error. I'm taking a guess that this might be the culprit, as using (turning on) the built-in health might cause some conflicts with me just creating a 'health' Integer Attribute (as I never turned/toggled on the built-in health feature) on my own. There might be a built-in 'health' and my 'health' in conflict with each other, or by turning on the 'health', my code is missing stuff that the built-in health requires in relation to its use, maybe.

if not, then try putting the turnscript outside of the 'game' Game Settings Object (so it's a direct child of the 'asl' tag, which is the actual GAME OBJECT), and see if that gets the code to work. I am not aware that you can put a Turnscript inside of the 'game' Game Settings Object, if you can than obviously this is not causing the problem... but if you can't... this could be the why the code isn't work... This might be culprit too....

there's probably nothing wrong with the 'OutputTextNoBr', but I'm just going to remove it anyways, as well, lol. You can test removing just this to see if it's removal causes the code to work possibly.

<asl version="550">

  // blah code

  <game name="example_game">
    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>

  <turnscript name="global_turnscript">
    <enabled />
    <script>
      // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
      player.turns = player.turns + 1
    </script>
  </turnscript>

  <object name="room">
    // blah
  </object>

  // blah code

</asl>

K.V.

HK,

This must have something to do with you and I using different versions of Quest. (Even though both save the asl file as version 550, I can attest that there are definitely still some differences).


  1. This is what I get right now when I copy & paste the code that's posted here right now: http://textadventures.co.uk/forum/quest/topic/u_n5otugokquhpmnu0bdzw/how-do-i-get-time-to-work#349a1b52-daeb-4c89-bdea-4f1bbf4faa6f

image


I found the errors

It's the lines that include the libraries.

It should be <include ref="English.aslx"/> and <include ref="Core.aslx"/> instead of <inherit name="English.aslx" /> and <inherit name="Core.aslx" />.


WORKS:

<asl version="550">

  <include ref="English.aslx"/>
  <include ref="Core.aslx"/>

  <game name="hk3">
    <gameid>5bdf38dd-657c-43eb-b434-b78df02c61d8</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>

DOESN'T WORK:

<asl version="550">

  <inherit name="English.aslx" />
  <inherit name="Core.aslx" />

  <game name="example_game">

    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

  </game>

And this:

<asl version="550"> // this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570">    //this asl version threw things off, so I used the HTML noting style (it still threw the object error, though)

This isn't actually commented out, so <asl version="570"> messes things up (and it's still version 550 anyway).

Here's the code you have posted right now (with those 3 lines edited). It loads right up and prints the testing messages now.

<asl version="550"> 

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="example_game">

    <gameid>7934e1d6-112d-41cb-b00e-0c7debced49e</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>

  </game>

  <object name="room">

    <inherit name="editor_room" />

    <exit name="exit_1A" alias="east" to="shelter">
      <inherit name="eastdirection" />
    </exit>

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

    <attr name="changedparent" type="script">
      if (player.parent = shelter) {
        player.time = 21600
      }
    </attr>

    <attr name="cold" type="boolean">false</attr>

    <attr name="turns" type="int">0</attr>

    <attr name="changedturns" type="script">
      if (player.cold) {
        player.health = player.health - 100 // you can change the '100' Integer Value to whatever (Integer: any non-decimal number) you want
      }
      if (player.turns % 5 = 0) {
        player.time = player.time + 3600
      }
    </attr>

    <attr name="time" type="int">0</attr>

    <attr name="changedtime" type="script">
      if (player.time = 21600) {
        player.cold = false
      } else if (player.time = 79200) {
        player.cold = true
      } else if (player.time = 86400) {
        player.time = 0
      }
    </attr>

    <attr name="health" type="int">999</attr>

    <attr name="changedhealth" type="script">
      <![CDATA[
        if (player.health < 1) {
          msg ("You died or were killed.")
          msg ("GAME OVER")
          finish
        }
      ]]>
    </attr>

  </object>

  <object name="shelter">

    <inherit name="editor_room" />

    <exit name="exit_1B" alias="west" to="room">
      <inherit name="westdirection" />
    </exit>

  </object>

  <turnscript name="global_turnscript">

    <attr name="enabled" type="boolean">true</attr>

    <attr name="script" type="script">
      // you can put other desired global scripting here (or you can use the special 'changed' Script Attributes on Objects as well)
      msg ("(TESTING) Turns: " + player.turns)
      msg ("(TESTING) Time: " + player.time)
      msg ("(TESTING) Cold: " + player.cold)
      msg ("(TESTING) Time: " + player.health)
      player.turns = player.turns + 1
      msg ("(TESTING) Turns: " + player.turns)
      msg ("(TESTING) Time: " + player.time)
      msg ("(TESTING) Cold: " + player.cold)
      msg ("(TESTING) Time: " + player.health)
    </attr>

  </turnscript>

</asl>

bloody....

HK bangs his head on the desk....

I really hate how 'include' and 'inherit' start with 'in', argh.... not again....

amazing find, K.V. !!!! HK has yet again typed in 'inherit' instead of 'include'.... ARGH !!!!!

I use the Object Types too much, so used to typing in 'inherit' that when I type in the library references, I type in 'inherit' instead of 'include' for the library references, argh argh argh..... BLOOODY AND FLAMING ASHES...... (Wheel of Time profanity, lol)


HUGE THANKS TO K.V. for finding/noticing I used 'inherit' (which is for the Object Types / Types --- I type/use these too much, lol, argh) for my library reference tags instead of the library reference tags of 'include', argh.... sorry about that to everyone.... I need to remember to check my library tags as the first thing before I post code !!!


ah, I forgot about this too (Another awesome find, K.V. !!!):

<asl version="550"> // this is my version, so if you can't open it up in the GUI/Editor, first try changing this over to the most recent version: <asl version="570">    //this asl version threw things off, so I used the HTML noting style (it still threw the object error, though)

the '//' line comments ONLY work within scripting, but I have them outside of scripting (outside of the tags), so that's why my code was giving an error (aside from also using 'inherit' for the library reference tags... GRRRRRR).

for comments outside of the tags, you got to do the block comment tags: <!-- xxx --->


K.V.

I really hate how 'include' and 'inherit' start with 'in', argh.... not again....

In related news:

I put BeginsWith instead of StartsWith every single time!!!

EVERY! SINGLE! TIME!


KV starts to bang his head on the desk, decides it might hurt the desk and skips directly to HK's second step: uttering mild profanities!


I still recommend looking at The Pixie's time library though. It could help.


K.V.

I still recommend looking at The Pixie's time library though. It could help.

I second this.

I use it. It's pretty awesome.

image

image


wow, looks awesome... !!! :D (I really need to get around learning how to do all of the UI/pane/JS customization coding... makes the game look so cool, just from the visuals of it alone)


K.V.

wow, looks awesome... !!! :D (I really need to get around learning how to do all of the UI/pane/JS customization coding... makes the game look so cool, just from the visuals of it alone)

Thank you, kind sir!

(Now, I only need to finish porting it so everyone can play it...)


Woo 30th answer! Also I give up because coding to me is like Japanese.


K.V.

@Enpherdaen

Yeah, I used to feel the same way. Then, I watched all the Dragon Ball episodes in Japanese, wrote a text adventure or two, and, now, I say this:

日本語よりもコーディングが簡単です
Nihongo yori mo kōdingu ga kantandesu


Your avatar is on my TV right now, by the way!


How so?


Just cheat and download a code library. Of course, I just cheat and PM The Pixie... Of course, currently I am using his code and I am basically a complete newbie, besides taking one summer coding class... so I need to.


Actually, I have read that code/his code on here, so I know the gist of it.

It's not exactly like this, but close.

Timer 1 changes the minute every 60 seconds.

Timer 2 changes the hour every 3600 seconds. (Yes, that's how many seconds are in an hour.)

Make attributes for the time.
Reset by typing:

game.minute = 0
game.hour = 0

(Technically, you only need the "realminute" and "realhour".... I'm just being stupid/eccentric.)

I use the online/web editor. So bear with me.

Timer 1

game.minute = game.minute + 1
game.realminute = game.realminute + 1

Timer 2

game.hour = game.hour + 1
game.realhour = game.realhour + 1

Game script
...I don't know how that looks on the offline thing.

game.minute = 0
game.hour = 0
game.realminute = 10
game.realhour = 24
if (game.realminute = 60) {
  game.realminute = 0
}
else if (game.realhour = 25) {
  game.realhour = 0
}

just for fun, if you want to see a convoluted way of doing a countdown timer, I made one (this was back when I was trying to do time coding for my first time), lol:

http://textadventures.co.uk/forum/samples/topic/4162/countdown-timer-code

it does provide some help, as this is one method/tactic that you can use for time, and also get more information on this type of stuff from Jay's responding posts too.


time and date stuff is complicated stuff, if you try to do it as accurately/complex as you can... I had no idea how technical/complicated actual/accurate 'leap year' and etc related stuff is... lol. I hate math...


the modulus operator is really helpful too: %

it is division, but finds/gets the REMAINDER, instead of the quotient

this makes it good for cyclic stuff (like time) and for factoring/divisibility and/or odd/even:

clock_second = second_count % 60
// 0, ... , 59, 0, ..., 59, etc

clock_minute = minute_count % 60
// 0, ... , 59, 0, ..., 59, etc

civilian_hour = hour_count % 12
// 0, ... , 11, 0, ... , 11, etc

military_hour = hour_count % 24
// 0, ... , 23, 0, ... , 23, etc

positive_degree_circle_location = degree % 360
// 0, ... , 359, 0, ... , 359, etc

odd/even:

if (number % 2 = 0) { msg ("IT IS AN EVEN NUMBER") } else { msg ("IT IS AN ODD NUMBER") }

factoring/divisibility:

if (number % 2 = 0) { msg ("2 IS A FACTOR OF THE NUMBER, OR TO SAY IT DIFFERENTLY, THE NUMBER IS DIVISIBLE BY 2") }
if (number % 3 = 0) { msg ("3 IS A FACTOR OF THE NUMBER, OR TO SAY IT DIFFERENTLY, THE NUMBER IS DIVISIBLE BY 3") }
if (number % 4 = 0) { msg ("4 IS A FACTOR OF THE NUMBER, OR TO SAY IT DIFFERENTLY, THE NUMBER IS DIVISIBLE BY 4") }
if (number % 5 = 0) { msg ("5 IS A FACTOR OF THE NUMBER, OR TO SAY IT DIFFERENTLY, THE NUMBER IS DIVISIBLE BY 5") }
if (number % 6 = 0) { msg ("6 IS A FACTOR OF THE NUMBER, OR TO SAY IT DIFFERENTLY, THE NUMBER IS DIVISIBLE BY 6") }
etc etc etc


K.V.

Real-game-time calculator script:

x = game.timeelapsed
game.hours = x / 3600
time = x%3600
game.minutes = x/60
x = time%60
game.seconds = x
msg ("<br/>Game time: " + game.hours + ":{if game.minutes<10:0}" + game.minutes + ":{if game.seconds<10:0}" + game.seconds + "<br/>")

K.V.

How so?

Who, me?

I'm watching FOR A FEW DOLLARS MORE.


Or do you mean 'how is coding easier than Japanese'?

The reading and writing in Japanese is what gets me.

Plus, the sentence structure is SUBJECT OBJECT VERB.

That messes me all up!


@K.V.

Yeeeeaaahhhh.... that's why I thought it was too complicated.... although, I find most code too complicated...

My code still works like a clock, though. I'm happy.

(My Japanese comprises of Otaku. Considering I am not a language sponge like you are, my vocabulary is limited. Example: KV -san code skii.)
(...I watch all manner of Shonen Jump series. And Pokemon, or whatever is playing on TV.)
Also, I think he was asking how his avatar was on the TV.


HK only knows/remembers a very few common anime shouts and/or street fighter game move shouts, lol

(have no idea how to spell them though, lol)

ha-do-ken (fireball move)
sho-ryu-ken (dragon punch move)

ka-me-ha-me-ha ... or whatever it is lol (dragon ball series)

"believe it" (lol)
"my ninja way" (lol)

yun-i-cev-i ("unforgivable" --- very angry / great rage)
k(o/e)r-o-cer ("KILL / SLAUGHTER / DIE MF'er!!!")
ba-kai / ba-ka-nai ("idiot / you idiot")
oi ("hey")
(and a few more that I can't think of at the moment)

shin = devil
yoma = demon
ryu = dragon

and some other "ahem" words of course ...


K.V.

I think he was asking how his avatar was on the TV.

I was watching a Clint Eastwood movie.

a language sponge

Well, more like a funnel. (I only hold onto bits and pieces for small amounts of time (but I take good notes). (And Google Translate is the only way I can 'read and write'.))

Otaku code

Whoa! I've never seen this!

s+++ (No dubbed!!!)

That's what I'm talking about!


HK!

Are you hitting ↓↓→→←← B at me?

Don't make me break out BISON!!!

(BWA-HA-HA-HA-HA!)


don't worry, I suck at the modern fighting games, I only was decent at the original street fighter 2 and like time-era-simplicity fighting games. Killer Instinct and MK (and up to now) was when I needed talent, which I don't have. I have no japanese finger dexterity... I can't do any combos that take timing and positioning and complex patterns/buttons/motions... sighs.

I love to watch the professional tournaments, though I actually still like SF3 Third Strike better than SF IV and V, not sure why, but they just don't interest me as much as Third Strike.

and man... has MK got REALLY violent... lol... I thought MK 1-3-3ultimate was violent (my early teenager years at the pizza place giving away lots of money in quarters playing KI and MK3U) ... lolololol

but amen/thanks to MK/midway, for giving us grown-up games, midway opened the floodgates to all the grown-up games we have now.


in hindsight, HK constantly bangs his head on the desk for buying SF2 (not even the 'turbo' version, this was the original SF2) when it first came out... F'N 60-70 dollars for it! (at the time, it was an "advanced" fighting game, lol), but now... HK bangs his head on the desk a final time...

also... it destroyed my thumb... tore off all my skin on my thumb (D-pad direction button on joystick/controller) trying to beat SF2 without losing... to get the "special ending scene", lol.


Actually I was referring to my avatar on your screen, K.V


K.V.

Hello, Enpherdaen!

How are you?


Your avatar is a picture of Clint Eastwood.                        


I was watching a Clint Eastwood movie on TV.

https://en.wikipedia.org/wiki/For_a_Few_Dollars_More


K.V.

@HK

don't worry, I suck at the modern fighting games

Me too!

also... it destroyed my thumb... tore off all my skin on my thumb (D-pad direction button on joystick/controller) trying to beat SF2 without losing... to get the "special ending scene", lol.

Yeah...

I vividly remember Nintendo-Thumb!


K.V I've seen the whole dollars trilogy twice, I did not know they still play it on TV.


K.V.

@Enpherdaen

Oh, sorry! I misunderstood the question.

They may not play it on TV anymore. I've had no cable, antenna, or satellite for nearly a decade (and I am SO much happier this way!).

I was just watching the Blu-ray. (Ha-ha!)


R.I.P Cable


hk ...
civilian_hour = hour_count % 12

Wouldn't it be...
civilian_hour = 1 + ((hour_count + 11) % 12)
?
Because you want it to go 1,2,…11,12,1,2…

(+11 rather than -1 because some obscure languages mess up in odd ways using the modulo operator on a negative, and it's easier to write it that way than to test if -1 would work right)


yes, thank you for correcting it


50th


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

Support

Forums