AttributeError: module 'interactions' has no attribute 'Client' - discord

Full disclosure I haven't written this code myself and I'm still a little new to discord intents. I'm worried that some older discord libraries on my computer may be causing this but i'm not sure why I'm getting this error. Every time I run my program "AttributeError: module 'interactions' has no attribute 'Client' ".
Here is the code I was using
#imports
import interactions
import random
import cloudscraper
#settings
SafeMines = ':white_check_mark:'
TileMines = ':x:'
SafeTowers = ':white_check_mark:'
TileTowers = ':x:'
BotToken = ''
ServerId = 0
BuyerRoleId = 0
#StartUp
bot = interactions.Client(
token=BotToken
)
#defines
def GenGrid(SafeTiles:int):
Generating = True
BoardNums = []
Board = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Grid = f''
line = 0
endrownums = [6,11,16,21]
while Generating:
if len(BoardNums) < SafeTiles:
Selection = random.randint(1, 25)
if Selection in BoardNums:
pass
else:
BoardNums.append(Selection)
else:
Generating = False
for Number in BoardNums:
Board[Number-1] = 1
for Position in Board:
line += 1
if line in endrownums:
Grid += f'\n'
if Position == 1:
Grid += f'{SafeMines}'
else:
Grid += f'{TileMines}'
else:
if Position == 1:
Grid += f'{SafeMines}'
else:
Grid += f'{TileMines}'
return Grid
def gentower(rows:int):
if rows >= 9:
return "Max Rows 8!"
else:
def pr():
rowtp1 = f"{SafeTowers}{TileTowers}{TileTowers}"
rowtp2 = f"{TileTowers}{SafeTowers}{TileTowers}"
rowtp3 = f"{TileTowers}{TileTowers}{SafeTowers}"
joe = random.randint(1,3)
if joe == 1:
return rowtp1
elif joe == 2:
return rowtp2
else:
return rowtp3
leg = True
counter = 0
finaltower = f""
while leg:
if counter == rows:
leg = False
else:
counter +=1
finaltower += f"{pr()}\n"
return finaltower
#Commands
#bot.command(
name='mines',
description="Generates A Mine Grid",
scope=ServerId,
options= [
interactions.Option(
name="game_id",
description="Put your game id here",
type=interactions.OptionType.STRING,
required=True,
),
interactions.Option(
name="clicks",
description="How many safe spots to generate",
type=interactions.OptionType.INTEGER,
required=True,
)
]
)
async def Mines(ctx, game_id: str, clicks:int):
if BuyerRoleId in ctx.author.roles or ctx.author.id == 756534114143961088:
if int(clicks) > 23:
mines = interactions.Embed(title=f"Mines", description=f"Too Many SafeClicks! Max is 23\nYou Chose {clicks}/23", color=0xFC4431)
await ctx.send(embeds=mines, ephemeral=True)
else:
count = 0
includes_dash = False
includes_number1 = ""
includes_number2 = ""
l = [14,15,16]
l2 = [18,19,20,21,22]
lsu = False
for v in game_id:
count += 1
if count == 9:
if v == "-":
includes_dash = True
if count in l:
if v == "4":
includes_number1 += v
if count in l:
try:
int(v)
if lsu == True:
continue
else:
includes_number2 +=v
lsu = True
except ValueError:
continue
if includes_dash == True:
if includes_number1 == "4":
try:
int(includes_number2)
mines = interactions.Embed(title=f"Mines", description=f"Generated Tiles!", color=0xFC4431)
mines.add_field(name=f"Field {clicks} Clicks", value=GenGrid(clicks),inline=True)
await ctx.send(embeds=mines, ephemeral=True)
print(f"\n\n{ctx.author} Used Towers command\nID = {ctx.author.id}\n")
except ValueError:
mines = interactions.Embed(title=f"Mines", description=f"Invalid ID!", color=0xFC4431)
await ctx.send(embeds=mines, ephemeral=True)
else:
mines = interactions.Embed(title=f"Mines", description=f"Invalid ID!", color=0xFC4431)
await ctx.send(embeds=mines, ephemeral=True)
else:
mines = interactions.Embed(title=f"Mines", description=f"Invalid ID!", color=0xFC4431)
await ctx.send(embeds=mines, ephemeral=True)
else:
await ctx.send(f"Not Eligable! {ctx.author.mention}")
#Bot
bot.start()
Im not sure why its giving me any error, any suggestions on this?

Related

Discord Python error: AttributeError: 'TextChannel' object has no attribute 'create_thread'

I've got a series of lengthy messages that make up the help function of my Discord bot, and I'd like to have them sent to a thread instead of the channel itself. However, when I try and call create_thread(), I get this error: AttributeError: 'TextChannel' object has no attribute 'create_thread'
Here's my code:
import discord
import os
import random
import time
client = discord.Client()
class initiative_card:
def __init__(self,name,command,image,emoji,color,card_type,copy,user_defined_name):
self.rgb = str(color).split(",")
self.raw_color = color
self.name = name
self.command = command
self.image = image
self.emoji = emoji
self.color = discord.Color.from_rgb(int(self.rgb[0]),int(self.rgb[1]),int(self.rgb[2]))
if (card_type == "Hero"):
self.is_hero = True
else:
self.is_hero = False
self.copy = copy
self.user_defined_name = user_defined_name
self.faceup = True
self.cardback_emoji = "<:initcardback:1069116117756432435>"
self.cardback_image = "https://cdn.discordapp.com/emojis/1069116117756432435.webp?size=96&quality=lossless"
def flip(self):
self.faceup = not self.faceup
global all_initiative_cards
global initiative_deck
global turn_index
def initialize_deck():
global all_initiative_cards
global initiative_deck
global turn_index
all_initiative_cards = []
# Read the cards file and create the initiative deck
with open('initiative_cards.txt') as f:
lines = f.readlines()
print('Found ' + str(len(lines)) + ' card entries in file')
valid_lines = 0
hero_card_count = 0
for i in lines:
words = i.split(" ")
if len(words) == 7:
all_initiative_cards.append(initiative_card(words[0],words[1],words[2],words[3],words[4],words[5],0,"undefined"))
valid_lines = valid_lines + 1
for i in all_initiative_cards:
if i.is_hero:
hero_card_count = hero_card_count + 1
print(str(valid_lines) + " valid entries found; created " + str(len(all_initiative_cards)) + " cards, of which " + str(hero_card_count) + " were hero cards.")
initiative_deck = []
turn_index = 0
return
#client.event
async def on_ready():
initialize_deck()
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name='!inithelp'))
#client.event
async def on_message(message):
global all_initiative_cards
global initiative_deck
global turn_index
if message.author == client.user:
return
if message.content.startswith('!allcards'):
new_thread = await message.channel.create_thread(name="Initiative Card Reference", message="Initiative Card Reference", type=ChannelType.public_thread)
new_thread.add_user(message.author)
embed=discord.Embed(title="Initiative", description="Listing all cards available to add to the track.", color=0x8c8c8c)
embed.set_thumbnail(url='https://cdn.discordapp.com/emojis/756583300612751460.webp?size=96&quality=lossless')
for index, item in enumerate(all_initiative_cards):
if (not (index % 8)) and (index > 0):
await new_thread.send(embed=embed)
embed=discord.Embed(title="Spectaculars Initiative", description="Listing all cards available to add to the track.", color=0x8c8c8c)
embed.set_thumbnail(url='https://cdn.discordapp.com/emojis/756583300612751460.webp?size=96&quality=lossless')
embed.add_field(name=item.name, value="Card ID: " + item.command, inline=True)
embed.add_field(name="Card Image", value=item.emoji,inline=True)
embed.add_field(name='\n',value='\n')
await new_thread.send(embed=embed)
Discord.py seems to have a create_thread method for TextChannel. What am I not seeing here?
I've tried removing all of the arguments from message.channel.create_thread. I was expecting this to create a new thread with the help text in it in the channel in which the help request was sent.

Inserting data from csv too slow Django

My problem is that inserting data into the database is too slow. I have written a correct algorithm that loads the data properly however with this method it will take 700 hours to load the database. There are almost 30 million records in the csv file.
Here is my models.py
from django.db import models
class Region(models.Model):
region = models.CharField(max_length=20)
class Rank(models.Model):
rank = models.IntegerField()
class Chart(models.Model):
chart = models.CharField(max_length=8)
class Artist(models.Model):
artist = models.CharField(max_length=60)
class Title(models.Model):
title = models.CharField(max_length=60)
class ArtistTitle(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
title = models.ForeignKey(Title, on_delete=models.CASCADE)
class SpotifyData(models.Model):
title = models.ForeignKey(ArtistTitle, related_name='re_title', on_delete=models.CASCADE)
rank = models.ForeignKey(Rank, on_delete=models.CASCADE)
date = models.DateField()
artist = models.ForeignKey(ArtistTitle, related_name='re_artist', on_delete=models.CASCADE)
region = models.ForeignKey(Region, on_delete=models.CASCADE)
chart = models.ForeignKey(Chart, on_delete=models.CASCADE)
streams = models.IntegerField()
My upload script looks like this:
def load_to_db(self, df):
bad = 0
good = 0
start = datetime.datetime.now
for _, row in df.iterrows():
try:
region_obj, _ = Region.objects.get_or_create(
region=row["region"],
)
rank_obj, _ = Rank.objects.get_or_create(
rank=row["rank"],
)
chart_obj, _ = Chart.objects.get_or_create(
chart=row["chart"],
)
artist_obj, _ = Artist.objects.get_or_create(
artist=row["artist"],
)
title_obj, _ = Title.objects.get_or_create(
title=row["title"],
)
arttit_obj, _ = ArtistTitle.objects.update_or_create(
artist=artist_obj,
title=title_obj,
)
spotifydata_obj, _ = SpotifyData.objects.update_or_create(
title=arttit_obj,
rank=rank_obj,
date=row["date"],
artist=arttit_obj,
region=region_obj,
chart=chart_obj,
streams=row["streams"],
)
good += 1
now = datetime.datetime.now
print(f"goods: {good}, loading time: {start-now}", )
except Exception as e:
bad += 1
current_time = datetime.datetime.now()
with open("data_load_logging.txt", "w") as bad_row:
bad_row.write(
f"Error message: {e} \n"
+ f"time: {current_time}, \n"
+ f"title: {row['title']}, type: {row['title']} \n"
+ f"rank: {int(row['rank'])}, type: {int(row['rank'])} \n"
+ f"date: {row['date']}, type: {row['date']} \n"
+ f"artist: {row['artist']}, type: {row['artist']} \n"
+ f"region: {row['region']}, type: {row['region']} \n"
+ f"chart: {row['chart']}, type: {row['chart']} \n"
+ f"streams: {int(row['streams'])}, type: {int(row['streams'])} \n"
+ "-" * 30
+ "\n"
)
I know it could probably help to use bulk/bulk_create/bulk_update but I can't figure out how to write the correct script....
def load_to_db(self, path):
start_time = timezone.now()
try:
with open(path, "r") as csv_file:
data = csv.reader(csv_file)
next(data)
packet_region = []
packet_rank = []
packet_chart = []
packet_artist = []
packet_title = []
packet_artist_title = []
packet_spotify_data = []
bad = -1 # first row is a header
for row in data:
region = Region(
region = row[4]
)
rank = Rank(
rank = row[1]
)
chart = Chart(
chart = row[5]
)
artist = Artist(
artist = row[3]
)
title = Title(
title = row[0]
)
artist_title = ArtistTitle(
artist = artist,
title = title
)
spotify_data = SpotifyData(
title = artist_title,
rank = rank,
date = row[3],
artist = artist_title,
region = region,
chart = chart,
streams = int(row[6])
)
packet_region.append(region)
packet_rank.append(rank)
packet_chart.append(chart)
packet_artist.append(artist)
packet_title.append(title)
packet_artist_title.append(artist_title)
packet_spotify_data.append(spotify_data)
if len(packet_spotify_data) > 1000:
print(datetime.datetime.now())
Region.objects.bulk_create(packet_region)
Rank.objects.bulk_create(packet_rank)
Chart.objects.bulk_create(packet_chart)
Artist.objects.bulk_create(packet_artist)
Title.objects.bulk_create(packet_title)
ArtistTitle.objects.bulk_update(packet_artist_title)
SpotifyData.objects.bulk_update(packet_spotify_data)
packet_region = []
packet_rank = []
packet_chart = []
packet_artist = []
packet_title = []
packet_artist_title = []
packet_spotify_data = []
logging.info(f"Failure numbers: {bad}")
if packet_spotify_data:
Region.objects.bulk_create(packet_region)
Rank.objects.bulk_create(packet_rank)
Chart.objects.bulk_create(packet_chart)
Artist.objects.bulk_create(packet_artist)
Title.objects.bulk_create(packet_title)
ArtistTitle.objects.bulk_update(packet_artist_title)
SpotifyData.objects.bulk_update(packet_spotify_data)
except FileNotFoundError as e:
raise NoFilesException("No such file or directory") from e
end_time = timezone.now()
self.stdout.write(
self.style.SUCCESS(
f"Loading CSV took: {(end_time-start_time).total_seconds()} seconds."
)
)
I tried to use bulk this way but unfortunately it doesn't work

Poll question which adds the correct amount of reactions. (d.py)

I am trying to make a poll command which adds the correct amount of reactions such as A B C D E etc.
I have already tried this but it was a simple yes or no poll command.
elif message.content.startswith('m/qpoll'):
question = message[8:]
await message.delete()
message = await message.channel.send(f"**New poll:** {question}")
await message.add_reaction('โŒ')
await message.add_reaction('โœ”๏ธ')
What i am trying to achieve is a command which adds A B C reactions if there is three possible answers and A B C D E if there is five possible answers etc.
The command the user has to use is preferred to be in this format:
m/poll "question" "answer 1" "answer 2" "answer 3"
The command needs to be under a on_message statement as the command package does not work as well for my bot.
A simple way to do it, without using discord.ext.commands :
elif message.content.startswith('m/qpoll'):
content = message.content[8:]
items = content.split(" ")
question = items[0]
answers = '\n'.join(items[1:])
await message.delete()
message = await message.channel.send(f"**New poll:** {question}\n{answers}")
reactions = ['A', 'B', 'C', 'D', 'E'] #replace the letters with your reactions
for i in range(len(items[1:]))
await message.add_reaction(reactions[i])
Here's the poll command I made for my bot
#commands.command()
async def poll(self, ctx):
"""
Conduct a poll (interactive)
?poll
"""
member = ctx.author
member: Member
maker = []
await ctx.send("```What is the Question โ“```")
em = ["๐Ÿงช", "๐Ÿงฌ", "๐Ÿš€", "๐Ÿ–Œ๏ธ", "๐Ÿงจ"]
def mcheck(m):
return m.author == member
try:
msg = await self.bot.wait_for('message', timeout=20.0, check=mcheck)
maker.append(msg.content)
except TimeoutError:
return await ctx.send("```Poll timed out โณ```")
await ctx.send("```How many options do you want?```")
try:
msg = await self.bot.wait_for('message', timeout=20.0, check=mcheck)
except TimeoutError:
return await ctx.send("```Poll timed out โณ```")
i = int(msg.content)
if i > 5:
return await ctx.send("```A maximum of 5 options for polls```")
await ctx.send("```Enter your options โœ”```")
for i in range(i):
try:
await ctx.send(f"```{i + 1}) ```")
msg = await self.bot.wait_for('message', timeout=20.0, check=mcheck)
maker.append(msg.content)
await msg.add_reaction("โœ…")
except TimeoutError:
return await ctx.send("```Poll timed out โณ```")
poller = Embed(color=0x5EE34)
poller.title = maker[0]
des = ''
for j in range(1, len(maker)):
des += f"```{em[j - 1]} {maker[j]}```\n"
poller.description = des
pr = await ctx.send(embed=poller)
for j in range(i + 1):
await pr.add_reaction(em[j])
def reac_check(r, u):
return pr.id == r.message.id and r.emoji in em
eopt = {e: 0 for e in em}
while True:
try:
reaction, user = await self.bot.wait_for('reaction_add', timeout=20.0, check=reac_check)
e = str(reaction.emoji)
except TimeoutError:
await ctx.send("```Poll Finished โœ…```")
break
if e in eopt.keys() and user != self.bot.user:
eopt[e] += 1
eopt = {k: v for k, v in sorted(eopt.items(), key=lambda item: item[1], reverse=True)}
most = next(iter(eopt))
loc = em.index(most)
poller.title = "Results ๐Ÿ†"
poller.description = f"```Folks chose ๐Ÿ“œ\n{maker[loc + 1]}```"
return await ctx.send(embed=poller)
As a rule of thumb avoid using on_message to create commands. You can read about commands.Bot() in the docs.
That said you should be able adapt the above example to suit your needs.

create my nribin code for logistf ,does it really work?

i need to creat my own nribin code , it can be used for logistf package outcome, i maybe work,please give me some advise!!!
i change z.std = mdl.std$x[,-1] to z.std = mdl.std$x
and cancle: link = mdl.std$family[[2]] and family=binomial(link),
the whole code is:
nribin_LTY <-
function (event=NULL, mdl.std=NULL, mdl.new=NULL, z.std=NULL, z.new=NULL, p.std=NULL, p.new=NULL,
updown='category', cut=NULL, link='logit', niter=1000, alpha=0.05, msg=TRUE) {
##
## type of calculation
flag.mdl = !is.null(mdl.std) && !is.null(mdl.new)
flag.prd = !is.null(z.std) && !is.null(z.new)
flag.rsk = !is.null(p.std) && !is.null(p.new)
##
## check standard & new model
if (flag.mdl) {
if (is.null(event)) event = as.numeric(mdl.std$y)
if (is.null(mdl.std$x) || is.null(mdl.new$x))
stop("\n\nmodel object does not contain predictors. pls set x=TRUE for model calculation.\n\n")
z.std = mdl.std$x
z.new = mdl.new$x
mdl.std = glm(event ~ ., data=as.data.frame(cbind(event, z.std)))
mdl.new = glm(event ~ ., data=as.data.frame(cbind(event, z.new)))
} else if (flag.prd) {
mdl.std = glm(event ~ ., data=as.data.frame(cbind(event, z.std)))
mdl.new = glm(event ~ ., data=as.data.frame(cbind(event, z.new)))***
message("\nSTANDARD prediction model:")
print(summary(mdl.std)$coef)
message("\nNEW prediction model:")
print(summary(mdl.new)$coef)
} else if (!flag.mdl && !flag.prd && !flag.rsk) {
stop("\n\neither one of 'event, z.std, z.new', 'event, p.std, p.new', and 'mdl.std, mdl.new' should be specified.\n\n")
}
if (is.null(cut))
stop("\n\n'cut' is empty")
objs = list(mdl.std, mdl.new, z.std, z.new, p.std, p.new)
##
## DH & DL
wk = get.uppdwn.bin(event, objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg=msg)
upp = wk[[1]]
dwn = wk[[2]]
ret = list(mdl.std=mdl.std, mdl.new=mdl.new, p.std=wk[[3]], p.new=wk[[4]], up=upp, down=dwn, rtab=wk[[5]], rtab.case=wk[[6]], rtab.ctrl=wk[[7]])
##
## point estimation
message("\nNRI estimation:")
est = nribin.count.main(event, upp, dwn)
message("Point estimates:")
result = data.frame(est)
names(result) = 'Estimate'
row.names(result) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
print(result)
##
## interval estimation
if (niter > 0) {
message("\nNow in bootstrap..")
ci = rep(NA, 14)
N = length(event)
samp = matrix(NA, niter, 7)
colnames(samp) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
for (b in 1:niter) {
f = as.integer(runif(N, 0, N)) + 1
objs = list(mdl.std, mdl.new, z.std[f,], z.new[f,], p.std[f], p.new[f])
wk = get.uppdwn.bin(event[f], objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg=FALSE)
upp = wk[[1]]
dwn = wk[[2]]
samp[b,] = nribin.count.main(event[f], upp, dwn)
}
ret = c(ret, list(bootstrapsample=samp))
ci = as.numeric(apply(samp, 2, quantile, c(alpha/2, 1-alpha/2), na.rm=TRUE, type=2))
se = as.numeric(apply(samp, 2, sd))
message("\nPoint & Interval estimates:")
result = as.data.frame(cbind(est, se, matrix(ci, ncol=2, byrow=TRUE)))
names(result) = c('Estimate', 'Std.Error', 'Lower', 'Upper')
row.names(result) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
print(result)
}
invisible(c(list(nri=result), ret))
}
It is need to add variable matrix to logistf outcome,such as:
x.std=as.matrix(thromb2[,c(8,9,10,14,21,22,24,25,26)])
mstd = logistf(formula=fml.std, firth = FALSE,
data = thromb2, x=TRUE)
mstd =backward(mstd)
mstd$x <- x.std

lights out game using CORONA SDK

am trying to devalope a lights out game with CORONA SDK
but am not able to figure out a way for looping it !!!
how many functions to create and the way to keep this going
here is my code (its dummy but a friend gave it to me as am trying to go on from there )
obj = nil
px = 35
py = 50
r = 22
xi = 60
yi = 60
x1y1 = display.newCircle(px+xi*0,py+yi*0,r) x1y1.id = "x1y1"
x2y1 = display.newCircle(px+xi*1,py+yi*0,r) x2y1.id = "x2y1"
x3y1 = display.newCircle(px+xi*2,py+yi*0,r) x3y1.id = "x3y1"
x4y1 = display.newCircle(px+xi*3,py+yi*0,r) x4y1.id = "x4y1"
x5y1 = display.newCircle(px+xi*4,py+yi*0,r) x5y1.id = "x5y1"
x1y2 = display.newCircle(px+xi*0,py+yi*1,r) x1y2.id = "x1y2"
x2y2 = display.newCircle(px+xi*1,py+yi*1,r) x2y2.id = "x2y2"
x3y2 = display.newCircle(px+xi*2,py+yi*1,r) x3y2.id = "x3y2"
x4y2 = display.newCircle(px+xi*3,py+yi*1,r) x4y2.id = "x4y2"
x5y2 = display.newCircle(px+xi*4,py+yi*1,r) x5y2.id = "x5y2"
x1y3 = display.newCircle(px+xi*0,py+yi*2,r) x1y3.id = "x1y3"
x2y3 = display.newCircle(px+xi*1,py+yi*2,r) x2y3.id = "x2y3"
x3y3 = display.newCircle(px+xi*2,py+yi*2,r) x3y3.id = "x3y3"
x4y3 = display.newCircle(px+xi*3,py+yi*2,r) x4y3.id = "x4y3"
x5y3 = display.newCircle(px+xi*4,py+yi*2,r) x5y3.id = "x5y3"
x1y4 = display.newCircle(px+xi*0,py+yi*3,r) x1y4.id = "x1y4"
x2y4 = display.newCircle(px+xi*1,py+yi*3,r) x2y4.id = "x2y4"
x3y4 = display.newCircle(px+xi*2,py+yi*3,r) x3y4.id = "x3y4"
x4y4 = display.newCircle(px+xi*3,py+yi*3,r) x4y4.id = "x4y4"
x5y4 = display.newCircle(px+xi*4,py+yi*3,r) x5y4.id = "x5y4"
x1y5 = display.newCircle(px+xi*0,py+yi*4,r) x1y5.id = "x1y5"
x2y5 = display.newCircle(px+xi*1,py+yi*4,r) x2y5.id = "x2y5"
x3y5 = display.newCircle(px+xi*2,py+yi*4,r) x3y5.id = "x3y5"
x4y5 = display.newCircle(px+xi*3,py+yi*4,r) x4y5.id = "x4y5"
x5y5 = display.newCircle(px+xi*4,py+yi*4,r) x5y5.id = "x5y5"
bb = {x1y1,x2y1,x3y1,x4y1,x5y1,x1y2,x2y2,x3y2,x4y2,x5y2,x1y3,x2y3,x3y3,x4y3,x5y3,x1y4,x2y4,x3y4,x4y4,x5y4,x1y5,x2y5,x3y5,x4y5,x5y5}
iClicked = 0
function click(e)
if(e.phase == "ended") then
--circleID = e.target.id
--whichCircle()
print(e.target.id)
obj = e.target
for u=1,25 do
if(obj==bb[u]) then
iClicked = u
end
end
if((iClicked-5) > 0 and (iClicked-5) < 26) then
bb[iClicked-5]:setFillColor(1,0,0)
end
if((iClicked-1) > 0 and (iClicked-1) < 26) then
bb[iClicked-1]:setFillColor(1,0,0)
end
obj:setFillColor(1,0,0)
if((iClicked+1) > 0 and (iClicked+1) < 26) then
bb[iClicked+1]:setFillColor(1,0,0)
end
if((iClicked+5) > 0 and (iClicked+5) < 26) then
bb[iClicked+5]:setFillColor(1,0,0)
end
end
end
for k=1,25 do
bb[k]:addEventListener("touch",click)
end
its all about having 25 circles and lighting them on and off but it doesnt seem to work for me
any good help will be great
Thanks
local myCircles = {}
for y = 1, 5 do
myCircles[y] = {}
for x = 1, 5 do
myCircles[y][x] = display.newCircle(px+xi*0,py+yi*4,r)
myCircles[y][x].id = .id = "x" .. x .. "y" .. y
end
end
or something like that.
Rob

Resources