I would like to execute a chat command that I have made in a way like this:
if buy == true then
<execute command>
end
The outcome of the command is already defined. I imported it from another program but whenever I try to mimick the code into an if statement, it will have many problems as other parts of the program need to run which are too complex for me to understand. It would be easier if there was a way to execute the command in the code and just program how and when to launch. Whoever helps me on this will get credit in my project. Thank you and God bless.
[Solved] How do I execute commands within a mod at a given time?
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
[Solved] How do I execute commands within a mod at a given time?
Last edited by ChristienChapman on Thu Jun 23, 2022 15:22, edited 1 time in total.
- Blockhead
- Member
- Posts: 1699
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: How do I execute commands within a mod at a given time?
You should be able to do this by calling the function that is registered to the chatcommand with the right parameters. For instance, to call /giveme air 1 as singleplayer:
You should probably store the function for later, for instance:
Code: Select all
minetest.registered_chatcommands["giveme"].func("singleplayer", "air 1")
Code: Select all
local giveme_chatcmd= minetest.registered_chatcommands["giveme"].func
...
local function give_player_stuff(name, item, qty)
giveme_chatcmd("singleplayer", item .. " " .. tostring(qty))
end
...
give_player_stuff("Blockhead", "review:positive_feedback", 99)
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
Re: How do I execute commands within a mod at a given time?
So will this execute if I give condition in if and call it like you said? Im basically just trying to automatically send commands behind the scenes without user input because some things I have are only run by commands. I'll try your code when I get the chance, thanks and God bless.
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
Re: How do I execute commands within a mod at a given time?
Hey I tried it and it works. Thank you sir for helping. I will add you in credits. God bless you!
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
Who is online
Users browsing this forum: No registered users and 12 guests