5 posts
Posted 14 April 2014 - 08:16 AM
Hi guys,
I just need some pointers, I want to Wright a program so the player can input a type of pokemon(Fire,Water,Grass..etc..) and a level and the computer will use a command block to spawn the pokemon.
I have a good idea, how to do this apart from how to randomise the pokemon with in the given type.
Any and all help is welcome, or if some really nice person already has something similar I could edit, that would save me pulling what little hair I have left out when I start this tonight.
35 posts
Posted 14 April 2014 - 04:13 PM
can a command block spawn modded entities?
if so you can use
commandBlock = peripheral.wrap("right") --Assuming the command block is to the right
while true do
i = math.random(1,16)
if i == 1 then
commandBlock.setCommand("Whatever the command is") -- this is where you put the command
commandBlock.runCommand()
elseif -- keep adding on
end
end
1281 posts
Posted 14 April 2014 - 05:42 PM
A better approach would be to use tables
local tPokemon = {
squirtle,
charmander,
bulbasuar
}
while true do
local spawn = tPokemon[math.random(1,#tPokemon)] --picks a random entry in the table
--commandblock spawning code here
end
Just remember to fill the table with whatever the commandblock uses to spawn said pokemon, making it easier to fill that into it's command parameters. And ofcourse in your case you would have multiple tables, one for each type, which you pull from depending on user input.
Edited on 14 April 2014 - 03:42 PM
5 posts
Posted 14 April 2014 - 10:40 PM
Thanks for the help guys, both are what I was looking for will give them a blast.
@CometWolf can I ask what I would be putting in the command block if normally the command would be "/pokespawn bulbasuar", would it be "/pokespawn spawn"
Sorry I am still a bit new at this. :D/>
72 posts
Location
Washing a ton state USA, North America, Earth, The Universe, The Multiverse (If that exists)
Posted 14 April 2014 - 11:52 PM
I don't know much about this mod, but you would use:
commandBlock.setCommand("/pokespawn " .. spawn)
commandBlock.runCommand()
Where spawn is the name of the pokemon to spawn. In case you don't know the .. string operator appends the value of a variable or table to the string before it. Using just /pokespawn spawn would try to spawn a pokemon named spawn
Edited on 14 April 2014 - 09:54 PM
5 posts
Posted 15 April 2014 - 08:30 AM
Thanks Enderbane
Well guys you have shown me the way forward, thanks all for the help
:)/>
5 posts
Posted 15 April 2014 - 05:33 PM
ok guys when I try Cometwolf's code I get the error : test 7: bad argument #2 interval is empty
Can I get some help on this?
Thanks
local tPokemon = {
squirtle,
charmander,
bulbasuar
}
while true do
local spawn = tPokemon[math.random(1,#tPokemon)] –picks a random entry in the table
–commandblock spawning code here
end
1281 posts
Posted 15 April 2014 - 05:44 PM
lol, i forgot to add quotes around the strings.
local tPokemon = {
"squirtle",
"charmander",
"bulbasuar"
}
5 posts
Posted 15 April 2014 - 07:40 PM
That's it, thanks :lol:/>