How do I make variable text?

Just started using Construct 2? Post your questions here

Post » Thu May 01, 2014 1:55 am

Hi, Panurge
You do not have the required permissions to view the files attached to this post.
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

Post » Sat May 03, 2014 5:52 pm

Thanks both very much. Nimos100 - that makes a lot of sense and I feel slightly embarrassed for not figuring it out myself! Whiteclaws - the array method is very elegant and I'll certainly make use of it (also, a tip of the hat for spotting me! Hope all is well with you :) ).
B
5
S
2
Posts: 53
Reputation: 792

Post » Sat May 03, 2014 9:15 pm

Sorry to keep resurrecting this thread but this sort of follows on from the problems I had before.

Everything is now working fine except the dictionaries sometimes return a result of 0 and I'm not sure why. For example, I have a dictionary called 'Jobs' with keys from 1 to 6 containing job names as values and set text from it like this:

Jobs.Get(str(round(random(1,6))))

All of the possible jobs will sometimes appear as text but I also sometimes get a 0. This happens with other dictionaries too.
B
5
S
2
Posts: 53
Reputation: 792

Post » Sun May 04, 2014 2:39 am

Jobs.Get(str(round(random(1,6))))

All of the possible jobs will sometimes appear as text but I also sometimes get a 0. This happens with other dictionaries too.


Sounds weird the dictionary returns 0 if something doesn't exist. Have you checked the debugger to see that it actually have 6 keys and that they match the values 1 to 6? your code should work as long as the keys are there.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Sun May 04, 2014 3:08 pm

Ack! Sorry about this - I just checked through and found I'd missed out a couple of keys (I have loads in each dictionary) and hadn't picked up on them the first time I checked. My fault entirely, everything is working fine now. :)
B
5
S
2
Posts: 53
Reputation: 792

Previous

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests