+=

Forum Archive - from http://theuniversal.net
Locked
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

+=

Post by morbydvisns »

Software:Registered Server
Version Number:
________________________________________________________________________
Location
planet
________________________________________________________________________
Description:
$gbuildingvar[$vBranchesHarvested] += 1
doesn't work. must do

$gbuildingvar[$vBranchesHarvested] = $gbuildingvar[$vBranchesHarvested ]+ 1


________________________________________________________________________
Steps to Replicate:
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

I agree, it would be quite nice to be able to just do $var + 1 instead of $var = $var + 1
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

mm... support for += was added a few versions back and seems to work fine for me. (I've been using it for a while now without any problems that i've noticed)
This is my test code..

Code: Select all

Event( "AccessBuilding", "4" )
{
	$vVarNum = 3
	$gBuildingVar[$vVarNum] = 0
	*say $gBuildingVar[$vVarNum]

	$gBuildingVar[$vVarNum] += 1
	*say $gBuildingVar[$vVarNum]

}
Which outputs 0 then 1 as expected. Could you recheck please?
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

ok well the only difference I see of the bat is I didn't set them to 0 before adding 1. I'll play around after work and see what more I can find out on it.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

Pretty sure that'll have nothing to do with it.
Where is your $vBranchesHarvested variable declared? Maybe try printing that just to make sure its getting the right var?
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

yea i donno, all i know is its working properly now after i put it back in with +=. I have odd issues with script sometimes, especially if i copy and paste in from another, older script file that things worked just fine before, simply retype the exact same chars and things are back in line.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

perhaps was a typo you didn't notice?

I'd be lying if I said it didn't happen to me.
Sometimes to the point where I had to copy/paste the two instances of a var and put them one above the other to compare letter by letter to find I was missing an 'i' or something like that after doing a long stretch of scripting..
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

O that's happened, but it's also happened just as i said. I will literally type a line in one below and it be exactly the same and work vs the pasted in. Here's an example of another oddity....

Code: Select all

 OsdAddItem(OSDIMAGE,””, “http://myweb.com/image.jpg”  )
 OsdAddItem(OSDIMAGE,"", "http://myweb.com/image.jpg"  )
the top is copy/pasted out of the world owners manual. the bottom is my own typed in.. see the difference? The top one will not work and the bottom will. I can only assume mit used the same key to type his quotation as I did (the one left of the enter, while holding shift).

That is
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

i dont know where that last lingering line at the bottom came from but disregard =)
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

if ($gBuildingVar[$vNextCycle]-1 > $gBuildingTimeVar[$tvNextCycle])
{
$gBuildingTimeVar[$tvNextCycle] += 1

//$gBuildingTimeVar[$tvNextCycle] = $gBuildingTimeVar[$tvNextCycle] + 1

*say tick $gBuildingTimeVar[$tvNextCycle]
}



if i go with the += i get a tick 1 scrolling eternally

if i go with the one currently commented out, it works properly.

All i did was copy the $gBuildingTimeVar[$tvNextCycle] paste it a couple times and put = + and 1 in their proper spots.

I've also typed in the top one a couple times with no diff.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

I see a different in that coded text.
Look closely at the quotation marks :p

copy/pasted from that code block
top:
bottom: "
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

right. That's why i made the comment about mit using the same key to type those. Never known a parser to care what font was used.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

Its not font, those quotation marks are a different ASCII character. Dunno if its a US-keyboard thing or something but i have no idea how you add those? :)
Anyway, they are now supported (server 0.67.2) and treated the same as the normal quotation marks.
Locked