Is it possible to launch mame with a lua script that would automatically insert coin and press player 1 after a short delay. The launch command would be something like:
mame digdug -autoboot_delay 30 -autoboot_script insert_coin.lua
Basically: launch digdug, ask mame to wait 30 seconds before executing the lua script which would do the insert coin + press player 1 magic.
QUESTION
If this is possible, how would you write the lua script to execute the coin insert and press player one commands.
Related
I'm new to LUA and I'm making a simple game where a bunny should bounce after pressing space on the keyboard. So the plan is to make the bunny go up by 30, wait for half a second and then for the bunny to go back to its original position.
That's the code that I've tried so far, and for the looks of it, the love.keypressed function completely ignored the wait function and tried to execute everything at the same time, which means the bunny simply does not move if the spacebar is pressed. (In other words, is there a way to make the bunny stay in the air for 0.5 seconds after pressing the spacebar and then making it go back to its original position?)
function wait(millisecond)
end
function love.keypressed(key)
if key == "space" then
bunny.y = bunny.y - 30
wait(500);
bunny.y = bunny.y + 30
end
end
For love2d this should work -> https://love2d.org/wiki/love.timer.sleep
An a pure lua sleep function would look like this:
(the time is in seconds)
local function sleep(time)
local start = os.clock()
while os.clock() - start <= time do end
end
The best way to do this without blocking the Lua thread (which would cause ALL functions to stop, including graphics and parsing data) is to create a timer. This library does exactly what you're looking for.
In the end, your function would look like this (assuming you've imported the library correctly):
function love.keypressed(key)
if key == "space" then
bunny.y = bunny.y - 30
timer.Simple(0.5, function() -- wait 0.5 seconds, and then run the code
bunny.y = bunny.y + 30
end)
end
end
I'm a newbie developer of roblox.
I'm trying to place a player in a specific position on first load in this way:
In StarterPlayer > StarterPlayerScripts I added a LocalScript with the following code:
local cf = CFrame.new(500, 5, 50)
local Char = game.Players.LocalPlayer
Char.HumanoidRootPart.CFrame = cf
When I click play, nothing happen onload.
What I'm doing wrong?
#ItsJustFunboy is half correct, you do need to use the Model:MoveTo function, but you might have some other issues as well : timing and LocalScripts.
Timing-wise, you have this code in StarterPlayerScripts. These LocalScripts execute when the Player joins the game, not when their character model appears. So it's possible that their character doesn't even exist at the time you're telling it to move. If you want to guarantee that the character model exists at the time you run this code, it needs to be in StarterCharacterScripts.
As for the problem with LocalScripts, they make changes to the world only on your client. Meaning that if you move your character in a LocalScript, then all the other players will still see your character model where it was, not where you moved it. So unless this is intentional, if you want everyone to see this change, you need to move the character model in a server-side Script.
So in a Script in the Workspace or in ServerScriptService, try this :
-- wait for a player to join the game
game.Players.PlayerAdded:Connect(function(player)
-- wait for their character to load into the game
player.CharacterAdded:Connect(function(character)
-- yield the thread for but a moment so that the character can finish loading
wait()
-- move their character
local targetPosition = Vector3.new(500, 5, 50)
character:MoveTo(targetPosition)
end)
end)
use the MoveTo() function:
local plr = game.Players.LocalPlayer
plr.Character:MoveTo(CFrame.new(500, 5, 50))
New to Lua scripting, so hopefully I'm using the right terminology to describe this, please forgive if I'm not, I'll get better over time....
I'm writing code for a game using Lua. And I have a function that sets a value. Now I need to "hold" this value for a set period of time after which it gets set to another value.
I'm trying to replicate this behavior:
Imagine a car-start key.
0 = off
1 = ignition on
2 = ignition on + starter -- this fires to get the engine to ignite. In real-life, this "start" position 2 is HELD while the starter does its thing, then once the engine ignites, you'd let go and it springs back to = 1 to keep the ignition on while the engine keeps running.
Now imagine instead, a start button and it can not NOT be pushed in and held in position=2 (like the key) for the time required for the starter to ignite the engine. Instead, once touched, that should cause the starter to runs for a set period of time in position 2 and when it senses a certain =>RPM, the starter stops and goes back to position 1, and leaves the engine running.
Similarly, I have a button that when "touched" fires the starter, but that starter event as expected goes from 0 to 2 and back to 1 in a blink. If I set it to be 2 then it fires forever.
I need to hold its phase 2 position in place for 15 seconds, then it can get back to 1
What I have:
A button that has an animated state. (0 off, 1, 2).
If 0 then 1, if 1 then 2 using phase==2 as the spring step from 2 back to 1
At position == 2, StarterKey = 2
No syntax issues.
The StarterKey variable is triggered to be =2 at position 2 -- BUT not long enough for the engine to ignite. I need StarterKey=2 to stay as a 2 for 15 seconds. Or, do I need to time the entire if phase==2 stage to be held for longer? Not sure.
What should I be looking at please? Here's a relevant snip..
function EngineStart()
if phase == 0 then
if ButtonState == 0 then
ButtonState = 1
StarterKey = 2 -- I tried adding *duration = 15* this event but that does not work
end
end
end
I also have the subsequent elseif phase == 2 part for when the button is in position == 2 so it springs back to 1 -- that all works fine.
How do I, or what do I need to use, to introduce time for my events and functions? I don't want to measure time, but set event time.
Thanks!
Solved this by watching a Lua tutorial video online (taught me how) + discovered that the sim has a timer function that I then used to set the number of seconds ("time") that the starter key-press stayed in its 2 position, which then fired it long enough for the igniters to do their work. (what to use)
QED :)) HA!
I have this exploit for Murder Mystery 2.
It is a tpcoins and esp exploit. When I enable the tpcoins it will turn off after a few seconds. Is there any way of making it so it stays on?
Here's the code:
function enableTpCoin()
if nameMap ~= "" and wp[nameMap] ~= nil then
if lplr.PlayerGui.MainGUI.Game.CashBag:FindFirstChild("Elite") then
tpCoin(10)
elseif lplr.PlayerGui.MainGUI.Game.CashBag:FindFirstChild("Coins") then
tpCoin(15)
end
end
Trigger to start the script is q.
Short answer, you can't. Since this is script related I'll answer your question.
So each round, the player can only earn 10 coins, and 15 if they have purchased the "Elite" gamepass.
This meaning that the game physically doesn't allow you to add anymore per round. You'll have to execute the code at the launch of every round.
The game has FE, so it's most likely that the original developer of the game has specified the remote events to only accept 10 or 15 coins depending on the boolean value whether the user is "Elite" or not.
Even if Universal Link says the truth, here's the solution.
Create a new function. In that function, do a while loop with a interval (use wait(.1)), and in that while loop, call enableTpCoin().
Now, call spawn() and pass the function you created as an argument.
The code should look like this:
function _loop()
while wait(.1) do
enableTpCoin()
end
end
spawn(_loop)
I'm using Rosbag to record a F1 robot simulated in Gazebo.
When i record the F1 everything is OK but qhen i use "Rosbag play" the record is not synchronized with the movement of the F1 that i recorded.
The "Bag time" starts in the second 20 but the duration starts in second 0 so the F1 turns early
I've tried with "rosparam set use_sim_time true" and "rosbag play xxxx.bag --clock" but it didn't work.
Any idea?
Thanks!
Presumably, the topics you record publish their first message after 20 seconds. Thus, when the first 20 seconds are empty, rosbag play skips this delay.
Just record more topics which also start to publish at your desired time.