Page 1 of 1

Can other commands be run withing a /c

Posted: Thu Apr 08, 2021 12:18 pm
by bigmond
When running a lua script with /c is there a way to run other commands withing the script.

My intention is to run a command from a mod but I guess the question applies to running any commands inside a /c lua script

Lets say this command for example

Code: Select all

/muppet_streamer_schedule_explosive_delivery {"explosiveCount":7, "explosiveType":"grenade", "target":"muppet9010", "accuracyRadiusMin":10, "accuracyRadiusMax":20}
Lets say for example I want to get an array of all players on the map and then loop through them using each entity as the target. How do I run this command from within a /c script.

Re: Can other commands be run withing a /c

Posted: Thu Apr 08, 2021 4:23 pm
by jodokus31
Might be helpful:

Code: Select all

/c for _,player in pairs(game.players) do 
   game.print(player.name) 
end
I'm not sure, if the mod command is callable inside that, maybe you have to call the function name directly

Re: Can other commands be run withing a /c

Posted: Thu Apr 08, 2021 6:18 pm
by eradicator
No. According to the API doc LuaCommandProcessor does not have any method to call or retrieve the function associated with a command. In earlier versions it might've been possible to trigger it by raising on_console_command, but that's been blocked after 0.18.27. To be callable from script the implementing mod must offer a remote interface.