Can other commands be run withing a /c

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
User avatar
bigmond
Inserter
Inserter
Posts: 28
Joined: Fri Aug 30, 2019 11:11 am
Contact:

Can other commands be run withing a /c

Post 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.
Please no more spagetti, I cant eat any more.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: Can other commands be run withing a /c

Post 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
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Can other commands be run withing a /c

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Technical Help”