The random in config folder is probably not randomizing anything because everything is spawned together on the tiled.
Can anyone help with that?
@Edit
how can i make this work on mac?
I don't have a mac to test
function love.keypressed(key, scancode, isrepeat)
if gameState == 0 and scancode == "return" then
gameState = 1
elseif Inventarios.Open == false and scancode == "i" and gameState > 0 then
Inventarios.Open = true
elseif Inventarios.Open == true and scancode == "i" and gameState > 0 then
Inventarios.Open = false
end
end
@edit: https://github.com/NinguemLPJ/games/tre ... inguem_RPG
problem with randomize and toggleKey
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- papainoel14
- Prole
- Posts: 10
- Joined: Fri Mar 13, 2020 3:59 pm
problem with randomize and toggleKey
Last edited by papainoel14 on Fri Mar 20, 2020 7:47 pm, edited 4 times in total.
Ninguem
Re: problem with randomize and toggleKey
I don't understand either of your questions. Can you provide a bit more context?
- papainoel14
- Prole
- Posts: 10
- Joined: Fri Mar 13, 2020 3:59 pm
Re: problem with randomize and toggleKey
https://love2d.org/imgmirrur/QweJywv.mp4
look at the money, it was supposed to be random but always comes the same amount
look at the money, it was supposed to be random but always comes the same amount
Ninguem
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: problem with randomize and toggleKey
You are setting the coin value in the files scope. Meaning the value is only set when the file is loaded once. You need to set a random value for each individual coin. If you know oop design you are essentially setting a static class property instead of setting a per instance value. To fix this when you create the coins random location also create it's random value and store it in the same table.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: problem with randomize and toggleKey
i looked at their conf.lua as well, and i only saw min and max values defined; i didn't see where they called (love.)math.random. that would help in debugging if that info bit was shared.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: problem with randomize and toggleKey
The OP didn't make it easy to find, but I'm going to guess that the problem is for example here:
https://github.com/NinguemLPJ/games/blo ... oin.lua#L3
The solution is simply to use love.math.random instead of math.random.
https://github.com/NinguemLPJ/games/blo ... oin.lua#L3
The solution is simply to use love.math.random instead of math.random.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: problem with randomize and toggleKey
Yeah i thought about that being the problem and the solution, however, that would only be an issue regarding getting the same random numbers on each startup,but not for consecutive calls which was what i understood was the issue...pgimeno wrote: ↑Sat Mar 21, 2020 12:33 pm The OP didn't make it easy to find, but I'm going to guess that the problem is for example here:
https://github.com/NinguemLPJ/games/blo ... oin.lua#L3
The solution is simply to use love.math.random instead of math.random.
but twist #2: that line is indeed the problem, because only one random number is generated and saved into the local, instead of one per object, i'm guessing.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- papainoel14
- Prole
- Posts: 10
- Joined: Fri Mar 13, 2020 3:59 pm
Re: problem with randomize and toggleKey
I created a function called debug, just to print the number generated below the player, I think I discovered the big problem, I couldn't find a solution so far.
with what you said I managed to solve the problem of being called only once, but it is not yet generated for non-integer numbers
If you help me look for a solution I will be grateful. and I imagine that this way it is easier for you to test your solution without having to try to understand my project
take a look at git again
Last functions of .lua
Ninguem_Extras/Ninguem_functions
debugUpdate(randomMAX, randomMIN) -- just change this function and the numbers inside the main update
with what you said I managed to solve the problem of being called only once, but it is not yet generated for non-integer numbers
If you help me look for a solution I will be grateful. and I imagine that this way it is easier for you to test your solution without having to try to understand my project
take a look at git again
Last functions of .lua
Ninguem_Extras/Ninguem_functions
debugUpdate(randomMAX, randomMIN) -- just change this function and the numbers inside the main update
Ninguem
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests