Post new topic    
Red Slime
Send private message
More scriping trouble 
 PostThu Jul 21, 2011 10:58 pm
Send private message Reply with quote
Hi, We are still having trouble with the hayfield only this time it is getting the hay to the wagon once, so people can't do this quest later unless they never did it before. This was the code including the mouse code because it used in this and the code for the hay wagon. Also it uses two global variable Haybegin and Numofhay

Code:
Script, InGameMouse, begin
  set slice x (mouse, mouse pixel x)
  set slice y (mouse, mouse pixel y)

  if (HayBegin) then (hay)

  slice to front (mouse)
  set timer (timer: mice, 0, 1, @InGameMouse)
end

Script, hay, begin
  if (NPC at spot (41, 7, 16)) then ((destroy NPC (16)), (NumofHay := NumofHay + 1))

end

script, map1autorun, begin
  haybegin := true
  InGameMouse
  variable (wagon, map layer)

  wagon := load large enemy sprite (0)
  map layer := lookup slice(sl:map layer 0)
  set parent(wagon, map layer)
  put slice (wagon, 850, 50)   
end


Thanks.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Liquid Metal King Slime
Send private message
 
 PostThu Jul 21, 2011 11:28 pm
Send private message Reply with quote
Well, as always, helping people with scripts like this is really hard because the details of the game are unknown to me. If I could see the game, or even a test case video of what is currently happening and an explanation of what you wish was happening I'd be able to fix the problem in no time.
Anyways, it seems like the problem is that you can't repeat the process, correct? This might be because you don't make the variable HayBegin false again, after making it true and completing the task.
I also noticed this:
NPC at spot (41, 7, 16)
That last number seems to be the npc ID you're trying to work with. When in fact that last number is the layer number of the npc. You'll almost always want to have that last number be a 0. Unless you're stacking npc's. I think you're looking for something like this instead:
Code:

Script, hay, begin

  variable(thehay)
  thehay := NPC reference(16,0)

  if (NPC at spot (41, 7, 0)==thehay) then ((destroy NPC (16)), (NumofHay := NumofHay + 1))

end


I'd love to help more, but that's all I could really decipher from your script.
Liquid Metal King Slime
Send private message
 
 PostFri Jul 22, 2011 4:13 pm
Send private message Reply with quote
The last argument of NPC at spot is not the NPC reference or ID, and it is not the map layer. It is actually the NPC copy count.

Code:
NPC at spot (41, 7, 16)


This means that if there are 17 NPCs all overlapping each other on tile 41, 7 then the last one will be returned. (the 17 NPCs would be counted from 0-16 which is why 16 means 17th)

Perhaps something like this would be more correct?:

Code:
Script, hay, begin
  variable(n)
  n := NPC at spot (41, 7)
  if (get NPC ID(n) == 16) then (
    destroy NPC (n)
    NumofHay := NumofHay + 1
  )
end
Liquid Metal King Slime
Send private message
 
 PostSat Jul 23, 2011 12:21 am
Send private message Reply with quote
That's totally what I just wrote
Liquid Metal King Slime
Send private message
 
 PostSun Jul 24, 2011 7:03 pm
Send private message Reply with quote
Spoonweaver wrote:
That's totally what I just wrote


Oh, right! So you did! I misread "When in fact that last number is the layer number of the npc" to mean something you didn't mean :)
Red Slime
Send private message
 
 PostThu Jul 28, 2011 11:39 pm
Send private message Reply with quote
Thanks Spoonweaver and James,

We need the characters doing this quest to move hay to the wagon and when they get it there for the hay to disappear. Furthermore, we want them not to repeat this quest after they saved the game.

These pictures might help:





We would like to create this for ten to twenty bales in the field; each being dragged over and disappearing into the wagon in turn. When the character completes this they then return to the farmer and gain exp and get gold.

Right now the hay moves to the spot and that is it; it doesn't disappear although it can be moved afterward.

Does this help at all?
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Metal King Slime
Send private message
 
 PostMon Aug 01, 2011 8:17 am
Send private message Reply with quote
James' hay script should definitely work. If it doesn't, check:
-the position x=41,y=7 is correct
-the hale bales really are NPC ID 16
-there is no other NPC at 41,7

I assume the mouse works, indicating that the InGameMouse and hay scripts are being run.

As for making the task nonrepeatable, there's quite a lot of different ways to do that, for example:
-when entering the map, you could delete NumofHay copies of the hay bale NPC (but not necessarily the same hay bales which the player moved to the wagon)
-you could track whether each hay bale has been moved to the wagon using a separate tag or global variable, and delete the NPCs you've already moved to the wagon when you enter the map
-you could store the exact position of each hay bale in global variables, so that nothing changes when you save and load.

Also, for #1 and #2 above, you can set the map to remember NPC positions so that NPCs are only reset to their original positions when you save and load the game, not every time you renter the map (the scripts will have to be adjusted to only delete NPCs the first time you enter the map after loading)

So which one would you like?
Red Slime
Send private message
 
 PostThu Aug 04, 2011 11:24 pm
Send private message Reply with quote
TMC,

You have some good ideas which we probably should have thought to do ourselves. It is likely we have that position wrong which would explain why the script is not working: however, right now we've stopped working on the game to put together a music book for our church. Sorting music that is in the public domain is very time consuming.

Still, if time allows we try to get back to the engine and check those locations. Thank you again for your suggestion and we will get back to you.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Display posts from previous: