Jump to content

random map


xana
 Share

Recommended Posts

Bonjour, c'est encore moi le nul en ce logiciel. Bref en essayant de créer des map Random ne sachant pas si c'était possible je me suis dit autant faire beaucoup de portes en formes de mur qui en commencant la partie s'active ou non j'ai voulue reprendre le code de BushBoutton.lua mais sa ne semble pas fonctionner.

Merci pour vos aide, si il existe des façon de générer des map je suis preuneur un peut comme Monstrum désoler pour la pub.

 

Hello, it's me again a draw in software. In short, trying to create Random map not knowing if it was possible I thought as do many doors wall shapes that starting the game is activated or not I wanted to resume code BushBoutton.lua but its not working.

 

Thank you for your help, if there is way to generate a map I can preuneur as Monstrum grieve for the pub.

 

 

Script.enabled=true--bool "Enabled"
Script.soundfile=""--path "Sound" "Wav Files (*.wav):wav"
v = math.random(1,2)
function Script:Start()
if self.soundfile then
 self.sound = Sound:Load(self.soundfile)
end
end
if (v = 1;){
function Script:Use()
if self.enabled then
 if self.sound then self.entity:EmitSound(self.sound) end
 self.component:CallOutputs("Use")
end
end
}
if (v = 2;){
function Script:Use()
if self.enabled then
 if self.sound then self.entity:EmitSound(self.sound) end
 self.component:CallOutputs("Use2")
end
end
}
function Script:Enable()--in
if self.enabled==false then
 self.enabled=true
 self.component:CallOutputs("Enable")
 self.health=1
end
end
function Script:Disable()--in
if self.enabled then
 self.enabled=false
 self.component:CallOutputs("Disable")
 self.health=0
end
end
function Script:Release()
if self.sound then self.sound:Release() end
end

Link to comment
Share on other sites

Merci pour les liens mais j'ai remarqué que c'est beaucoup plus compliqué que prévue donc je vais resté avec ma deuxième idée en tête celle du déclenchement aléatoire savez vous comment résoudre mon code qui est fort erroné

 

Thank you for the links but I noticed that it is much more complicated than expected so I stayed with my second idea in mind that the random trigger you know how to fix my code which is very wrong

Link to comment
Share on other sites

To start with you need to put your random number generation in Start() or something. It also needs to be a variable that will stick around by the time the Use() function gets called so do something like this:

function Script:Start()
 self.v = math.random(1,2)
end

 

Put all the checks for v within one Use() function. Something like

function Script:Use()
 if self.enabled then
   if self.v == 1 then
     self.component:CallOutputs("Use1")
   elseif self.v == 2 then
     self.component:CallOutputs("Use2")
   end
 end
end

  • Upvote 1
Link to comment
Share on other sites

Merci pour le code mais étrangement après chaque démarrage du jeu ou en appuyant de nouveau sur le bouton le résultat et toujours le numéro maximum

(dans mon code c'est 4)

 

 

Thank you for the code but strangely after each start of the game or by pressing again on the result and still the maximum number button

(in my code is 4)

 

Script.enabled=true--bool "Enabled"
Script.soundfile=""--path "Sound" "Wav Files (*.wav):wav"
function Script:Start()
 self.v = math.random(1,4)
end
function Script:Use()
 if self.enabled then
    if self.v == 1 then
	  self.component:CallOutputs("Use1")
 elseif self.v == 2 then
	  self.component:CallOutputs("Use2")
 elseif self.v == 3 then
	  self.component:CallOutputs("Use3")
    elseif self.v == 4 then
	  self.component:CallOutputs("Use4")
    end
 end
end

function Script:Enable()--in
if self.enabled==false then
 self.enabled=true
 self.component:CallOutputs("Enable")
 self.health=1
end
end
function Script:Disable()--in
if self.enabled then
 self.enabled=false
 self.component:CallOutputs("Disable")
 self.health=0
end
end

function Script:Release()
if self.v then self.v:Release() end
end

Link to comment
Share on other sites

Are you seeding the random number generator? Try doing the following line of code before your math.random call.

 

math.randomseed(Time:Millisecs())
self.v = math.random(1,4)

 

I remember seeing a thread talking about how Time:Millisecs() wasn't the best way to get a random number but I can't remember where it was now, should work better than no seed though. os.time would create a problem for Game Launcher so I would avoid it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...