Blockland Forums > Modification Help

Is there a way to call a Torque function using Python and vice versa?

Pages: (1/4) > >>

adam savage:

Python as far as I know doesn't have functions such as GetWord() or GetSubStr(), so I was wondering if I could call torque functions in IDLE, and Python functions in Blockland somehow.

otto-san:

you can probably do it by making a local server in python and a tcpobject in blockland connect and having them communicate

Ephialtes:

You'll need Django, code in bit bucket and a continuous integration server for this.

Port:


--- Quote from: adam savage on June 11, 2012, 07:57:14 AM ---Python as far as I know doesn't have functions such as GetWord() or GetSubStr()

--- End quote ---

>>> foo = 'hello world'
>>> foo[0:5]
'hello'
>>> foo[0:2]
'he'
>>> foo[3]
'l'
>>> bar = foo.split(' ')
>>> bar
['hello', 'world']
>>> bar[0]
'hello'
>>> bar[1]
'world'
>>> bar[1] = 'blockland'
>>> ' '.join(bar)
'hello blockland'

Brian Smithers:


--- Quote from: adam savage on June 11, 2012, 07:57:14 AM ---Python as far as I know doesn't have functions such as GetWord() or GetSubStr(), so I was wondering if I could call torque functions in IDLE, and Python functions in Blockland somehow.

--- End quote ---


########################
#Sticks and Stones Lang#
#By Brian Smith        #
#Version 1 Build 1     #
########################
########
#SubStr#
########
def getSubStr(string,start,end):
   return string[start:end]
def strLen(string):
   return len(string)
######################
#Basic Word Functions#
######################
def firstWord(string):
   return string.split(" ")[0]
def restWords(string):
   return string.split(" ")[1:]
def lastWord(string):
   return string.split()[-1]
def getWordCount(string):
   words = string.split()
   return words.len()
def getWord(string,num)
   words = string.split('')
   if num > words.len():
      return -1
   else:
      return words[num]

#######################
#Basic Field Functions#
#######################
def getFieldCount(string):
   fields = string.split('\t')
   return fields.len()
def getField(string,num):
   fields = string.split('\t')
   if num > fields.len():
      return -1
   else:
      return fields[num]

######################
#Basic Line Functions#
######################
def getLineCount(string):
   lines = string.split('\n')
   return lines.len()
def getLine(string,num):
   lines = string.split('\n')
   if num > lines.len():
      return -1
   else:
      return lines[num]


:)

Pages: (1/4) > >>

Go to full version