What to use for scripting?

What to use for scripting? Map.ActorsInBox or Trigger.OnEnteredFootprint?

Information and discussion for custom maps and mods.
Post Reply
LeonardMT
Posts: 19
Joined: Tue Jan 12, 2021 2:38 am

What to use for scripting?

Post 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.

Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Re: What to use for scripting?

Post 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.

Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Re: What to use for scripting?

Post 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.

LeonardMT
Posts: 19
Joined: Tue Jan 12, 2021 2:38 am

Re: What to use for scripting?

Post 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!

Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Re: What to use for scripting?

Post by Adrian »

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

Post Reply