Delaying Variable Actions

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Delaying Variable Actions

Postby GORDON » Wed Jan 18, 2012 11:25 pm

I know how to make as an example: "hotspot 21" visible if "hold1" & "bulb1" have var values of "1" but can this action be delayed for 2 seconds? Thanks in advance!
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 1:44 am

If you want a time delay "before" you set the variables, the following will work.

Code: Select all
if hold1 = 1 and bulb1 = 1 then
    Action.CreateTimedEvent 2, "Action.LoadAPicture Hotspot(1), ""mypic_file""", false
end if
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Thu Jan 19, 2012 3:33 am

Actual code: if hold1 = 1 and bulb1 = 1 then Action.CreateTimedEvent 2, "Action.LoadAPicture Hotspot(21), ""BULBINHOLDER.jpg
""", false
end if
I keep getting an error message " Unterminated string constant"
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 4:46 am

I tested your code and didn't get the error. Please use the code tags to show your code so I can see EXACTLY how you entered it.



Code: Select all
if hold1 = 1 and bulb1 = 1 then
    Action.CreateTimedEvent 2, "Action.LoadAPicture Hotspot(21), ""BULBINHOLDER.jpg""", false
end if
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Thu Jan 19, 2012 5:05 am

It works without the error now but the timed event will not work. It goes immediately to the hotspot with no delay? Because I am using code do I need to change the original variable tab setup? I copied the code into the advanced tab in my hotspot.
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 5:20 am

Once the 2 variables equal 1, then there should be a 2 second delay before hotspot 21 has an image displayed.

This is what you intended. right?

I tested it and it worked for me.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Thu Jan 19, 2012 5:38 am

I realized my problem. I already had frame 21 with a picture. Once I set it to transparent it worked. If this hotspot was already hidden , I guess I wouldn't need to ask for the picture, just the hotspot?
Thanks! You have a lot of patience.
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 11:59 am

I set my test hotspot transparency programmatically from the Frame properties - advanced tab by using:

Action.LoadAPicture Hotspot(21), ""

but, you probably don't want to work that way! :)
I'm glad you have it working!
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Thu Jan 19, 2012 9:18 pm

It seems like the variables have to be triggered in the exact order that is in the code [hold1=1 and bulb1=1]. If "bulb 1 is triggered first then "hold 1", it will not work. I would like the hotspot to appear having the variables triggered in any order. Thanks!
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 10:11 pm

The code as it is written will work in any order. The problem is probably where you are setting the variables to 1. I'd have to see how you coded your project. If you want, I can upload a sample project.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Thu Jan 19, 2012 10:45 pm

I guess the problem arose when I used this code for three items:
if bulb1 = 1 and hold1 = 1 and front1 = 1 then
Action.CreateTimedEvent 1, "Action.LoadAPicture Hotspot(22), ""BULBHOLDERFRONT.jpg""", false
end if
My code for using three items might be incorrect or somehow I'm setting my variables wrong.
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Thu Jan 19, 2012 10:55 pm

Code: Select all
if bulb1 = 1 and hold1 = 1 and front1 = 1 then
    Action.CreateTimedEvent 1, "Action.LoadAPicture Hotspot(22), ""BULBHOLDERFRONT.jpg""", false
end if



This condition is correct if all 3 variables MUST equal 1 before the action occurs. Did you leave the frame before all 3 conditions were met? It might be that the variables are getting reset to 0 at some point.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Fri Jan 20, 2012 3:46 pm

In this scenario:
back1=0 bat1=0
If back1=1 bat1=1 Hotspot15 with BATTERYINBACK.jpg appears
Works perfectly whether back1=1 is clicked first or second[no code]
When I use the code:
if back1 = 1 and bat1 = 1 then
Action.CreateTimedEvent 1, "Action.LoadAPicture Hotspot(15), ""BATTERYINBACK.jpg""", false
end if
If back1=1 is first then bat1=1 is second it will not work
but works perfectly with 1 sec. delay if bat1=1 is first then back1=1 is
second.
Any ideas what is wrong?
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Fri Jan 20, 2012 4:25 pm

Try this for me:

Add the following msgbox line just before your if condition and tell me what the results are when you test back1 and bat1 click order.

Code: Select all
msgbox "back1 = " & back1 & vbcrlf & "bat1 = " & bat1
if back1 = 1 and bat1 = 1 then
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Fri Jan 20, 2012 5:32 pm

Error: Expected "If"
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Fri Jan 20, 2012 5:47 pm

LOL. I meant for you to finish the if condition completely...add the action and the end if

Code: Select all
msgbox "back1 = " & back1 & vbcrlf & "bat1 = " & bat1
if back1 = 1 and bat1 = 1 then
    Action.CreateTimedEvent 1, "Action.LoadAPicture Hotspot(15), ""BATTERYINBACK.jpg""", false
end if



Test 1:
- set back1 = 1
- set bat1 = 1
results?

Test 2:
- set bat1 = 1
- set back1 = 1
results?

The msgbox will display the variable status just before they are tested by the if condition. What you will find is that bat1 is NOT getting set to 1 when you expect it.

I think after this test you will see that bat1 is getting altered somewhere in your game or losing its value because of scope (but that is more doubtful).

I'm interested in seeing if bat1 is anything besides 1 or 0. if it is, we can adjust the if condition to fix this.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby GORDON » Fri Jan 20, 2012 6:20 pm

error:cannot call this method while the script is executing
Cannot find another script that I had entered?
GORDON
Advanced Member
 
Posts: 154
Joined: Mon Apr 30, 2007 1:36 am
Location: Canada

Postby reneuend » Fri Jan 20, 2012 7:26 pm

That error shows up when another process in the game is running at the same time when it is trying to execute a new one.

I think at this point, I'd have to get a copy of your project files and figure out how you are using back1 and bat1.

I can send you a sample project that shows how to use this delay, but I think you'll find that there is something else in your code that is not setting bat1 to 1 when you expect it.

(edit) I tested this in my test project iand it worked fine.
Next step:
Do you want my test project?
or
Do you want to send me your project files?
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby mercedes » Fri Jan 20, 2012 10:25 pm

GORDON wrote:error:cannot call this method while the script is executing
Cannot find another script that I had entered?


it could be anything at all...Variable tab...Advanced tab..Procedure..

perhaps you have one of those variables still in the variable tab...
Usually it has to do with timed events/variables...and sounds..These are things I double check..
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests