Code Snippet: What's wrong with this, please?

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

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

Code Snippet: What's wrong with this, please?

Postby Netjera » Mon Jan 25, 2010 1:32 pm

Can anyone tell me what's wrong with this please? It's giving me an "Expected end of line" error.

Dim Upper = 0
Action.CreateTimedEvent .1, "Hotspot(1).top = Upper + 1", TRUE

Those are the only two lines of code. What I'm trying to do is move the hotspot by 1 on the Y access every .1 second. I have no idea if this will work or not, because I might be misunderstanding what the "Top" attribute of the hotspot represents.

Is there a complete hotspot reference anywhere, which lists all the hotspot attributes and describes what they do? Thanks!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby juhuwoorps » Mon Jan 25, 2010 3:04 pm

if you want to move a hotspot, there's a plugin in the plugin corner.
I think it should be in the plugin pack from Lybero
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Netjera » Mon Jan 25, 2010 3:06 pm

juhuwoorps wrote:if you want to move a hotspot, there's a plugin in the plugin corner.
I think it should be in the plugin pack from Lybero


OMG, you're joking?! lol I downloaded that last night, and haven't had a chance to look at them yet. Thanks!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Re: Code Snippet: What's wrong with this, please?

Postby Lyberodoggy » Mon Jan 25, 2010 4:19 pm

Netjera wrote:Can anyone tell me what's wrong with this please? It's giving me an "Expected end of line" error.

Dim Upper = 0
Action.CreateTimedEvent .1, "Hotspot(1).top = Upper + 1", TRUE

Those are the only two lines of code. What I'm trying to do is move the hotspot by 1 on the Y access every .1 second. I have no idea if this will work or not, because I might be misunderstanding what the "Top" attribute of the hotspot represents.

Is there a complete hotspot reference anywhere, which lists all the hotspot attributes and describes what they do? Thanks!


You should definitely try the plugin, it should save you a lot of time.
Still, if you wish to know why your code didn't work as expected, it's probably because it has some math problems
first of all, the code you've written continuously asigns the value 1 to the hotspot's top property. What you really wanted was probably to increase it every time. To do that it should be looking like this:
Dim Upper = 0
Hotspot(1).top = Hotspot(1).top+Upper : Upper = Upper + 1
still, this wouldn't do the trick, since the top property works with twips and you probably wanted to measure in pixels. So in order to convert pixels to twips you need to multiply by the number of the twips each pixel has, which normally equals 15

So finally the right code is:

CreateTimedEvent 0.1, "Hotspot(1).top = Hotspot(1).top+Upper : Upper = Upper + 1",true
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Re: Code Snippet: What's wrong with this, please?

Postby Netjera » Mon Jan 25, 2010 5:58 pm

Lyberodoggy wrote:
Netjera wrote:Can anyone tell me what's wrong with this please? It's giving me an "Expected end of line" error.

Dim Upper = 0
Action.CreateTimedEvent .1, "Hotspot(1).top = Upper + 1", TRUE

Those are the only two lines of code. What I'm trying to do is move the hotspot by 1 on the Y access every .1 second. I have no idea if this will work or not, because I might be misunderstanding what the "Top" attribute of the hotspot represents.

Is there a complete hotspot reference anywhere, which lists all the hotspot attributes and describes what they do? Thanks!


You should definitely try the plugin, it should save you a lot of time.
Still, if you wish to know why your code didn't work as expected, it's probably because it has some math problems
first of all, the code you've written continuously asigns the value 1 to the hotspot's top property.


So the timer recalling itself doesn't work like a form of recursion? I thought it would start at 0, then add 1 to upper. Then when it called itself, upper would be 1, so it would add 1 again to make upper 2.

Lyberodoggy wrote:What you really wanted was probably to increase it every time. To do that it should be looking like this:
Dim Upper = 0
Hotspot(1).top = Hotspot(1).top+Upper : Upper = Upper + 1
still, this wouldn't do the trick, since the top property works with twips and you probably wanted to measure in pixels. So in order to convert pixels to twips you need to multiply by the number of the twips each pixel has, which normally equals 15

So finally the right code is:

CreateTimedEvent 0.1, "Hotspot(1).top = Hotspot(1).top+Upper : Upper = Upper + 1",true


I'm not sure I'm understanding why "Hotspot(1).top = Upper" won't work, if Upper is incremented every cycle (tick, whatever). If Upper is one, then Hotspot(1).top would be 1. If Upper is 2, then Hotspot(1).top would be 2. If you make it add Upper to Hotspot(1) each time, it will jump too much, wouldn't it? Hotspot(1).top = 0, then add Hotspot(1) and Upper, and now Hotspot(1) = 1. Add Hotspot(1) and Upper, and now you're adding (1) and (2) and getting 3, aren't you? The only way it would add 1 each time, would be if Upper wasn't incremented. Or am I misunderstanding something somewhere?

Incidentally, what's a "twip"?

Thanks for all the patience!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Lyberodoggy » Mon Jan 25, 2010 7:53 pm

in order for the timer to increment the variable, it needs an according comand.
In VBS the right command is variable=variable+value (while in C you can just type variable+=value or if value is 1 just variable++)

Your second question can be also answered with the above explanation. You need to increase Hotspot(1).top by the value of Upper, so you have to type Hotspot(1).top = Hotspot(1).top+Upper.
Writing just Hotspot(1).top = Upper assigns a "constant" value to Hotspot.top unless upper is increased and if it is increased then it just sets Hotspot(1).top to its value instead of increasing it.
It's not similar to maths, that's why you get confused. Here the expression variable=something isn't an equation, it's a command that tells the cpu to assign a value to the variable. So x=-x+2 doesn't mean x=1. Instead it gets the current value of x (let's say 5) and then puts it in there, so what is actually being done is x=-5+2 and then -5+2 is the new value of x


A twip is a means to measure distances on one's monitor.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Re: Code Snippet: What's wrong with this, please?

Postby mercedes » Tue Jan 26, 2010 4:48 pm

Is there a complete hotspot reference anywhere, which lists all the hotspot attributes and describes what they do? Thanks!


Here is a link..that might help..:)

http://www.adventuremaker.com/phpBB2/viewtopic.php?t=4594&highlight=hotspots+properties
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Netjera » Tue Jan 26, 2010 5:39 pm

OMG Thank you, thank YOU, THANK YOU!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron