[Ohrrpgce] SVN: james/6358 New plotscripting command "NPC is disabled" for detecting when an NPC re
Ralph Versteegen
teeemcee at gmail.com
Sun Feb 2 14:05:20 PST 2014
On 3 February 2014 06:29, James Paige <Bob at hamsterrepublic.com> wrote:
> Actually, we do have a way of testing if an NPC doesn't exist at all
>
> if(get NPC id(ref) == -1) then()
>
> My use case for "NPC is disabled" is when I am looping through all possible
> NPC ids, and doing actions on them based on their NPC id
>
> script, create objects from npcs, begin
> variable(ref, pic, sl, nd, d, item)
> for(ref, -300, -1) do(
> sl := 0
> if(get NPC id(ref) >= 0 && not(NPC is disabled(ref))) then(
> pic := read npc(ref, NPCstat:picture)
> nd := npc direction(ref)
> switch(nd) do(
> case(left, right) do(
> sl := create monster by id(pic)
> if(nd == left) then(d := -1)
> if(nd == right) then(d := 1)
> )
> case(up, down) do(
> sl := create monster spawner(pic)
> if(nd == up) then(d := -1)
> if(nd == down) then(d := 1)
> )
> )
> )
> if(sl) then(
> set slice x(sl, npc x(ref) * 20 + 10)
> set slice y(sl, npc y(ref) * 20 + 19)
> set direction(sl, d)
> )
> destroy npc(ref)
> )
> end
>
> But if you think it would be best to make "NPC is disabled" return true for
> non-existant NPCs too, I can easily make that change.
>
> ---
> James
Ah.
Returning true for invalid references seems like a useful convenience,
but not needed.
> On Sun, Feb 2, 2014 at 12:22 AM, Ralph Versteegen <teeemcee at gmail.com>
> wrote:
>>
>> I notice that this returns false if the NPC doesn't exist at all. (And
>> I assume that the intention is that if we had a better switch to
>> enable script warnings, then this would throw a warning/error
>> instead.)
>> But we don't seem to have a direct way to check whether an NPC
>> reference is valid at all. It would be useful.
>>
>> On 2 February 2014 16:54, <subversion at hamsterrepublic.com> wrote:
>> > james
>> > 2014-02-01 19:54:52 -0800 (Sat, 01 Feb 2014)
>> > 119
>> > New plotscripting command "NPC is disabled" for detecting when an NPC
>> > reference is disabled by tags or by one-time-use
>> > ---
>> > U wip/const.bi
>> > U wip/docs/plotdict.xml
>> > U wip/docs/plotdictionary.html
>> > U wip/plotscr.hsd
>> > U wip/whatsnew.txt
>> > U wip/yetmore.bas
>> > _______________________________________________
>> > Ohrrpgce mailing list
>> > ohrrpgce at lists.motherhamster.org
>> > http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>> _______________________________________________
>> Ohrrpgce mailing list
>> ohrrpgce at lists.motherhamster.org
>> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>
>
>
> _______________________________________________
> Ohrrpgce mailing list
> ohrrpgce at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>
More information about the Ohrrpgce
mailing list