Newbie
Displaying 1-8 of 8 total.
1
Interference
|
Hi there! I'm a MegaZeuxer who's decided to dabble a little in VERGE. I can draw quite competently but my coding skills leave a little to be desired.
I've been watching VERGE develop from afar for a while now but I never decided to have a go myself as I'm a bumbling retard at programming in c-oriented languages. With the appearance of v2.7 (and the language changing to Python) I thought I may as well give it a go since the language seems to be a lot easier for me to code in.
I'm generally fiddling around at the moment and getting myself accustomed to Python. I do the majority of my learning from working examples of code (of which there are few for games written in v2.7) and like every budding newbie I'll have a few questions to ask before I shut up and get on with something.
Anyway, a question:
When I want to make an entity I put on the map in maped do something (like follow another entity) how do I target specific entities? I know I have to use commands that in the reference begin with "entity." but what do I substitute the word "entity" with? If anyone would be nice enough to help I'd also appreciate a little sample code to look at too.
Yes, this probably sounds like a very dumb question of which there is likely a blindingly obvious answer but help would further my knowledge.
Thanks.
Posted on 2001-10-01 14:16:10
|
andy
|
When the reference guide says "entity.blah", the word "entity" means an entity object. There are two ways to get such an object. One is the Entity() function, which creates an entity out of thin air, and gives you the object associated with it.
bob=Entity(x,y,'bob.chr')
The other way is a built in dictionary called map.entities. It contains all the entities spawned from the map. Name the entity something that's easy to remember in maped, then refer to it like so:
map.entities['Bob'].Move('R8L8')
"Ignorance is its own reward" -- Proverb
Posted on 2001-10-01 19:01:13
|
Interference
|
Fantastic! That last bit was all I needed to know! Cheers!
I do have another question, though:
How do I set a variable to a number so that it can be read by any section of my game? In QBASIC the command is COMMON SHARED (variable name), what is it in Python?
Thanks again!
-- Interference "Today is the dawn of a new error"
Posted on 2001-10-02 16:18:54
|
JL
|
Just assign a value to the variable in the global scope (i.e. outside any function definitions). Then you will be able to read the value of the variable from within any function in the same file:
myInt = 3
def output():
print myInt
To write a value to the variable, you must first declare it global within the function. This is so that Python knows you meant to assign to a variable outside the function, rather than creating a new, local variable:
def setsInt():
global myInt
myInt = 8
If you want to read or write the variable from another file, you must first import the file the variable is in. For instance, if the above definitions are in system.py and you want to access the variable in map.py, type the following line at the top of map.py:
from system import *
Then you should be able to access the variable in the same way you did in system.py.
---
I am a frontrunning eltist.
Posted on 2001-10-02 18:24:27
|
Interference
|
Uh, won't that keep setting the variable myInt to 8 every time I call the function setsInt()?
I'm trying to make it so that I set the variable "health" in system.py at the start of a new game to 100. From there on I want it to be possible to add or subtract to or from this initial figure in any file and to be able to display how much health the player has left on any status screens.
-- Interference "Today is the dawn of a new error"
Posted on 2001-10-02 19:10:56
|
JL
|
It's pretty straightforward if you follow the guidelines I posted:
def initNewGame():
global health
health = 100
def healCharacter(amount):
global health
health = min(health + amount, 100)
def hurtCharacter(amount):
global health
health -= amount
if health
---
I am a frontrunning eltist.
Posted on 2001-10-02 19:36:19
|
JL
|
It's pretty straightforward if you follow the guidelines I just posted:
def initNewGame():
global health
# Various initialization.
# ...
health = 100
# ...
def healCharacter(amount):
global health
health = min(health + amount, 100)
def hurtCharacter(amount):
global health
health -= amount
if health <= 0:
showDeathSequence()
initNewGame()
initNewGame()
And so on.
Like I said before, you don't really need the global statement if you are just reading the variable, but it's good practice to put it in anyway. To access the var in other files, be sure to include "from system import *" at the top.
---
I am a frontrunning eltist.
Posted on 2001-10-02 19:40:31
|
Interference
|
Right! Now I get it, it's just it seemed a little odd the first time I saw it. To need more than two lines of code to add or subtract an amount from a variable just appeared a little strange. Let's just say I was hoping there was an easier way to do it. Thanks for the help!
I've got another two questions (argh!):
I seem to have an inability to place zones with WinMaped, ie. I can only place zone 0s (the default one) because I don't know what the controls are to switch to the other zones. What are they? I know they were "a" and "z" in Maped but that doesn't seem to be the case in WinMaped. Is the feature unimplemented, is my computer screwed or is the answer right under my nose?
And: there was a utility for VERGE 2 games using VC that allowed you to pack all your game files into a pack file. This utility doesn't work for 2.7, are there plans to put packfile support into it?
Sorry to have to keep asking dumb questions. They'll get fewer in numbers as I learn :-).
-- Interference "Today is the dawn of a new error"
Posted on 2001-10-03 14:54:13
|