Search DLab 1.0

Tuesday, August 31, 2010

Scripting Updates

      Ajarn Moe krub, right now we are trying to figure out abit more about the interactive HUD. The scripting is easy enough for us to figure out, however, we are still stuck on how to get the output to correspond to the input. We are learning from a blender file from the internet. In the file, when you click on 'buy banana' button, the number of bananas owned increases by one and the same goes for apple. Below is the ingame screen cap and the script.







# this line look if the apple sensor is activated
if buy_apples_sen.positive:

# Here we check if you have enought money to buy an apple
if owner["Money in pocket"] - owner["Apples price"] >= 0:

# Here we increment your number of apples by one
owner["Apples in pocket"] += 1

# Here we reduce your money amount depending
# on the price of an apples.
owner["Money in pocket"] -= owner["Apples price"]


# this line look if the bananas sensor is activated
if buy_bananas_sen.positive:

# Here we check if you have enought money to buy a bananas
if owner["Money in pocket"] - owner["Bananas price"] >= 0:

# Here we increment your number of bananas by one
owner["Bananas in pocket"] += 1

# Here we reduce your money amount depending
# on the price of a bananas.
owner["Money in pocket"] -= owner["Bananas price"]


      What we are confused about is, the script says that it first wants to check whether the apple button sensor is activated by using the line "if buy_apples_sen.positive;". We understand that the 'positive;' means that its checking whether the button is pressed. This should mean that the button is labeled ''buy_apples_sen" or "buy_apples". But the thing is its not named that way. Anyways, we posted our question on a blender blog, should be very soon before the Canadian guy answers.

1 comment:

  1. i'll have to look into this with you two when i get back. let me know if you get any reply from the forum.

    ReplyDelete