Staredit Network > Forums > Null > Topic: Share Your Programs/Scripts/Etc.
Share Your Programs/Scripts/Etc.
Jul 5 2010, 5:44 am
By: Sand Wraith  

Jul 5 2010, 5:44 am Sand Wraith Post #1

she/her

http://www.staredit.net/?p=shoutbox&view=959

here we r to share in our cleverness and attention-whoring

By the previous line I mean that I'm sure a lot of us here at SEN know bits of scripts, programming, macros, etc. to troll improve life, and I think that opening up a topic to share such tidbits would be interesting and beneficial for us all especially those of us who don't receive much attention in real life or don't desire attention from real people.
For example, several of the members here have once spammed the shoutbox with "waves" of lines generated by [sup] and [sub] BBcode abuse, and one member even had a JS script (durr) handy to do so. I'm sure many of us that were online to observe the spectacle was at least slightly amused.

So, here's one example of the type of (non-malicious) things we can share.

C++ go! (Attached as an EXE, too. Programmed, compiled, built in Visual C++.)
What the following code does is reverse an input string. E.g. "123" to "321". It also writes it to an "output.txt" in the folder that the EXE is located in.
Code
#include <iostream>
#include <sstream>
#include <fstream>

using namespace std;

int main ()
{
    string in, out;
    while( true )
    {
        cout << "Input the string to be translated into Hell Speech." << endl; // how-to
        cout << ">> "; // prompt
        getline( cin, in ); // input
        out = in; // prepare to translate
        for( int i = in.length(); i > 0; i-- ) // loop for translating
        {
            out[ i - 1 ] = in.at( in.length() - i ); // translating
        }
        cout << out << endl; // output and preparation for another iteration

        ofstream outFile;
        outFile.open( "output.txt", ios::trunc );
        if( outFile.is_open() )
        {
            outFile << out;
            outFile.close();
            cout << "Output file success.";
        }
        else
            cout << "Was unable to output file.";
        cout << "\n" << endl;
    }
    return 0;
}


I guess we can also flame/commend each other in regards to coding technique/etc. here too.

Post has been edited 1 time(s), last time on Aug 20 2010, 8:17 am by Sand Wraith.




Jul 5 2010, 5:57 am Sand Wraith Post #2

she/her

here's something else
http://www.staredit.net/?p=shoutbox&view=904

Post has been edited 1 time(s), last time on Jul 5 2010, 6:14 am by Merrell.




Jul 5 2010, 5:59 am DavidJCobb Post #3



This JS function will take any non-ASCII character in a string and convert it into a numeric HTML entity.

function DoShit (str) {
return str.replace(
/[\u0080-\uFFFF]/g,
function(a){
return "&#"+a.charCodeAt(0)+";"
}
);
}




None.

Jul 5 2010, 6:22 am Sand Wraith Post #4

she/her

Errr, how do I implement that? I know next to nothing about web development, despite having "developed" multiple basic HTML websites. >_<




Jul 5 2010, 7:47 am Sand Wraith Post #5

she/her

I updated ma shiz. Can now read "input.txt" if the prompt is answered by "input".

Code
#include <iostream>
#include <sstream>
#include <fstream>

using namespace std;

int main ()
{
    string in, out;
    while( true )
    {
        cout << "Input the string to be translated into Hell Speech." << endl; // how-to
        cout << "(Entering in \"input\" will cause the program to translate \"input.txt\".)" << endl;
        cout << ">> "; // prompt
        getline( cin, in ); // input

        if( in != "input" ) // normal input
        {
            out = in; // prepare to translate
            for( int i = in.length(); i > 0; i-- ) // loop for translating
            {
                out[ i - 1 ] = in.at( in.length() - i ); // translating
            }
            cout << out << endl; // output and preparation for another iteration

            ofstream outFile;
            outFile.open( "output.txt", ios::trunc );
            if( outFile.is_open() )
            {
                outFile << out;
                outFile.close();
                cout << "Output file success." << endl;
            }
            else
                cout << "Was unable to output file.";
        }
        else // file input
        {
            ifstream inFile;
            inFile.open( "input.txt" );
            if( inFile.is_open() )
            {
                ofstream outFile; // preparing to write
                outFile.open( "output.txt", ios::trunc );
                cout << "The following is the text found.\n" << endl;
                while( ! inFile.eof() )
                {
                    getline( inFile, in );
                    out = in; // prepare to translate
                    for( int i = in.length(); i > 0; i-- ) // loop for translating
                    {
                        out[ i - 1 ] = in.at( in.length() - i ); // translating
                    }
                    outFile << out << endl;
                    cout << in << endl;
                }
                if( outFile.is_open() ) // writing
                {
                    cout << "\nOutput file success." << endl;
                }
                else
                    cout << "Was unable to output file.";
                outFile.close();
                inFile.close();
            }
            else
                cout << "Was unable to open input file.";
        }

        cout << endl;
    }
    return 0;
}


ratS eulB


edoc hceepS lleH


Attachments:
Hell Speech.exe
Hits: 1 Size: 41.5kb

Post has been edited 1 time(s), last time on Jul 5 2010, 7:54 am by Sand Wraith.




Jul 5 2010, 3:06 pm Riney Post #6

Thigh high affectionado

Feast your eyes upon a script I made that allowed you to mine in one cave, with one pickaxe, on one rock, with only one proficiency mastery, with one rock possible to come out, as well as one gem to come out at random, for my old ass game Lands of Lingia.



Point of the matter is this, you said post scripts, you didnt say how useful they could be ;D



.riney on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

Sure I didn't pop off on SCBW like I wanted to, but I won VRChat. Map maker for life.

Jul 5 2010, 6:28 pm Sand Wraith Post #7

she/her

Oh my. :rip:

The code... Errr, what language is that?




Jul 5 2010, 6:43 pm Azrael Post #8



VB.




Jul 5 2010, 6:51 pm CecilSunkure Post #9



Lol DM that code was terrible.

Here is the most updated version of that text RPG I was making, and had to postpone due to personal reasons:

Code
import random

MAP1 = [
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 3],
   [1, 7, 0, 0, 0, 2, 1, 6, 1, 3],
   [1, 1, 2, 0, 0, 0, 1, 0, 1, 3],
   [1, 0, 1, 0, 0, 0, 2, 0, 1, 3],
   [1, 0, 1, 1, 0, 0, 1, 0, 1, 3],
   [1, 0, 0, 0, 0, 0, 0, 0, 1, 3],
   [1, 0, 0, 2, 1, 0, 1, 1, 1, 3],
   [1, 2, 0, 7, 1, 0, 0, 5, 1, 3],
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 3]
   ]

MAP2 = [
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 3],
   [1, 7, 0, 0, 0, 2, 1, 6, 1, 3],
   [1, 1, 2, 0, 0, 0, 1, 0, 1, 3],
   [1, 0, 1, 0, 0, 0, 2, 0, 1, 3],
   [1, 0, 1, 1, 0, 0, 1, 0, 1, 3],
   [1, 0, 0, 0, 0, 0, 0, 0, 1, 3],
   [1, 0, 0, 2, 1, 0, 1, 1, 1, 3],
   [1, 2, 0, 7, 1, 0, 0, 5, 1, 3],
   [1, 1, 1, 1, 1, 1, 1, 1, 1, 3]
   ]


class gameField:
   def __init__(self, mapData=[0]):
       self.mapData = mapData
       self.string = ''
       self.blocks = []
       for i in range(len(self.mapData)):
           for j in range(len(self.mapData[i])):
               if self.mapData[i][j] == 2:
                   r = random.randrange(0, 4)+1
                   if r == 1:
                       self.blocks.append(' v ')
                   if r == 2:
                       self.blocks.append(' x ')
                   if r == 3:
                       self.blocks.append(' ^ ')
                   if r == 4:
                       self.blocks.append(' * ')
                   if r == 5:
                       self.blocks.append(' ~ ')

class character:
   def __init__(self, x=0, y=0, field=None, startwep=None):
       self.crds = [x, y] #crds = coordinates
       self.x = self.crds[0]
       self.y = self.crds[1]
       self.field = field #This links the current playing field with the character. The purpose was to make is easy to manipulate the player's coordinates in reference to the current game field. field would be an instance of the gameField class.
       self.inventory = {'Slot1':None, 'Slot2':None, 'Slot3':None, 'Equipped':None, 'Gold':0,}
       self.hp = 100
       self.inventory['Equipped'] = startwep

   def __str__(self):
       s = ''
       r = 0
       for i in range(len(self.field.mapData)):
           for j in range(len(self.field.mapData[i])):
               if self.field.mapData[i][j] == 4:
                   self.field.mapData[i][j] = 0
       self.field.mapData[self.y][self.x] = 4
       for i in range(len(self.field.mapData)):
           for j in range(len(self.field.mapData[i])):
               if self.field.mapData[i][j] == 0:
                   s += '   '
               elif self.field.mapData[i][j] == 1:
                   s += ' / '
               elif self.field.mapData[i][j] == 2:
                   r += 1
                   s += self.field.blocks[r-1]
               elif self.field.mapData[i][j] == 3:
                   s += '\n'
               elif self.field.mapData[i][j] == 4:
                   s += ' O '
               elif self.field.mapData[i][j] == 5:
                   s += ' S '
               elif self.field.mapData[i][j] == 6:
                   s += '[/]'
               elif self.field.mapData[i][j] == 7:
                   s += '{"}'
               elif self.field.mapData[i][j] == 8:
                   s += '{_}'
       self.field.string = s
       return self.field.string

   def isValidMove(self, move):
       '''This method just checks to see if a desired move is valid.
       The coordinates must be referenced backwards due to the way I use
       lists of lists to store coordinates. It would actually be more
       efficient if I converted the lists to tuples after instantiation.
       Oh well.'''
       
       if move == 'a':
           if self.field.mapData[self.y][self.x - 1] != 0:
               return False
       if move == 'a':
           if self.field.mapData[self.y][self.x - 1] == 0:
               return True
       if move == 'w':
           if self.field.mapData[self.y - 1][self.x] != 0:
               return False
       if move == 'w':
           if self.field.mapData[self.y - 1][self.x] == 0:
               return True
       if move == 's':
           if self.field.mapData[self.y + 1][self.x] != 0:
               return False
       if move == 's':
           if self.field.mapData[self.y + 1][self.x] == 0:
               return True
       if move == 'd':
           if self.field.mapData[self.y][self.x + 1] != 0:
               return False
       if move == 'd':
           if self.field.mapData[self.y][self.x + 1] == 0:
               return True

class item:
   def __init__(self, name='', drange=[1, 4], itype='', price=0):
       self.name = name
       self.drange = drange
       self.itype = itype
       self.price = price

   def attackRoll(self):
       #Ranges in the if comparisons are for hit/miss.
       #Ranges of drange[0]-[1] are for the weapon's damage ranges.
       
       if self.itype == 'Small':
           if random.randrange(1, 12) > 1:
               return random.randrange(self.drange[0], self.drange[1]+1)
           else:
               return 0

       if self.itype == 'Medium':
           if random.randrange(1, 9) > 1:
               return random.randrange(self.drange[0], self.drange[1]+1)
           else:
               return 0

       if self.itype == 'Large':
           if random.randrange(1, 5) > 1:
               return random.randrange(self.drange[0], self.drange[1]+1)
           else:
               return 0

class monster:
   def __init__(self, name='', size=0, weapon=[0]):
       self.size = size
       self.name = name

       if self.size == 0:
           self.hp = 10
           self.size = 'Small'
           self.weapon = item('Small Claws', [1, 4], 'Small')
       if self.size == 1:
           self.hp = 20
           self.size = 'Medium'
           self.weapon = item('Fists', [2, 6], 'Medium')
       if self.size == 2:
           self.hp = 30
           self.size = 'Large'
           self.weapon = item('Maul', [1, 12], 'Large')
       else:
           self.hp = 10
           self.size = 'Small'

       #Allows to instantiate a monster holding a specific weapon. Will not fire if a specific weapon argument was not supplied.
       if weapon[0] != 0:
           self.weapon = item(weapon[0], weapon[1], weapon[2])

def battle(playerCharacter, battleLevel=1, enemy=None):

   turn = random.randrange(0, 2) + 1
   print('\n' + 'Battle Initiated.')
   b = raw_input()
   
   if battleLevel == 1 and enemy == None:
       a = random.randrange(0, 2) + 1
       if a == 1:
           enemy = monster('Small Creature #1', 0, ['Small Claws', [1, 4], 'Small'])
       if a == 2:
           enemy = monster('Small Creature #2', 0, ['Sharp Claws', [2, 5], 'Small'])

   while enemy.hp > 0 and playerCharacter.hp > 0:
       print ('Player    |    ' + enemy.name)
       if playerCharacter.hp == 100:
           print ('   ' + str(playerCharacter.hp) + '    |    ' + str(enemy.hp))
       else:
           print ('    ' + str(playerCharacter.hp) + '    |    ' + str(enemy.hp))
       print ('     o    |    x')
       print ('')
       if turn == 1:
           print ('The enemy is attacking you! (press enter)')
           b = raw_input()
           attackRoll = enemy.weapon.attackRoll()
           playerCharacter.hp -= attackRoll
           print ('The enemy hit you with its ' + enemy.weapon.name + ' dealing ' + str(attackRoll) + ' damage! (press enter)')
           b = raw_input()
           if enemy.hp <= 0:
               print ('You have been defeated by the ' + enemy.name + '! (press enter)')
               b = raw_input()
           turn = 2
           
       elif turn == 2:
           print ('It is your turn to fight! Press enter to attack!')
           b = raw_input()
           if playerCharacter.inventory['Equipped'] != None:
               attackRoll = playerCharacter.inventory['Equipped'].attackRoll()
           else:
               attackRoll = 1
           enemy.hp -= attackRoll
           if playerCharacter.inventory['Equipped'] != None:
               print ('You hit the enemy with your ' + playerCharacter.inventory['Equipped'].name + ' dealing ' + str(attackRoll) + ' damage! (press enter)')
           else:
               print ('You hit the enemy with your fists dealing 1 damage!')
           b = raw_input()
           if enemy.hp <= 0:
               print ('You have defeated the ' + enemy.name + '! (press enter)')
               b = raw_input()
               return enemy.size
           turn = 1
       else:
           return

def battleTreasure(val, currentPlayer):
   
   diceRoll1 = random.randrange(0, 20) + 1
   diceRoll2 = random.randrange(0, 5) + 1

   if val == 'Small' and diceRoll1 < 15:
       currentPlayer.inventory['Gold'] += diceRoll2
       print('You gained ' + str(diceRoll2) + ' gold from winning the battle!')
       b = raw_input()
       print('You now have ' + str(currentPlayer.inventory['Gold']) + ' gold.')
       b = raw_input()


http://cecilsunkure.blogspot.com/2010/04/mini-rpg-just-started.html
http://cecilsunkure.blogspot.com/2010/05/mini-rpg-continued.html

I had plans to add in armor, any other types of items I wanted, and lots more rooms, NPC characters, and possibly an ability to load a .txt file with a pre-configured map layout. Although since I'm grounded and trying to get to college I can't work on things like this anymore.



None.

Jul 5 2010, 6:51 pm CecilSunkure Post #10



Code
def shop(currentPlayer, shopx=0):

   while shopx == 0:
       print('Welcome to the shop! What would you like to buy? (1-3)')
       print('1. Short Sword : Small  : 10 Gold')
       print('2. Mace        : Medium : 20 Gold')
       print('3. Halberd     : Large  : 30 Gold')
       print('4. Potion      : 1 use  : 5  Gold')
       print('Exit: Any other key.')
       choice = raw_input()

       slot = findEmptyInventorySlot(currentPlayer)

       if choice == '1':
           buy(currentPlayer, SHORTSWORD, slot)

       if choice == '2':
           buy(currentPlayer, MACE, slot)

       if choice == '3':
           buy(currentPlayer, HALBERD, slot)

       if choice == '4':
           buy(currentPlayer, POTION, slot)
           
       else:
           return

def buy(currentPlayer, item, slot):
   if currentPlayer.inventory['Gold'] >= item.price:
       slot = findEmptyInventorySlot(currentPlayer)
       if slot != None:
           currentPlayer.inventory[slot] = item
           currentPlayer.inventory['Gold'] -= item.price
           print('You purchased a ' + currentPlayer.inventory[slot].name + '!')
           b = raw_input()
           choice = 0
           return
       
   elif currentPlayer.inventory['Gold'] < item.price:
       print('That is not enough money! You need ' + str(item.price) + ' Gold. (press enter)')
       b = raw_input()
       return
   
   else:
           print('Your inventory is full!')
           b = raw_input()
           return

def inventory(currentPlayer):
   
   while True:
       print('Your current inventory, pick a number to use/equip an item:')
       s = inventoryDisplay('1.', currentPlayer.inventory['Slot1'])
       print(s)
       s = inventoryDisplay('2.', currentPlayer.inventory['Slot2'])
       print(s)
       s = inventoryDisplay('3.', currentPlayer.inventory['Slot3'])
       print(s)
       s = inventoryDisplay('4.', currentPlayer.inventory['Equipped'], 'Equipped')
       print(s)
       print('5. Enter Discard Menu')
       print('Press any other key to exit.')
       choice = raw_input()
       
       if choice != '1' and choice != '2' and choice != '3' and choice != '4' and choice != '5':
           return
       if choice == '1':
           useItem('Slot1', currentPlayer)
       if choice == '2':
           useItem('Slot2', currentPlayer)
       if choice == '3':
           useItem('Slot3', currentPlayer)
       if choice == '5':
           discard(currentPlayer)

def discard(currentPlayer):
   while True:
       print('Your current inventory, pick a number to discard an item:')
       s = inventoryDisplay('1.', currentPlayer.inventory['Slot1'])
       print(s)
       s = inventoryDisplay('2.', currentPlayer.inventory['Slot2'])
       print(s)
       s = inventoryDisplay('3.', currentPlayer.inventory['Slot3'])
       print(s)
       s = inventoryDisplay('4.', currentPlayer.inventory['Equipped'], 'Equipped')
       print(s)
       print('Press any other key to enter the inventory menu.')
       choice = raw_input()

       if choice != '1' and choice != '2' and choice != '3' and choice != '4' and choice != '5':
           return
       if choice == '1':
           currentPlayer.inventory['Slot1'] = None
       if choice == '2':
           currentPlayer.inventory['Slot2'] = None
       if choice == '3':
           currentPlayer.inventory['Slot3'] = None
       if choice == '4':
           currentPlayer.inventory['Equipped'] = None
           print('You discared an equipped item! Be sure to equip another for battle.')
           b = raw_input()
   

def useItem(slot, currentPlayer):
   if currentPlayer.inventory[slot] == POTION:
       currentPlayer.hp += 20
       currentPlayer.inventory[slot] = None
       print('You used a potion! You have been healed by 20 hp. (press enter)')
       b = raw_input()
   if currentPlayer.inventory[slot] != None:
       if currentPlayer.inventory['Equipped'] != None:
           c = currentPlayer.inventory['Equipped']
           currentPlayer.inventory['Equipped'] = currentPlayer.inventory[slot]
           currentPlayer.inventory[slot] = c
           del(c)
           print(currentPlayer.inventory['Equipped'].name + ' has been equipped! (press enter)')
           b = raw_input()
       else:
           currentPlayer.inventory['Equipped'] = currentPlayer.inventory[slot]
           currentPlayer.inventory[slot] = None
           print(currentPlayer.inventory['Equipped'].name + ' has been equipped! (press enter)')
           b = raw_input()
   else:
       print('There is nothing in this slot to use! (press enter)')
       b = raw_input
       
       

def inventoryDisplay(number, item, slotType=''):
   if item == DAGGER and slotType != 'Equipped':
       s = number + ' ' + item.name + '      : ' + item.itype + '  : ' + '1 - 4  Damage'
       return s
   elif item == SHORTSWORD and slotType != 'Equipped':
       s = number + ' ' + item.name + ' : ' + item.itype + '        : ' + '1 - 8  Damage'
       return s
   elif item == MACE and slotType != 'Equipped':
       s = number + ' ' + item.name + ' : ' + item.itype + ' : ' + '3 - 10 Damage'
       return s
   elif item == POTION and slotType != 'Equipped':
       s = number + ' ' + item.name + '     : ' + item.itype + '  : ' + 'Heals 20 damage'
       return s
   elif item == HALBERD and slotType != 'Equipped':
       s = number + ' ' + item.name + '    : ' + item.itype + '  : ' + '1-25 Damage'
       return s
   elif slotType == 'Equipped':
       '4. Potion      : 1 use  : 5  Gold'
       'Equipped Item  : '
       if item == DAGGER:
           s = number + ' Equipped Item : ' + item.name + ' : ' + item.itype + ' : ' + '1 - 4 Damage'
           return s
       elif item == SHORTSWORD:
           s = number + ' Equipped Item : ' + item.name + ' : ' + item.itype + ' : ' + '1 - 8 Damage'
           return s
       elif item == MACE:
           s = number + ' Equipped Item : ' + item.name + ' : ' + item.itype + ' : ' + '3 - 10 Damage'
           return s
       elif item == POTION:
           s = number + ' Equipped Item : ' + item.name + ' : ' + item.itype + ' : ' + 'Heals 20 damage'
           return s
       elif item == HALBERD:
           s = number + ' Equipped Item : ' + item.name + ' : ' + item.itype + ' : ' + '1-25 Damage'
           return s
       else:
           return ' Nothing Equipped'

   else:
       s = number + ' Empty Slot :        :'
       return s

def findEmptyInventorySlot(currentPlayer):
   if currentPlayer.inventory['Slot1'] == None:
       return 'Slot1'
   elif currentPlayer.inventory['Slot2'] == None:
       return 'Slot2'
   elif currentPlayer.inventory['Slot3'] == None:
       return 'Slot3'
   else:
       return None

def action(currentPlayer):
   upy = currentPlayer.y - 1
   downy = currentPlayer.y + 1
   leftx = currentCharacter.x - 1
   rightx = currentCharacter.x + 1

   if currentPlayer.field.mapData[currentCharacter.y][leftx] == 5 or currentPlayer.field.mapData[currentCharacter.y][rightx] == 5 or currentPlayer.field.mapData[upy][currentCharacter.x] == 5 or currentPlayer.field.mapData[downy][currentCharacter.x] == 5:
       return 'Store'
   elif currentPlayer.field.mapData[currentCharacter.y][leftx] == 6 or currentPlayer.field.mapData[currentCharacter.y][rightx] == 6 or currentPlayer.field.mapData[upy][currentCharacter.x] == 6 or currentPlayer.field.mapData[downy][currentCharacter.x] == 6:
       return 'Door'
   elif currentPlayer.field.mapData[currentCharacter.y][leftx] == 7 or currentPlayer.field.mapData[currentCharacter.y][rightx] == 7 or currentPlayer.field.mapData[upy][currentCharacter.x] == 7 or currentPlayer.field.mapData[downy][currentCharacter.x] == 7:
       return 'Chest'
   else:
       return None

def chest(currentPlayer, level=0):
   upy = currentPlayer.y - 1
   downy = currentPlayer.y + 1
   leftx = currentCharacter.x - 1
   rightx = currentCharacter.x + 1
   
   if currentPlayer.field.mapData[currentCharacter.y][leftx] == 7:
       chesty = currentCharacter.y
       chestx = leftx
   if currentPlayer.field.mapData[currentCharacter.y][rightx] == 7:
       chesty = currentCharacter.y
       chestx = rightx
   if currentPlayer.field.mapData[upy][currentCharacter.x] == 7:
       chesty = upy
       chestx = currentCharacter.x
   if currentPlayer.field.mapData[downy][currentCharacter.x] == 7:
       chesty = downy
       chestx = currentCharacter.x

   currentPlayer.field.mapData[chesty][chestx] = 8
   slot = findEmptyInventorySlot(currentPlayer)

   if slot != None:
       if level == 0 and random.randrange(0, 2) == 0:
           currentPlayer.inventory[slot] = POTION
           print('Acquired one potion from the chest! (press enter)')
           b = raw_input()
       elif level == 0 and random.randrange(0, 2) == 1:
           currentPlayer.inventory['Gold'] += 10
           print('Acquired ten gold from the chest! (press enter)')
           b = raw_input()
       return

   else:
       print('Your inventory is full! Cannot open chest. (press enter)')
       currentPlayer.field.mapData[chesty][chestx] == 7
       b = raw_input()
       return
           

#These lines set up the game by creating field, character, and item instances.    
GameField1 = gameField(MAP1)
GameField2 = gameField(MAP2)
DAGGER = item('Small Dagger', [1, 4], 'Small', 5)
SHORTSWORD = item('Short Sword', [1, 8], 'Small', 10)
MACE = item('Mace', [3, 10], 'Medium', 20)
HALBERD = item('Halberd', [1, 25], 'Large', 30)
POTION = item('Potion', [0, 0], '1 use', 5)
currentCharacter = character(3, 1, GameField1, DAGGER)

#Cheats! Uncomment these to activate them.
currentCharacter.inventory['Gold'] = 50


while True:
   print(currentCharacter)
   char = raw_input()

   #Store character's current position.
   oldx = currentCharacter.x
   oldy = currentCharacter.y
   
   if char == 'a':
       if currentCharacter.isValidMove(char):
           currentCharacter.x -= 1
   if char == 'd':
       if currentCharacter.isValidMove(char):
           currentCharacter.x += 1
   if char == 'w':
       if currentCharacter.isValidMove(char):
           currentCharacter.y -= 1
   if char == 's':
       if currentCharacter.isValidMove(char):
           currentCharacter.y += 1
   if char == 'e':
       #e is the action button.
       event = action(currentCharacter)
       if event == 'Store':
           shop(currentCharacter, 0)
       if event == 'Chest':
           chest(currentCharacter, 0)
       else:
           if event == None:
               print('Nothing interesting here')
           else:
               print(str(event))
               
   if char == 'i':
       inventory(currentCharacter)

   #Check to see if the character moved.
   if (oldx != currentCharacter.x or oldy != currentCharacter.y) and char != 'e':
       diceRoll = random.randrange(0, 20) + 1
   else:
       diceRoll = 0

   #If dice roll passed (only if character moved last time step), then initiate battle.
   if diceRoll > 17 and diceRoll < 21:
       battleValue = battle(currentCharacter)
       battleTreasure(battleValue, currentCharacter)


Continued due to post size limit. Written in python.

The basic idea was to use classes to create the objects, and then instantiate multiple types of objects from there. For example I have an item class. To create a new type of item I would make a call to the class fulfilling the "constructor's" arguments. To allow me to manipulate the field with a player method, I assigned the entire field to one of the character's data types during instantiation of the player.

Truly, my main loop was simply this:

Code
while True:
   print(currentCharacter)
   char = raw_input()

   #Store character's current position.
   oldx = currentCharacter.x
   oldy = currentCharacter.y
   
   if char == 'a':
       if currentCharacter.isValidMove(char):
           currentCharacter.x -= 1
   if char == 'd':
       if currentCharacter.isValidMove(char):
           currentCharacter.x += 1
   if char == 'w':
       if currentCharacter.isValidMove(char):
           currentCharacter.y -= 1
   if char == 's':
       if currentCharacter.isValidMove(char):
           currentCharacter.y += 1
   if char == 'e':
       #e is the action button.
       event = action(currentCharacter)
       if event == 'Store':
           shop(currentCharacter, 0)
       if event == 'Chest':
           chest(currentCharacter, 0)
       else:
           if event == None:
               print('Nothing interesting here')
           else:
               print(str(event))
               
   if char == 'i':
       inventory(currentCharacter)

   #Check to see if the character moved.
   if (oldx != currentCharacter.x or oldy != currentCharacter.y) and char != 'e':
       diceRoll = random.randrange(0, 20) + 1
   else:
       diceRoll = 0

   #If dice roll passed (only if character moved last time step), then initiate battle.
   if diceRoll > 17 and diceRoll < 21:
       battleValue = battle(currentCharacter)
       battleTreasure(battleValue, currentCharacter)


The rest of the code was just setting up my data and functions.

Here is the .exe and source code for I think the latest version: http://www.mediafire.com/?inmezfzgwdz

However, you start with 50 gold for testing, which I forgot to remove :(

Post has been edited 1 time(s), last time on Jul 5 2010, 7:03 pm by CecilSunkure.



None.

Jul 5 2010, 7:12 pm DavidJCobb Post #11



@Sandy:

var StringThatIWantToFuckUp = "O HAI THERE 〈";
alert(DoShit(StringThatIWantToFuckUp)); // Displays "O HAI THERE &#9001;"




None.

Jul 5 2010, 11:36 pm Rantent Post #12



I would post this molecular modeling program I made for the university, but I technically don't own the rights to it.
:(
My one good program, and I can't post it.



None.

Jul 6 2010, 12:53 am Aristocrat Post #13



Not a script, but an applet. First one I ever made.

http://dl.dropbox.com/u/2426275/xyrus.clan-boa.com/extern/chaosbrot/index.html



None.

Jul 6 2010, 1:04 am Riney Post #14

Thigh high affectionado

Quote from Sand Wraith
Oh my. :rip:

The code... Errr, what language is that?


VB6 <3 Damn if only they could update it to be more functional and become an industry standard Id be in the programming market.



.riney on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

Sure I didn't pop off on SCBW like I wanted to, but I won VRChat. Map maker for life.

Jul 6 2010, 3:28 am DavidJCobb Post #15



alert("VBScript is the spawn of the devil. It has ugly syntax, diminished and inconsistent functionality, nonsensical\
keywords, and a horrible appearance. What the fuck is a \"sub\"? If it can't have turkey and pickles on it, it needs\
to eat shit and die. And \"dim\" to define a function? I think the guy who came up with that keyword was a little\
\"dim\", if ya know what I mean. It's time to chop off VB's head and shit down its neck, if I may borrow and\
bastardize a quote from the legendary Duke Nukem.");


I just wrote that off the top of my head.

Post has been edited 3 time(s), last time on Jul 6 2010, 3:35 am by DavidJCobb.



None.

Jul 6 2010, 3:50 am Sand Wraith Post #16

she/her

Quote from DavidJCobb
alert("VBScript is the spawn of the devil. It has ugly syntax, diminished and inconsistent functionality, nonsensical\
keywords, and a horrible appearance. What the fuck is a \"sub\"? If it can't have turkey and pickles on it, it needs\
to eat shit and die. And \"dim\" to define a function? I think the guy who came up with that keyword was a little\
\"dim\", if ya know what I mean. It's time to chop off VB's head and shit down its neck, if I may borrow and\
bastardize a quote from the legendary Duke Nukem.");

\lacisnesnon ,ytilanoitcnuf tnetsisnocni dna dehsinimid ,xatnys ylgu sah tI .lived eht fo nwaps eht si tpircSBV"(trela
\sdeen ti ,ti no selkcip dna yekrut evah t'nac ti fI ?"\bus"\ a si kcuf eht tahW .ecnaraeppa elbirroh a dna ,sdrowyek
\elttil a saw drowyek taht htiw pu emac ohw yug eht kniht I ?noitcnuf a enifed ot "\mid"\ dnA .eid dna tihs tae ot
\dna worrob yam I fi ,kcen sti nwod tihs dna daeh s'BV ffo pohc ot emit s'tI .naem I tahw wonk ay fi ,"\mid"\
;)".mekuN ekuD yradnegel eht morf etouq a ezidratsab





Jul 6 2010, 8:25 pm O)FaRTy1billion[MM] Post #17

👻 👾 👽 💪

Code
void ParsePUPx(){
 int i,j;
 for(i=0;i<61;i++){
  switch(i){
   case 18:
   case 45:
   case 46:
   case 48:
   case 50:
   case 55:
   case 56:
   case 57:
   case 58:
   case 59:
    for(j=0;j<12;j++){
     mapPUPx[j*61+i] = 0;
     mapPUPx[732 + j*61+i] = 0;
     mapPUPx[1586 + j*61+i] = 0;
    }
    mapPUPx[1525 + i] = 0;
    mapPUPx[1464 + i] = 0;
    break;
   case 60:
    for(j=0;j<12;j++){
     mapPUPx[j*61+i] = 0;
     if(j < 8 && UsedPlayers[j] == -1){
      mapPUPx[732 + j*61+i] = 0;
      mapPUPx[1586 + j*61+i] = 0;
     }else{
      if(mapPUPx[1586 + j*61+i] != 0 || mapPUPx[732 + j*61+i] == mapPUPx[1525 + i]){
       mapPUPx[732 + j*61+i] = 0;
       mapPUPx[1586 + j*61+i] = 1;
      }
     }
    }
    mapPUPx[1464 + 60] = 0;
    break;  
   default:
    for(j=0;j<12;j++){
     if(j < 8 && UsedPlayers[j] == -1){
       mapPUPx[j*61+i] = 0;
       mapPUPx[732 + j*61+i] = 0;
       mapPUPx[1586 + j*61+i] = 0;
     }else{
      if(mapPUPx[1586 + j*61+i] != 0 || (mapPUPx[j*61+i] == mapPUPx[1464 + i] && mapPUPx[732 + j*61+i] == mapPUPx[1525 + i])){
       mapPUPx[j*61+i] = 0;
       mapPUPx[732 + j*61+i] = 0;
       mapPUPx[1586 + j*61+i] = 1;
      }else{
       if(mapPUPx[732 + j*61+i] >= mapPUPx[j*61+i]) mapPUPx[j*61+i] = 0;
      }
     }
    }
    if(mapPUPx[1525 + i] >= mapPUPx[1464 + i]) mapPUPx[1464 + i] = 0;
  }
 }
}

TinyMap2 is awesome. :awesome:

Also this is better than the other way I was going to do it ... Before I was just going to have a multi-dimensional void array for sections. :P



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Jul 6 2010, 8:40 pm Sand Wraith Post #18

she/her

Switch is super convenient and super awesome.




Jul 6 2010, 8:47 pm O)FaRTy1billion[MM] Post #19

👻 👾 👽 💪

Except I loaded .dat files so I wouldn't need it ... But I guess I never implemented them. :P

This one is fun because I had to fix it 2 or 3 times!
Code
void ParseMASK(){
 int i,j;
 unsigned char mask = 0;
 j = 1;
 for(i=0;i<8;i++){
  if(mapOWNR[i] != 6) mask |= j;
  j <<= 1;
 }
 for(i=0;i<mapDIM[0]*mapDIM[1];i++){
  mapMASK[i] |= mask;
 }
}

How could that ever possibly be broken, amirite?

:P The file the has all of the section compressing functions is over 2100 lines. I don't comment.

Post has been edited 1 time(s), last time on Jul 6 2010, 8:56 pm by FaRTy1billion.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:09 pm]
Ultraviolet -- :wob:
[2024-6-12. : 6:23 am]
Ultraviolet -- got some light recalls behind too
[2024-6-12. : 12:07 am]
O)FaRTy1billion[MM] -- 🦗
[2024-6-11. : 9:53 pm]
Wing Zero -- I wonder how he knew I was in the market for a good cricket bat
[2024-6-11. : 2:27 pm]
lil-Inferno -- ya
[2024-6-11. : 10:49 am]
Oh_Man -- or scarab maybeh
[2024-6-11. : 10:49 am]
Oh_Man -- shielt battery + photon cannon blast?
[2024-6-11. : 10:49 am]
Oh_Man -- check out the animation at 7:56
[2024-6-11. : 9:06 am]
Oh_Man -- https://youtu.be/3mpjxspSUtQ I defeated the hell boss yall, bow to my power
[2024-6-10. : 5:04 pm]
lil-Inferno -- poop
Please log in to shout.


Members Online: myocytebd, Kyradax, jun3hong, Roy