Jump to content


Replying to Scar Group objects Question along with other Scar Questions


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

YOUSLESS

Posted 26 June 2022 - 05:57 AM

Thank you again Gambit 


Gambit

Posted 26 June 2022 - 05:41 AM

Hello again brother.

 

...for example Player_GetEntities returns an Egroup, and I wonder if I can randomly select individual entities in the Egroup.

To select an individual entity, you need to us the EGroup_GetSpawnedEntityAt function.

Here is an example:

EGroup_Clear(EGroup_CreateIfNotFound("eg_TheNameYouWannaCallIt"))
local total = EGroup_CountSpawned("eg_TheNameYouWannaCallIt") -- All the entities of the EGroup
local rnd =  World_GetRand(1,total) -- Indexing starts from 1.
local entityID = EGroup_GetSpawnedEntityAt("eg_TheNameYouWannaCallIt",rnd)

... Or something. :grad:
The entityID  is of course a random entity, chosen from the EG.

 

 

 

 

Aside from these group objects I've been trying to print the players name with Player_GetDisplayName. But it prints out "table: 312B0D10" does this mean the LocString object is a table? and if so how do I get the display name out of it?

Player_GetDisplayName, indeed returns an array with more info. What you seek is the first element of that array. In other words:

local player_name = Player_GetDisplayName(playerID)[1]

 

And lastly I've been trying to get an alert to show up with the following line:
UIWarning_Show("hello World")

but it seems it doesn't do anything, I feel I'm missing something but I don't know what.

Try:

Util_MissionTitle("hello World")

... But remember, if a different event is running, then you may miss this one...

There is an alternative for this. You can try calling a function from your current function:

function YOUR_FUNCTION()
...
    Rule_Add(Rule_Display_Your_Message)
...
end


function Rule_Display_Your_Message()
    if not Event_IsAnyRunning() then
        Util_MissionTitle("hello World")
        Rule_Remove(Rule_Display_Your_Message)
    end
end

YOUSLESS

Posted 26 June 2022 - 12:18 AM

also, can you use lua extensions in SCAR? I want to use the socket library so my scar script can talk to a python script running locally
 

EDIT: I tried using the io library and I got an "attempt to index a nil value" from that does SCAR have its own io?


YOUSLESS

Posted 25 June 2022 - 09:21 PM

I'm working with several functions that return these group objects. for example Player_GetEntities returns an Egroup, and I wonder if I can randomly select individual entities in the Egroup. It doesn't seem like it works like a standard Lua table with some added functionality. I've been looking around the groups.scar file and groupcallers.scar file and there doesn't seem to be any underlying data structure I can access.

Aside from these group objects I've been trying to print the players name with Player_GetDisplayName. But it prints out "table: 312B0D10" does this mean the LocString object is a table? and if so how do I get the display name out of it?

And lastly I've been tryong to get an alert to show up with the following line:
UIWarning_Show("hello World")

but it seems it doesn't do anything, I feel I'm missing something but I don't know what.

Thanks in advance.


Review the complete topic (launches new window)