Post new topic    
Metal Slime
Send private message
hero X () and hero Y () don't do what they should? 
 PostWed Nov 24, 2010 3:28 pm
Send private message Reply with quote
This might just be a user error, which is why I'm not reporting a bug, but it seems to be referring to the wrong hero?

I'm referring to a hero, and I'm trying to create an NPC two to the right of him. So, I use hero X and such. And it works fine, except it seems to be referring to a different hero - one that doesn't even exist. It's relative to the last slot in the caterpillar (even though I only have heroes in the first two slots)

Now, one thing is that earlier in the game, a few scenes back, this hero was in the last slot, but two heroes were removed and he was swapped to the front. This might have something to do with it?

Here is the offending line:

create npc (2, hero X (hero:Eron) + 2, hero Y (hero:Eron), west)

And here is how I swapped earlier:

swap by position(0, find hero(hero:Eron))

I'm using the latest nightly.

(On a related note, since I'm already asking about scripting - how do you force a hero who is in a vehicle to move. walk hero (me...) or walk npc (the vehicle) or what?)
Liquid Metal Slime
Send private message
 
 PostWed Nov 24, 2010 3:54 pm
Send private message Reply with quote
You need to use findhero() to find the position of the hero.
For example:

herox(findhero(hero:bob)) will give you the X position of Bob.

I recommend using variables instead of stacking code.
My website, the home of Motrya:
http://www.jshgaming.com
Metal Slime
Send private message
 
 PostWed Nov 24, 2010 4:02 pm
Send private message Reply with quote
Ugh yeah that'll do it - I'm an idiot. Thanks.

I use variables when I refer to things more than once, otherwise I just stack the code and use a comment so I know what it's doing.

Not that it's a bad thing, but hamster speak has waaaaay more pointers/references and things like that than any other language I've used. It's almost more confusing than higher level Java in that regard.
Liquid Metal Slime
Send private message
 
 PostWed Nov 24, 2010 4:28 pm
Send private message Reply with quote
Mystic wrote:
Ugh yeah that'll do it - I'm an idiot. Thanks.

I use variables when I refer to things more than once, otherwise I just stack the code and use a comment so I know what it's doing.

Not that it's a bad thing, but hamster speak has waaaaay more pointers/references and things like that than any other language I've used. It's almost more confusing than higher level Java in that regard.


Definitely. Also it overuses parentheses like crazy, heh.
My website, the home of Motrya:
http://www.jshgaming.com
Display posts from previous: