Code: Select all
/c __mod name__ game.player.print(serpent.dump(storage))
Code: Select all
/c __mod name__ game.player.print(serpent.dump(storage))
LuaGameScript::console_command_used is a read-only flag (Boolean value) that is set when the player has used a console command ('/c some_command'). When the flag hasn't been set, you will be prompted to enter the command again because that will disable achievements for that game.SLywnow wrote: ↑Sat Nov 16, 2024 10:23 am if someone will find it, i found only one solution: custom commands
use this event to run function that will change variable you need
https://lua-api.factorio.com/latest/cla ... mmand_used
Code: Select all
/c
storage.value = "x"
Code: Select all
/c
game.print(storage.value)
Code: Select all
/c
game.print("hello")
Code: Select all
/c
local condition = true
if condition then
-- only run if condition is true
game.print("hello")
end
Code: Select all
script.on_event(defines.events.on_console_command,function(event)
command(event)
end)
function command (event)
if event.command == "your_command" then
local par = splitString(event.parameters," ")
--now you can get command parameters by id, like:
local num = tonumber(par[2]) --converts second parameter into int
--checking first parameter and changing variable
if par[1] == "set" then
storage.variable = num
elseif par[1] == "add" then
storage.variable = storage.variable+num
end
end
end
function splitString(input, delimiter)
local result = {}
local pattern = string.format("([^%s]+)", delimiter)
for word in string.gmatch(input, pattern) do
table.insert(result, word)
end
return result
end