Page 1 of 1

What to use for scripting?

Posted: Tue Nov 22, 2022 12:07 am
by LeonardMT
I want to have a square bounty arround an oil field and I want it to play a play a one time PlaySpeechNotification when a unit enters. What to use? Map.ActorsInBox or Trigger.OnEnteredFootprint? Both seem like they can work just fine.

Re: What to use for scripting?

Posted: Tue Nov 22, 2022 6:02 pm
by Adrian
I play here in Dune 2000 only (sometimes). So don't quite understand your problem.

I use both functions Map.ActorsInBox and Trigger.OnEnteredFootprint succefully in my mods. If your need just working example, then I can right it down.

Re: What to use for scripting?

Posted: Tue Nov 22, 2022 6:22 pm
by Adrian
Example of Map.ActorsInBox

We can repair units of tech but we cannot do the same for human units.
So I made place for hospital. Healing place (I call it “lechebnica”) .

Code: Select all

-- place for hospital (mesto pod lechebnicu),
-- where variable “verh” is left-top of square 
-- and variable “niz” is right-bottom.

verh = WPos.New(91*1024, 79*1024, 0)
niz = WPos.New(93*1024, 81*1024, 0)

Tick = function()

  -- lechebnica ---------------------

  pacient = Utils.Where(
    Map.ActorsInBox (verh, niz), 
    function(actor) return actor.Type == "light_inf" 
                    or actor.Type == "trooper" 
                    or actor.Type == "sardaukar" 
                    or actor.Type == "engineer" 
                    or actor.Type == "fremen" 
                    and actor.Owner == player 
  end)

  if (#pacient>0) then 
    pacient[1].Health = pacient[1].MaxHealth
  end

  -- ---------------------
First (and only one) actor, who comes to the square gets MaxHealth.

Re: What to use for scripting?

Posted: Wed Nov 23, 2022 7:20 am
by LeonardMT
Ah thank you I misunderstood what Map.ActorsInBox did it returns actors and doesn't act like a trigger, so I should use Trigger.OnEnteredFootprint. You saved me a lot of time!

Re: What to use for scripting?

Posted: Wed Nov 23, 2022 12:11 pm
by Adrian
My syntax error
Adrian wrote:
Tue Nov 22, 2022 6:02 pm
... then I can right it down.
I mean "write down".