obj/cannon
do
Fire(mob in oview(5))
ammo--
while(ammo)
Problem description: I'm trying to make a cannon loop through its ammo, but Dream Maker is telling me that the value 'ammo' is not allowed in either spots it's used. Any help?
ID:143053
Jan 1 2008, 5:28 am
|
|
Code:
obj/cannon Problem description: I'm trying to make a cannon loop through its ammo, but Dream Maker is telling me that the value 'ammo' is not allowed in either spots it's used. Any help? |
In response to SuperSaiyanGokuX
|
|
And another thing, what is "Fire(mob in oview(5))"? Is it supposed to loop through all mobs in view? If so, that's not how you do it. Use a for() loop instead.
|
In response to SuperSaiyanGokuX
|
|
SuperSaiyanGokuX wrote:
Another thing I'd like to mention is that you can skip using do altogether... The following works without it: > obj It will carry out the code within while() in the same loop that you'd get with the previous example (though I'd guess the only real difference is in how clean your code looks)... An even more significant reason not to use do-while() in this situation is that the do statement will be executed at least once. That means if ammo is currently 0, it will become -1 when the first do statement executes and it will fall into an infinite loop. |
In response to Kaiochao2536
|
|
And another thing: that should be oview(src,5), or it defaults to oview(usr,5), and usr is not valid in procs.
|
In response to Garthor
|
|
Any an other other thing: oview() and view() is dist first, then source. Unless it doesn't matter.
oview(dist=5,src=usr) |
In response to Kaiochao2536
|
|
Kaiochao2536 wrote:
Any an other other thing: oview() and view() is dist first, then source. Unless it doesn't matter. It doesn't really matter, no. Whichever argument is numeric is the one that's treated as range. These procs are about the only place that sort of thing applies. Lummox JR |
You would have to create a proc for your cannon object, and place that code inside of it, then call that proc in your game to make the cannon carry out those functions... Something like this:
Another thing I'd like to mention is that you can skip using do altogether... The following works without it:
It will carry out the code within while() in the same loop that you'd get with the previous example (though I'd guess the only real difference is in how clean your code looks)...
And if you want the cannon to automatically fire as soon as it is created, you can also move the loop into the cannon's built-in New() proc, which will execute it immediately upon creation...