Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4247712
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:08:46+00:00 2026-05-21T04:08:46+00:00

I am currently working on a released bot for a game in the hopes

  • 0

I am currently working on a released bot for a game in the hopes of learning more about programming. Unfortunately, a new command i was adding that seemed simple at first became overwhelmingly difficult when i got into the subject of binary arrays. Basically, i took an already made command in which you place an item in two places in order to define the area in which you will be restoring. My edit to the command would be that it would allow the complete restoration of the entire map without placing any items to define the map.

Before a restore command is done, a backup command is done in which a binary array is made of the entire map and then stored in a file. In order to restore the entire map, the new command still has to deal with the coordinates of the two points. One would be at the bottom corner of the map (0,0,0) and then another at the corner at the top opposite side of the map which would always be vary depending on which server you want. My reasoning to solve this would be to simply just retrieve the length of the binary array for each coordinate. Unfortunately, I have been out of luck trying to do that and I really don’t know how to find the dimensions of a binary array. The pack and unpack of the array are shown and the part of the code that i can’t solve.

One strange thing is that if I input the numbers manually like the if statement with that one server ip address, the bot works perfectly. It’s just that any effort to make a code that would work for any map rather than just that one map has been fruitless.

enter code here
def onBackup(self,user,filename):
    fn = bakFolder+filename+".backup"
    try:
        f = open(fn,"r")
        self.bot.sendMessage("A backup by that name already exists.")
        f.close()
        return
    except IOError:
      try:
        f = open(fn,"wb")
        f.write(struct.pack("!3i",self.bot.level_x,self.bot.level_y,self.bot.level_z))
        self.bot.block_array.tofile(f)
        self.bot.sendMessage("Backup saved to file %s.backup"%filename)
        print "Backup save to %s.backup"%filename
        return
      except IOError:
        self.bot.sendMessage("Error opening %s.backup"%filename, false)
        print "Backup: Error opening file"
        return
def restoremap(self):
    fn = bakFolder+self.restore_filename+".backup"
    try:
        f = open(fn,"rb")
        header_x, header_y, header_z = struct.unpack('!3i',f.read(12))
        backup_array = array.array('B')
        backup_array.fromfile(f,header_x*header_y*header_z)
        x1,y1,z1 = (0,0,0) 
        if server == "204.232.197.228":
            x2,y2,z2 = (64,1020,64) #special server that already has coordinates
        else:
            x2,y2,z2 = ??? rest of servers, coordinates derived from the binary array
        if x1 > x2 : x1, x2 = x2, x1
        if y1 > y2 : y1, y2 = y2, y1
        if z1 > z2 : z1, z2 = z2, z1
        tiles_to_deglass = []
        tiles_to_build   = []
        while x1 <= x2:
            y = y1
            while y <= y2:
                z = z1
                while z <= z2:
                    offset = self.bot.calculateOffset(x1,y,z)
                    current_tile = int(self.bot.block_array[offset])
                    backup_tile  = int(backup_array[offset])
                    if not ( current_tile == backup_tile):
                        if (current_tile == 0) and (backup_tile in self.valid_blocks):
                            tiles_to_build.append((backup_tile,x1,y,z))
                        elif (current_tile >= 8) and (current_tile <= 11) and (backup_tile == 0):
                            ## This deals with water & lava in what used to be empty spaces
                            ## first we'll glass it all, and then deglass later!
                            self.blocks.append((20,x1,y,z))
                            tiles_to_deglass.append((0,x1,y,z))
                        elif backup_tile == 7:##use stone
                            tiles_to_build.append((0,x1,y,z))
                            tiles_to_build.append((1,x1,y,z))
                        elif backup_tile in self.valid_blocks:
                            ## This is the fall through... We'll try to erase
                            ## the current tile and then restore it to the other state
                            tiles_to_build.append((0,x1,y,z))
                            tiles_to_build.append((backup_tile,x1,y,z))
                        elif (backup_tile == 0) and not (current_tile == 0):
                            tiles_to_build.append((0,x1,y,z))

                    z+=1
                y += 1
            x1 +=1
        self.DrawBlocks()
        self.blocks += tiles_to_build
        self.DrawBlocks()
        self.blocks += tiles_to_deglass
        self.DrawBlocks()
        self.bot.sendMessage("Restoring...",ignorable=True)
        ##self.bot.action_queue.append(SayAction(self.bot,"Done restoring."))
        self.onReset(silent=True)

    except IOError:
        self.bot.sendMessage("Error while restoring (couldn't read file).")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:08:47+00:00Added an answer on May 21, 2026 at 4:08 am

    Consider the length 1024; this could be turned into (x, y, z):

    2  2  256
    2  4  128
    2  8   64
    2 16   32
    2 32   16
    ...
    128 4  2
    256 2  2
    

    Even if the length of the array was 1001, you wouldn’t get very friendly answers:

     7 11 13
    11  7 13
     7 13 11
    11 13  7
    13 11  7
    13  7 11
    

    So, your saved file must include the (x, y, z) coordinates for each specific map.

    It looks like the onBackup() routine saves the coordinates of the bot in the first three integer positions (four bytes each). You could extend this program by walking the bot to the furthest extent of the map, and then save the coordinates. Or you could see if the server can report the extent of the map somehow, and capture the information.

    But I don’t think you can just guess the dimensions from a given input array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an update to an iOS application that was released
Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
I'm currently working on a game/engine that uses OpenGL for rendering, and recently have
I am currently working on a project that involves crawling certain websites. However sometimes
I'm currently working on an App that has a couple of Entities and relationships
I am currently working on a private web application that is not going to
I'm currently working on a small script that needs to use gtk.StatusIcon() . For
BACKGROUND: I'm currently working on building a photography gallery where I release a new
I am currently working on a project that uses a Google Earth API library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.