Post new topic    
Liquid Metal Slime
Send private message
Twinconclusive's scripting issues 
 PostThu Feb 04, 2010 8:43 pm
Send private message Reply with quote
After pressing the spacebar, the script 'Activation' is supposed to see if the hero is close enough to an NPC to activate it.
If the conditions are met, then the script 'Check' is run to toss out the result of such an interaction.

Right now, the loop compares the locations of the hero and NPC's 0-17.

[edit]The script actually doesn't display properly on the forums for some reason. Leaving the posted text version here in case it's actually relevant.



Code:
script, Activation, begin
variable(counter)

for (counter, 0, 17, 1)
do(

if(
(hero pixel X (me) + 10) >> (npc pixel x (counter) -- 10) , and,
(hero pixel Y (me) + 10) >> (npc pixel y (counter) -- 10) , and,
(hero pixel X (me) + 10) <<npc>> (npc pixel y (counter) + 30)
)

then(
Check (counter, current map)
counter := 17
)

)

end

Code:
script, Check, npc, map, begin
if(map == 1)
then(

if(npc == 0)
then(
show text box (16)
wait for text box
)

)
end


However, even when the conditions are met, the script doesn't seem to acknowledge it.



NPC 0 should be activated from the pixel x-coordinates of 810-850 and pixel y-coordinates of 1350-1390.

Any insight would be appreciated, thanks.

[edit]
Tried testing 'Activation' with a true statement in place of the huge 'if' condition, and the rest of the scripts worked fine.

So the issue is most probably in there.

[edit]
Tried changing the 'if' condition to:
Code:
if(
(npcpixelx(counter) -- 10) << (hero pixel X (me) + 10) << (npcpixelx(counter) + 30)
&&
(npcpixely(counter) -- 10) << (hero pixel Y (me) + 10) << (npcpixely(counter) + 30)
)


Now it's always true Gonk
Am thinking X<<Y<<Z doesn't mean what I think it means.
Super Slime
Send private message
Re: Script Aid Request: Npc Activation by Pixel coordinates 
 PostThu Feb 04, 2010 9:14 pm
Send private message Reply with quote
Right, you can't do "x << y << z" or similar. The image version you posted looks the most correct.

Your methodology is a little odd. In particular:
Code:
(heropixelx(me) + 10) >> (npcpixelx(counter) -- 10)
is the same as
Code:
heropixelx(me) >> (npcpixelx(counter) -- 20)


That shouldn't make any difference, but one is clearer (to me) than the other.

Dumb question: are you actually on map 0? Try adding "showvalue(npc)" to the beginning of your check script to see whether it's executing.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Gameathon 2009 Winner
Send private message
 
 PostThu Feb 04, 2010 9:16 pm
Send private message Reply with quote
A first glance suggests that you have a greater than comparison where you need a less than comparison in your if statement.

Specifically, you're testing if (hero pixel Y(me) + 10) >> (npc pixel y(counter) -- 10) and if (hero pixel Y(me) + 10) >> (npc pixel y(counter) + 30)

Just replace the second '>>' with a '<<' and hopefully that'll do the trick!
Liquid Metal Slime
Send private message
 
 PostThu Feb 04, 2010 9:23 pm
Send private message Reply with quote
Quote:
Dumb question: are you actually on map 0?

Think you mean map 1, but tried out the 'show value' suggestion and I am indeed in the right place.

The messy math was just kind of left over from me trying to envision the center of the sprites. V

Oh, while checking to see if the map was correct, I found the sweet spot for activating this guy.



Zombie

Looks like the x-conditions are working at the least.

Quote:
Specifically, you're testing if (hero pixel Y(me) + 10) >> (npc pixel y(counter) -- 10) and if (hero pixel Y(me) + 10) >> (npc pixel y(counter) + 30)

Just replace the second '>>' with a '<<' and hopefully that'll do the trick!


Oh! That did it.
Thanks a lot Angel
Display posts from previous: