Jass Questions.

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
weirdone2
Forum Staff
Posts: 926
Joined: June 3rd, 2007, 8:03 pm

Re: How to convert color to string?

Post by weirdone2 »

Hmm so your system is only based on one sided alliances? :P Also I just noticed i forgot to make the other side ally in mine lolz. I'ma prolly end up just doing a one sided alliance system though it seems an agreement alliance system is rather over annoying but it depends on which one in the end I think looks better. XD
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How to convert color to string?

Post by Aero »

One sided is better for multiple reasons and it's a lot easier with less confusion.

With two-sided, you have problems like red typing -ally green, then yellow typing -ally green and then green typing -accept.

Accept both? Accept first? Accept second?

Also with two-sided, I would think you would need at a minimum 1 global array or some kind of external variables.

There's nothing wrong with this but every global array has a limit of 8192 possible values and whether the values are empty or not they still take up space! (32kb memory for each global array)

This can add up very quickly if you use global arrays carelessly.

Plus, if you want my system to look nice just add some color (By the way, don't use a global array to store names or add color, use a local array--that way it only temporarely takes up memory)

Comment and praise my system! :D

Also...if you plan on using it, credits please =3
PM me for what to put :D[/quote]
User avatar
weirdone2
Forum Staff
Posts: 926
Joined: June 3rd, 2007, 8:03 pm

Re: How to convert color to string?

Post by weirdone2 »

Hehe I think ima go with one sided alliance as agreement allinace makes me think too much. :shock: Thankfully it'll be as simple as jsut taking out the stupid agreement part and viola it'll be a nice non bugged one sided allying system. XD Also I noticed no ones actually answered the question I made this thread for lolz. :lol:

And aero though I neva really looked over your allying system, just browsed it a lil. :) And saw that it wasn't an agreement system, :P i'm sure it's good as you usually put forth a good bit on all your works that i've seen. :wink: And thx for the info never knew how much space globals took up lolz, thankfully I never really use them anyway except for creating triggers. :)
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How to convert color to string?

Post by Aero »

Sorry, convert color to string?

What do you mean? Like hex codes?
HINDYhat
Senior Member
Posts: 101
Joined: June 1st, 2007, 9:05 pm

Re: How to convert color to string?

Post by HINDYhat »

I think by color to string he means converting Player(0) to "red", Player(1) to "blue" etc..
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How to convert color to string?

Post by Aero »

Just make a custom function...

Code: Select all

function Player2StringName takes player p returns string
local integer i=0
local string array s
set s[0]="red"
set s[1]="blue"
set s[2]="teal"
set s[3]="purple"
set s[4]="yellow"
set s[5]="orange"
set s[6]="green"
set s[7]="pink"
set s[8]="gray"
set s[9]="light blue"
set s[10]="dark green"
set s[11]="brown"
loop
exitwhen i>11
if p==Player(i)then
return s[i]
endif
set i=i+1
endloop
return null
endfunction
Or Alternatively... (I would use the following)

Code: Select all

function Player2StringName takes player p returns string
if p==Player(0)then
return"red"
elseif p==Player(1)then
return"blue"
elseif p==Player(2)then
return"teal"
elseif p==Player(3)then
return"purple"
elseif p==Player(4)then
return"yellow"
elseif p==Player(5)then
return"orange"
elseif p==Player(6)then
return"green"
elseif p==Player(7)then
return"pink"
elseif p==Player(8)then
return"gray"
elseif p==Player(9)then
return"light blue"
elseif p==Player(10)then
return"dark green"
elseif p==Player(11)then
return"brown"
endif
return null
endfunction
If this isn't what you wanted I'm sure you can understand how you would modify this accordingly...
User avatar
backspaceoneone
Junior Member
Posts: 44
Joined: July 21st, 2007, 7:31 am

Re: How to convert color to string?

Post by backspaceoneone »

For most diplomacy/strategy maps only the person typing the text allies (so if im red and I type ally blue, only I will ally to blue). But when someone types unally red, then both players will become enemies.
User avatar
weirdone2
Forum Staff
Posts: 926
Joined: June 3rd, 2007, 8:03 pm

Re: How to convert color to string?

Post by weirdone2 »

Na i'm talking about this lil peace of code.

Code: Select all

local string splayers=GetPlayerColor(p)
call DisplayTextToPlayer(Player(0),0,0,splayers+"wishes to ally you, type -ally "+splayers+"to ally them")
if i were able to get this to work my code would be even shorter. :)
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How to convert color to string?

Post by Aero »

You are misunderstanding what GetPlayerColor does . . .

function GetPlayerColor takes player p returns playercolor

playercolor is a handle... not a string

local string splayers = FunctionReturnValueThatIsNotAString

playercolor is mostly used for color coding players on main/mini map and unit colors.
User avatar
weirdone2
Forum Staff
Posts: 926
Joined: June 3rd, 2007, 8:03 pm

Re: How to convert color to string?

Post by weirdone2 »

Aero wrote:You are misunderstanding what GetPlayerColor does . . .

function GetPlayerColor takes player p returns playercolor

playercolor is a handle... not a string

local string splayers = FunctionReturnValueThatIsNotAString

playercolor is mostly used for color coding players on main/mini map and unit colors.

Youve misuderstood what I asked, I asked if it was possible to "convert" it to a string, obviously its not a string... Though it doesn't matter anymore as sally has now become the backbone of my system. :lol: