Jump to content

'On active changed' problem for tasks


eirikub

Recommended Posts

I am trying to build a Wherigo in Urwigo and suddenly met a problem. I have some code that I want to execute when a task becomes active, and only then. Urwigo only lets me add code to an 'On active changed' event, i.e. so that it is set to be executed also when I set 'Active' to false.

 

My problem is that this task needs 'Active' to be disabled and enabled several times and to execute the same bit of code every time it is set to true, but only then.

 

It would be much easier if the events were split into 'On active enabled' and 'On active disabled'. Does anybody have a suggestion for how to solve this?

Link to comment

Yes. Use a if to check, if Active is true or false.

 

I have already tried to start the 'On active changed' code with 'if Active is true, execute code, else do nothing', but this did not help. Is there anywhere else that I could add this if or the code as a whole. I think part of the problem is that the code is looping in some kind of way when I try to tweak the 'Active' status inside an event that is dependent on it...

Link to comment

Normally the OnSetActive gets a parameter, which contains the new value. This didn't work in Urwigo. So you should check for the old value of Active. When you want to react if the status change from inactive to active, than you should check, if Active is false.

 

I made a short cartridge, where you could see, what you should do. There is a task and a item with the command "Toggle". Use the command to change the Active status of the task. The new status is checked in OnSetActive and you get a message with the new status.

Link to comment

Thank you. I have tried to fit this code in with my code, but all I got was error messages when I tried to run the cartridge. I will try to describe in detail how I want it to be.

 

1. Initially, the task is not shown, i.e. not active.

2. The user comes to a zone where he chooses between several categories of tasks (which are fetched from input questions) by the use of commands.

3. The user chooses one of the commands, and the corresponding task is set to active. The question is thus prompted.

4a. If the user gives the correct answer, there is no problem, because there is no use for this task anymore.

4b. The problem is when the user gives the wrong answer. Then I want the task to be set to inactive without anything else happening.

5b. The user gave the wrong answer, so I need to be able to set the task to active again later in the game. In principle, this needs to work over and over again until the user gives the correct answer to that category.

 

This is basically a trivia-like Wherigo with the zones as the fields of a board game.

Edited by eirikub
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...