Pokemon-style berry plant things?
Moderators: marionline, SDHawk
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
Oh, that makes sense. I double-checked and yes, "next NPC reference" only loops through currently visible NPCs.
But I know another way to do this. Try this:
The negative ref numbers from -300 to -1 are the valid range of possible NPC numbers, and I know that unlike non-existent NPC ID numbers, nonexistant NPC ref numbers are safe and will not produce any error message (I know this because I do it a lot in my own games)
Let me know if this solves the problem.
But I know another way to do this. Try this:
Code: Select all
plotscript, berryRefillUpdate, begin
variable(i, g)
for (i, berryArrayStart, berryArrayEnd) do (
g := readGlobal(i)
if (g > 0) then (
writeGlobal(i, g -- 1)
)
)
variable(ref, arg, tag)
for (ref, -300, -1) do (
arg := readNpc(ref, NpcStat:scriptargument)
if (arg >= berryArrayStart && arg <= berryArrayEnd) then (
g := readGlobal(arg)
if (g == 0) then (
tag := abs(readNpc(ref, 9))
setTag(tag, off)
)
)
)
end
Let me know if this solves the problem.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
Oops!
I said I used this method in my own scripts, but I should have looked more closely at my own scripts:
Try this:
The part that checks if(get NPC id(ref) >= 0) makes sure that the NPC reference is valid before it uses it.
I said I used this method in my own scripts, but I should have looked more closely at my own scripts:
Try this:
Code: Select all
plotscript, berryRefillUpdate, begin
variable(i, g)
for (i, berryArrayStart, berryArrayEnd) do (
g := readGlobal(i)
if (g > 0) then (
writeGlobal(i, g -- 1)
)
)
variable(ref, arg, tag)
for (ref, -300, -1) do(
if(get NPC id(ref) >= 0) then(
arg := readNpc(ref, NpcStat:scriptargument)
if (arg >= berryArrayStart && arg <= berryArrayEnd) then (
g := readGlobal(arg)
if (g == 0) then (
tag := abs(readNpc(ref, 9))
setTag(tag, off)
)
)
)
)
end
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact: