plant grwing script help

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

plant grwing script help

Post by marionline »

Hello,
this time I need help finding an bug that make the first plant (NPC 0, on map 3) change it's picture then it shouldn't. Almost immediately after picking a fuit the plant switches back to the picture facing left, displaying the fully grown plant. :/



For one plant the script wokred fine, but after adding the others, the fist behaves oddly,but the other plants on map 3 grow as they should.

Thanks for your help in advance! :D

Code: Select all

# plant growing script
# Plant stuff
# Plants

# walkabout graphic 31: 
# walkabout graphic 32: 
# walkabout graphic 33: 
# walkabout graphic 34: 
# walkabout graphic 35: 
# walkabout graphic 36: 
# walkabout graphic 37: 


#global variables: 10 to 15 = plantcounterswamp
#global variables (16 to ??,plantcounterroadtoEllysuI)
#global variables (?? to ??,plantcounterroadtoEllysuII)
#global variables (?? to ??,plantcounterForestofEllysu1) 
#global variabls  (?? to ??,plantcounterWaytoWestcity)

#show textbox (12)
plantcounterswamp  := plantcounterswamp  +1 #NPC 0
plantcounterswamp1 := plantcounterswamp1 +1 #NPC 1
plantcounterswamp2 := plantcounterswamp2 +1 #NPC 2
plantcounterswamp3 := plantcounterswamp3 +1 #NPC 3
plantcounterRoadtoEllysuIII := plantcounterRoadtoEllysuIII +1 # NPC0

# The 1st plant (NPC0) in the Swamp 
if (current map == 3) then 
         
	if (plantcounterswamp >= 9) then 
		(
		# Alter NPC (0,NPCstat:picture,33)
		set NPC direction (0, left)
		)
	else if (plantcounterswamp > 6) then 
		(
		# Alter NPC (0,NPCstat:picture,33)
		set NPC direction (0, down)
		)
	else if (plantcounterswamp > 3) then 
		(
		# Alter NPC (0,NPCstat:picture,33)
		set NPC direction (0, right)
		)
	else 
		(
		# Alter NPC (0,NPCstat:picture,33)
		set NPC direction (0, up)
		)

# The 2nd plant (NPC 01) in the Swamp 
if (current map == 3) then 
         
	if (plantcounterswamp1 >= 9) then 
		(
		set NPC direction (1, left)
		)
	else if (plantcounterswamp1 > 6) then 
		(
		set NPC direction (1, down)
		)
	else if (plantcounterswamp1 > 3) then 
		(
		set NPC direction (1, right)
		)
	else 
		(
		set NPC direction (1, up)
		)

# The 3rd plant (NPC 02) in the Swamp 
if (current map == 3) then 
         
	if (plantcounterswamp2 >= 9) then 
		(
		set NPC direction (2, left)
		)
	else if (plantcounterswamp2 > 6) then 
		(
		set NPC direction (2, down)
		)
	else if (plantcounterswamp2 > 3) then 
		(
		set NPC direction (2, right)
		)
	else 
		(
		set NPC direction (2, up)
		)


# The 4th plant (NPC 03) in the Swamp 
if (current map == 3) then 
         
	if (plantcounterswamp3 >= 9) then 
		(
		set NPC direction (3, left)
		)
	else if (plantcounterswamp3 > 6) then 
		(
		set NPC direction (3, down)
		)
	else if (plantcounterswamp3 > 3) then 
		(
		set NPC direction (3, right)
		)
	else 
		(
		set NPC direction (3, up)
		)

# The 1st plant (NPC 0) on the road to EllysuIII 
if (current map == 6) then 
         
	if (plantcounterRoadtoEllysuIII  >= 9) then 
		(
		set NPC direction (0, left)
		)
	else if (plantcounterRoadtoEllysuIII  > 6) then 
		(
		set NPC direction (0, down)
		)
	else if (plantcounterRoadtoEllysuIII  > 3) then 
		(
		set NPC direction (0, right)
		)
	else 
		(
		set NPC direction (0, up)
		)		

end

plotscript, getfruitSwamp, begin
if (current map == 3 && plantcounterswamp >= 9) then 
	(
	plantcounterswamp := 0
	# Alter NPC (0,NPCstat:picture,33)
	set NPC direction (0, up)
	get item (21,random(2,4))
	)
end

plotscript, getfruitSwamp2, begin
if (current map == 3 && plantcounterswamp1 >= 9) then 
	(
	plantcounterswamp1 := 0
	# Alter NPC (0,NPCstat:picture,33)
	set NPC direction (1, up)
	get item (21,random(2,4))
	)
end

plotscript, getfruitSwamp3, begin
if (current map == 3 && plantcounterswamp2 >= 9) then 
	(
	plantcounterswamp2 := 0
	set NPC direction (2, up)
	get item (21,random(2,4))
	)
end

plotscript, getfruitSwamp4, begin
if (current map == 3 && plantcounterswamp3 >= 9) then 
	(
	plantcounterswamp3 := 0
	set NPC direction (3, up)
	get item (21,random(2,4))
	)
end

plotscript, getfruitRoadtoEllysuIII, begin
if (current map ==6 && plantcounterRoadtoEllysuIII >= 9) then 
	(
	plantcounterRoadtoEllysuIII := 0
	set NPC direction (1, up)
	get item (21,random(2,4))
	)
end
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

How is this script triggered?

Also, I think a screenshot or two of the plants on the map, and a screenshot of the plant sprites in the sprite editor would be helpful for visualizing what is going on here
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

Post by marionline »

The script is included in the each-step script, wich also manage weather changes and count your steps.

That's a picture of the plant:
Image

The script to pick up the fruits are run by NPCs, if you click them.
Image

I also re-checked if not two NPC were using the same "get fruit" script, it's not the case here.
I could also upload the .rpg file if that helps.

Edit: The number on the sceen is the "plantcounterswamp" value, also displayed by the each step script. ((show value (plantcounterswamp) ))
Last edited by marionline on Tue Sep 10, 2013 3:28 pm, edited 1 time in total.
Post Reply