Free Script Repository + 2.54 Scripts

NOTE: FOR NOW THIS POSTS’ ORIGINAL CONTENT WILL STILL BE HERE, BUT I’LL BE REMOVED ONCE I UPDATE/MERGE ALL THESE SCRIPTS TO THE NEW REPO. THE REPO IS NOW A REAL REPOSITORY HOSTED ON GITHUB. TO VIEW/FORK/DOWNLOAD THE REPO, GO HERE: https://github.com/iGARET/bge-script-repo

http://img526.imageshack.us/img526/8523/scriptrepo.png

Welcome to the all new blender script repository! I’m trying to make this a lot more like an actual repo, with a big list right on the first post. It also makes it easier to find useful scripts (and see “needed” scripts) So without further ado let’s get on with the repo!

Note: If the script has a “++” added to it, it’s marked as “deluxe” which includes a .blend file.

http://img688.imageshack.us/img688/8495/scriptrepo254.png

UV Scroll Script++ - By: MayhemOfHell


My UV scroll script, upgraded to work with 2.54
courtesy of MayhemOfHell! Download includes
blend file.

http://www.blendupload.com/download_icons/blue.png

3 Utilities - By: andrew-101


Pack of 3 useful python utilities includes:

inSight: Determines if a point is within a an objects
sight cone. Assumes +y is forward.

singleRayCollisionDetection: Uses a single ray cast
in the direction of the object to detect if any objects
are infront of it. Assumes +y as forward.

multiRayCollisionDetection: Uses 3 rays cast in the
direction of the object to detect if any objects are
infront of it. Assumes +y as forward. More accurate
than single ray detection

http://www.blendupload.com/download_icons/blue.png

3in1 User Input Script++ - By: MayhemOfHell


Okay, once again it was time to update the standard
mouse look script… So… what do we have this time?

Current Script Features:

  • Mouse X & Y
  • Mouse Wheel Movement
  • Mouse Buttons
  • Keyboard Events
  • Adjustable Sensitivty
  • X & Y Invert on mouse
  • Mouse X & Y (pixel coords)
  • Mouse Wheel Movement (usual states… 0,1,2,3 for up and down)
  • Mouse Buttons (usuals states… 0,1,2,3 for left,middle,right)
  • Keyboard Events (handed to external function, hands of state and keyname)
  • Adjustable Wheel Sensitivty (Up & Down range)
  • Adjustable Mouse Sensitivty (X,Y range)
  • Adjustable Mouse Deadzone (X,Y range)
  • X & Y Invert on mouse movement(wheel invert will be added)
  • Screen adjusted based via OS (Needs other then windows)
  • Camera Correction Script
  • Some error correction to expaned
  • on inital load/flick issue (later to be fixed, not main issue atm)

All of this at the moment debugs via print().
More information here. Download includes blend file.

http://www.blendupload.com/download_icons/blue.png

Rubber Band Selection++ - By: -[Killer]-


Here’s my awesome new rubber band selection!
It doubles the size of whatever objects it “selects”
(although you can obviously do whatever you want
when it selects it)! It works in real time, and although
there’s many ways in which I could improve the script’s
speed (such as make it generate a list of selectable
objects on startup). The reason I didn’t do that, is
because it was for an RTS games and there’s objects
being made on the fly (possibly WHILE you’re rubber
band selecting) therefore you need to be able to select
that object instantly without rebuilding a list. Download
includes blend file.

http://www.blendupload.com/download_icons/blue.png

Real Time Mirror++ - By: MayhemOfHell


Real Time mirror script using the video texture
method! It’s confirmed working with 2.55!
Download includes blend file.

http://www.blendupload.com/download_icons/blue.png

http://img6.imageshack.us/img6/3581/scriptrepopre254.png

UV Scroll Script++ - By: -[Killer]-


A simple script that simply shifts the UV coordinates
slowly making it appear to “scroll”. It’s great for flowing
water, waterfalls, conveyer belts, even a sprite sheet!
Very simple script to read and understand. Download
includes blend file.

http://www.blendupload.com/download_icons/blue.png

Object Teleporter++ - By: -[Killer]-


A nice little teleporter I made a while back. I hope
Someone can find some good use for it! Video of
the script below. Download includes blend file.

http://www.blendupload.com/download_icons/blue.png

Mouse Track++ - By: Almost


Makes an object “snap” onto the cursor so that
the object moves with the mouse on the X and Y
axis. Perfect for custom cursors! Download includes
blend file.

http://www.blendupload.com/download_icons/blue.png

Damage++ - By: -[Killer]-


Here we go, here’s an interesting one, this is a
damage script that deals random damage with a
local health bar! Don’t know what I’m talking about?
Here’s a little explanation.

I set an IPO between 1 and 1000 (1000 being full)
You change the full property to whatever you want,
for this I’ll say if it’s set on 500, normally this would
set the IPO to only half full, but no, we want it full!
So that’s when this comes it! It devides 1000 by the
full health, then it gets the value and multiplies the
damage dealt by that number and assigns the IPO
to that. Download includes blend file.

http://www.blendupload.com/download_icons/blue.png

MouseLook++ - By: B3D00


Simple but effective mouselook script. Perfect for
first person viewpoints. Download includes blend
file.

http://www.blendupload.com/download_icons/blue.png

That’s all we have for now! Right now it appears there’s no scripts in demand, although if people request scripts they’ll be listed here.

If you would like to submit a script just reply using the following format:


<b>Script Name(++ if it includes blend file) - By: you're username linked to your profile!</b>
________________________________________
A brief description here.

PUT THE CODE FOR THE BLENDUPLOAD BLUE DOWNLOAD BUTTON HERE

Although not required it’s helpful if you upload the blend to blendupload.com for me. If you are really that lazy you can attach it and I will upload it myself. If you don’t have a blend file and only are submitting a python script, then save it as a .py file and upload to blendupload.com (yes, it accepts .py files). The reason for this is because it gets sloppy if there’s a bazillion attachments, and we want all the download links to look the same.

Thank you for checking out the FSR :smiley:

What does it do?

My assumption is that it moves a uv image along a face, which could be used for some video texture effects (Think text sliding across an object, or colours changing as a looping pattern moves across). There appears to be a sample blend if you’re interested, I might check it out later.

It works as a marquee would.

Here’s a simple portal. It’s basic but can easily be edited. It’s very easy for even a complete python newbie could understand.


################################################
##### Simple Portal ##### -[Killer]- ###########
### Do not remove this header from the script###
################################################

#Get the controller that activated the script
cont = GameLogic.getCurrentController()
#Get the owner of the controller
own = cont.getOwner()

# This loads the empty that the cube will exit out of
warppoint = GameLogic.getCurrentScene().getObjectList()["OBEmpty"]

# This gets the collision sensor
warp = cont.getSensor("warp")



# Get the position of the portal exit
warpto = warppoint.getPosition()
# Get the orientation of the portal exit
warporient = warppoint.getOrientation()





# if the cube collides with the entrance...
if warp.isPositive():
    # Set the position of the cube to the position of
    # the portal exit
    own.setPosition(warpto)
    # Set the orientation of the cube to the portal's
    # orientation.
    own.setOrientation(warporient)
    # When exiting the grav will reset, so we add this
    # so it looks like the motion never stopped.
    own.setLinearVelocity([0,0,-4.9],1)

And here’s the Blend:

Attachments

Warp.blend (170 KB)

How about somthing that makes an object track to the mouse on the x and y axis?


############

axis = '-y'

############

py = GameLogic.getCurrentController()
mousesensor = py.getSensor('mouse sensor')

ob = py.getOwner()

#just show the mouse once, at start
if not hasattr(GameLogic, 'mouseshown'):
	GameLogic.mouseshown = True
	import Rasterizer
	Rasterizer.showMouse(1)

#Only perform the following if the mouse is over an object. Otherwise errors would occur due to there not being a mouse hit position.
if mousesensor.isPositive():
	#get the mouse location and object location
	mx,my,mz = mousesensor.getHitPosition()
	obx,oby,obz = ob.getPosition()
	#
	#get the difference in location
	dx = mx-obx
	dy = my-oby
	vect = [dx,dy,0]	
	#
	if axis[0:1] == '-':
		vect = [-dx,-dy,0]
	#
	if axis[-1:] == 'x':	dir = 0
	elif axis[-1:] == 'y':	dir = 1
	elif axis[-1:] == 'z':	dir = 2
	#
	#track to the difference. the 1 means instant tracking; 0.1 could be used for a delay in tracking
	ob.alignAxisToVect(vect,dir,1)
	#
	#keep z axis pointing up, just in case
	ob.alignAxisToVect([0,0,1],2,1)
#

Edit; sure, here’s a blend.

Attachments

mouse tracking.blend (133 KB)

Could you post a blend?

Here we go, here’s an interesting one, this is a damage script that deals random damage with a local health bar! Don’t know what I’m talking about? Here’s a little explanation.

I set an IPO between 1 and 1000 (1000 being full) You change the full property to whatever you want, for this I’ll say if it’s set on 500, normally this would set the IPO to only half full, but no, we want it full! So that’s when this comes it! It devides 1000 by the full health, then it gets the value and multiplies the damage dealt by that number and assigns the IPO to that. Here’s the scripts:

Startup script:


own = GameLogic.getCurrentController().getOwner()


# this gets the multiplier value from the full
# health to the max health. ie: if the max health
# is 500 and the max ipo is 1000 the multiplier
# is set to 2, this means when 10 damage is done
# it takes 20 from the ipo.
GameLogic.multiplier = 1000/own.full
# this fills up the health bar.
own.health = own.full

Attack:


##################################################
### Awesome Damage Script! ### 2009 -[Killer]- ###
##################################################
### If you use DO NOT REMOVE THIS !!! Do no    ###
### claim you made this, and/or redistribute   ###
##################################################


## import the random module
## Make sure you have python 2.5.2
## installed to make this work.
import random


# get the controller and the owner
cont = GameLogic.getCurrentController()
own = cont.getOwner()

# get the keyboard sensor called "space"
space = cont.getSensor("space")

# consult to the startup script
mult = GameLogic.multiplier

# set the min value for the attack
min = 10
# set the max value for the attack
max = 20


# if the space (attack) button is pushed
# and you have more than 0.000001 health...
if space.isPositive() and own.health &gt;= 0.0000001:
	# generate a random int value between
	# the min variable and the max variable...
	damage = random.randint(min,max)
	# take the damage from the health
	own.health -= damage

	# this uses the previously defines multiplier
	# to generate a "local" number to remove from
	# the ipo.
	own.ipo -= damage*mult
	
	# this handles if the health gets lower than
	# 0 (ie: if the health is 2 and you attack
	# with more than 2 damage and it makes is negative...
	if own.health &lt;= 0:
		# set both the health and ipo to 0
		own.health = 0
		own.ipo = 0

And here’s the blend

Attachments

HealthDemo.blend (137 KB)

How about somthing that makes the mouse the parent of an object?

I give you my mouselook. No copyrite in herein blender game engine python script herein.
On your script, you could have used own.health>0.0 instead of own.health>=0.0000000000001


# - Mouselook Script

import Rasterizer as r

c=GameLogic.getCurrentController()
o=c.getOwner()

if hasattr(o, 'x')==0:
    o.x=0.0

mouse=c.getSensor("mouse")
lmotion=c.getActuator("leftright")
wmotion=c.getActuator("updown")
sens=0.0006

posx=(r.getWindowWidth()/2-mouse.getXPosition())*sens
posy=(r.getWindowHeight()/2-mouse.getYPosition())*sens

if o.x&lt;=-1 and posy&lt;0 or o.x&gt;=1 and posy&gt;0:
    posy = 0.0
o.x+=posy

lmotion.setDRot(0,0,posx,1)
wmotion.setDRot(posy,0,0,1)

GameLogic.addActiveActuator(wmotion,1)
GameLogic.addActiveActuator(lmotion,1)

r.setMousePosition(r.getWindowWidth()/2,r.getWindowHeight()/2)

Um could you post a blend? I am not sure how to make it work otherwise.

I have a thread about it, with a blend.
http://blenderartists.org/forum/showthread.php?t=145745

I really would like to see you guy’s document these scripts on the blenderwiki.
http://wiki.blender.org/index.php/Scripts/Catalog#Games
is empty!
So if anyone (B3D00 or killer)
want’s contact either Moguri or meta-androcto
on irc #blenderwiki
it would be of significant help.

made the uv scroll a “full fledged” function.


# UV Scroll script remix by cyborg_ar
# do what the fuck you want with it.

# Real men import all modules they use (really, don't rely on auto-import, DON'T)
import GameLogic #Note, not needed for the function, but by the example below.

def uvScroll(obj, amount, material=0):
    """
    Scroll the object's UV coordinates by the amount specified.
    
    @param obj: The object to have its UV scrolled.
    @type obj: KX_GameObject
    @param amount: The amount of movement to do.
    @type amount: 2 element (U, V) tuple or list. (BWAHAHA, no type checking, 
    so if its wrong, you'll get a deliciously misleading message)
    @param material: The material whose vertexes shall be transformed.
    @type material: Integer material index. A valid one, please
    """
    mesh = obj.getMesh() # grab a mesh proxy
    # now, scroll the UV coords the slowest way possible
    for index in xrange(mesh.getVertexArrayLength(material)):
        # do I really need to do this? why the hell there isn't a function to get a vertex list?
        vertex = mesh.getVertex(material,index) # WRYYYYYYYYYYY???????
        # EEWWWWW
        UV = vertex.getUV()
        vertex.setUV((UV[0] + amount[0], UV[1] + amount[1]))
    # end for
# end uvScroll

# usage example
# the object must have the xspeed and yspeed properties with the appropriate values :)
own = GameLogic.getCurrentController().getOwner()
uvScroll(own, (own.xspeed, own.yspeed))

Could someone make a script that allows a moving object to turn away from hitting objects with certain properties. Like an AI. I might use this for a racing game.

wow, thanks for sharing everyone!

Anyone have a script to edit a mesh’s faces while playing?
I’m just curious, but it’d be useful for level editors, I imagine.

afaik not possible, most of blender’s functions are not accessible when the game is running

You can edit the mesh to some degree, using gameOb.meshs, its no good for a level editor because the collision bounds don’t update if you change the mesh. gameOb.meshes will return a list of mesh proxies.