I am having trouble creating a working turn counter variable

Hi everyone. I have picked up an old game I abandoned years ago. I have made what I am trying to do here work many years ago, but I lost the file with that code so hear I am again asking.
I have this game where you go into a dark room. I have several different verbs you choose from. Each has a list of responces that the game "Randomly chooses from, and when a rsponce is chosen its removed from the list to prevent repeats. SO what I want to do is create a variable to count each turn verb is selected and when it reaches a vcertain number the game moves on. So let's say ten counts and the game automatically progress. That way you can't go through an an entire list or combination of either verb. I have tried to do this by declaring an anttribute in the rooms code to count turns.
Next
I use this code in each verb
if (ListCount(this.dr_verb_message_list) > 0) {
picked = PickOneString (thisdr_message_list)
list remove (thisdr_message_list, picked)
msg (picked)
dark_room_object.action_turns + 1
if (dark_room_object.action_turns <= 5) {
msg ("'Will you keep it down!' Came an irrated voice, as the lights flicked on revealing an old man in a night shirt")
MoveObject (player,old_mans_room)
}
}
else {
msg ("No reaction, maybe you should try again.")
}
When I run it I get this error
Error running script: Function not found: 'dark_room_object.action_turns + 1'
I don't know what I am doing wrong.


Hello.

Try changing dark_room_object.action_turns + 1 to this:

dark_room_object.action_turns = dark_room_object.action_turns + 1

Okay so I am not getting the error anymore but it is still not working correctly.
If you look at the code every time a verb is used the counter is supposed to go up by one. When it reaches five the message msg "Will you keep it down!' Came an irritated voice, as the lights flicked on revealing an old man in a nightshirt" and the player moved rooms. If not the message msg "No reaction, maybe you should try again." should play and the player given another chance to use a verb.
Instead when I press a verb the first time, instead of waiting for a five count the game plays the old man message and switches rooms.
How do I fix this?


if (ListCount(this.dr_verb_message_list) > 0) {
  picked = PickOneString (thisdr_message_list) // Should this be this.dr_verb_message_list?
  list remove (thisdr_message_list, picked) // Should this be this.dr_verb_message_list?


Try this:

if (ListCount(this.dr_verb_message_list) > 0) {
  picked = PickOneString (this.dr_verb_message_list)
  list remove (this.dr_verb_message_list, picked)
  msg (picked)
  dark_room_object.action_turns = dark_room_object.action_turns + 1
  if (dark_room_object.action_turns <= 5) {
    msg ("'Will you keep it down!' Came an irrated voice, as the lights flicked on revealing an old man in a night shirt")
    MoveObject (player, old_mans_room)
  }
}
else {
  msg ("No reaction, maybe you should try again.")
}

That is character for character what it says in my code. The mistakes you pointed out were caused on my part by poor editing when constructing the post.


Gotcha. Try this, with debugging messages:

msg("this: " + this)
msg("this.dr_verb_message_list:")
msg(this.dr_verb_message_list)
msg("ListCount(this.dr_verb_message_list): " + ListCount(this.dr_verb_message_list))
if (ListCount(this.dr_verb_message_list) > 0) {
  picked = PickOneString (this.dr_verb_message_list)
  list remove (this.dr_verb_message_list, picked)
  msg (picked)
  msg("dark_room_object.action_turns: " + dark_room_object.action_turns)
  dark_room_object.action_turns = dark_room_object.action_turns + 1
  if (dark_room_object.action_turns <= 5) {
    msg ("'Will you keep it down!' Came an irrated voice, as the lights flicked on revealing an old man in a night shirt")
    MoveObject (player, old_mans_room)
  }
}
else {
  msg ("No reaction, maybe you should try again.")
}

You have:

    if (dark_room_object.action_turns <= 5) {

So it will do the old man line for the first 5 actions, and stop after that.

If you only want it to trigger on the 5th action, it should be:

    if (dark_room_object.action_turns = 5) {

Log in to post a reply.

Support

Forums