Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411526 Posts in 69381 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 09:11:18 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General thread for quick questions
Pages: 1 ... 31 32 [33] 34 35 ... 69
Print
Author Topic: General thread for quick questions  (Read 135636 times)
valrus
Level 3
***


View Profile
« Reply #640 on: May 04, 2016, 05:20:23 PM »

With a regex replace, you can pass a MatchEvaluator (essentially a wrapper around a method from matches to strings) instead of a string as the replacement.  So if you had your relevant translations in an array, you could pass in a method that gives you translation\[i\] and increments i, so that each time it finds a '%' it gives the next translation in line.

But you're best off naming your slots rather than referring to them all with just '%'.  Zilluss's solution should work.  More generally, you can use the regex+MatchEvaluator solution to capture however you name things, then ask for that name from your GetTranslation function.  Very roughly:

Code:
public string repl(Match m) {
  return Localization.GetTranslation(m.ToString().slice(1));
}

public string localize(string s) {
  Regex r = new Regex('%[A-Z0-9_]*');
  MatchEvaluator me = new MatchEvaluator(repl);
  return r.Replace(s, me);
}

...

string vsText = "%TRANSLATION_KEY1 vs. %TRANSLATION_KEY2";
vsText = obj.localize(vsText);

Something like that should call Localization.GetTranslation("TRANSLATION_KEY1") and Localization.GetTranslation("TRANSLATION_KEY2") and put the results in the right place.  (NB: I don't work in C# much, so the code probably doesn't work as-is.)
Logged
oahda
Level 10
*****



View Profile
« Reply #641 on: May 04, 2016, 08:32:25 PM »

Code:
String.Format("{0} vs. {1}", Localisation.GetTranslation( "TRANSLATION_KEY1" ), Localisation.GetTranslation( "TRANSLATION_KEY2" ))
This is the syntax they use for their localisation function at my new temporary job, which I got to use yesterday, actually. Spooky quinkydink.
Logged

zilluss
Level 1
*



View Profile
« Reply #642 on: May 05, 2016, 01:10:31 PM »

I... I'm not stalking you, baka senpai!
Logged

@zilluss | Devlog  Hand Point Right
oahda
Level 10
*****



View Profile
« Reply #643 on: May 05, 2016, 10:23:43 PM »

K-kowai..!
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #644 on: May 06, 2016, 07:48:47 AM »

I realize I'm probably asking for the moon here but does anyone know of the right set of flags to get MSVC to compile only ansi c?

edit : googling shows a couple ways to make their compiler a little more restrictive but I think I'll probably just have to test against another compiler every now and then to be sure.

« Last Edit: May 06, 2016, 07:57:31 AM by InfiniteStateMachine » Logged

Polly
Level 6
*



View Profile
« Reply #645 on: May 06, 2016, 09:33:48 AM »

I realize I'm probably asking for the moon here but does anyone know of the right set of flags to get MSVC to compile only ansi c?

/Za .. but you won't be able to use some of the headers that come with Visual Studio anymore as they use Microsoft extensions.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #646 on: May 06, 2016, 10:54:33 AM »

I realize I'm probably asking for the moon here but does anyone know of the right set of flags to get MSVC to compile only ansi c?

/Za .. but you won't be able to use some of the headers that come with Visual Studio anymore as they use Microsoft extensions.

Ah sweet thanks. That should get me started. The docs are funny though.

"The /Za compiler option emits an error for language constructs that are not compatible with ANSI C89 or ISO C++11."

C89 or Cpp11? That's pretty broad hahaha :D

Logged

Polly
Level 6
*



View Profile
« Reply #647 on: May 06, 2016, 12:43:19 PM »

C89 or Cpp11?

Depends on whether your source file ends with ".c" or ".cpp" ( iirc ) Wink
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #648 on: May 06, 2016, 01:54:52 PM »

Ah cool. I wasn't sure if they were going to discern the difference. That makes sense Smiley
Logged

Eendhoorn
Level 6
*

Quak


View Profile
« Reply #649 on: May 08, 2016, 03:26:25 PM »

Code:
String.Format("{0} vs. {1}", Localisation.GetTranslation( "TRANSLATION_KEY1" ), Localisation.GetTranslation( "TRANSLATION_KEY2" ))
Totally forgot to check back here, but thanks, that seems to do the trick!
Logged

LucasMaxBros
Level 2
**


My body is ready.


View Profile WWW
« Reply #650 on: May 09, 2016, 03:57:15 AM »

So on Game Maker Studio, I'm trying to research how to squeeze down on the file sizes of images in the future (cause I'd like to use a lot of different backgrounds of large scope later on, if feasible). It seems they only store them as PNG, is there a way I can store them as a different file-type so I can reduce how much space they take up? Or am I stuck with only PNG?
Logged

Pinqu!
Level 1
*


So it has come to this


View Profile WWW
« Reply #651 on: May 09, 2016, 04:01:49 AM »

Currently working on this in Gamemaker Studio:



The tree foliage is made of multiple white sprites that are colored with d3d_set_fog(true, color, 0, 1)

But if I add d3d_set_fog to the world it causes problems with the fog set on the tree foliage.

Any alternative for coloring the trees? (besides just adding more sprite with different colors)
Logged

Polly
Level 6
*



View Profile
« Reply #652 on: May 09, 2016, 04:44:28 AM »

Any alternative for coloring the trees?

image_blend
Logged
Pinqu!
Level 1
*


So it has come to this


View Profile WWW
« Reply #653 on: May 09, 2016, 05:06:53 AM »

To my knowledge image_blend only works when you are using draw_sprite_ext or draw_self(). Also it doesn't fully cover the sprite original color, but blends with it.. I am using d3d_draw_wall to draw the foliage, draw_sprite doesn't work in 3d..
Logged

Polly
Level 6
*



View Profile
« Reply #654 on: May 09, 2016, 06:36:42 AM »

draw_sprite doesn't work in 3d

Just double-checked it ( since i haven't used GameMaker in years ) .. and it works just fine. The red circle ( with "Hello" cut-out ) is a sprite and the black "wireframe" cube is a d3d_draw_block using a outline texture.



Also it doesn't fully cover the sprite original color, but blends with it..

If you make your sprite white, you can blend it to whichever color you want. The screenshot above uses the image below ( as sprite ) in combination with "image_blend = c_red".

« Last Edit: May 09, 2016, 06:43:22 AM by Polly » Logged
Pinqu!
Level 1
*


So it has come to this


View Profile WWW
« Reply #655 on: May 09, 2016, 06:46:43 AM »

draw_sprite doesn't work in 3d

Just double-checked it ( since i haven't used GameMaker in years ) .. and it works just fine. The red circle ( with "Hello" cut-out ) is a sprite and the black checkered cube is a d3d_draw_block.


Also it doesn't fully cover the sprite original color, but blends with it..

If you make your sprite white, you can blend it to whichever color you want. The screenshot above uses the image below ( as sprite ) in combination with "image_blend = c_red".

I didn't know you could use draw_sprite in 3d mode?!? I thought d3d_draw_wall was the only option to draw sprites.. I m gonna try this, thanks man Smiley

//edit
Works like a charm, thanks again!
« Last Edit: May 09, 2016, 11:14:49 AM by Pinqu! » Logged

Joj
Level 0
**


woh


View Profile WWW
« Reply #656 on: May 17, 2016, 10:12:20 AM »

Almost made a new thread for this question oops lol.

Should I be relying on event ticks to progress the time of day?
My UE4 game (is going to) depend on a time-of-day system for events to trigger eg, a house is inaccessible between the times of 8pm and 6am. But the general vibe I've gotten for relying on event ticks is that it's a crime punishable by death and it's going to cause a bunch of problems later. I'm not really a strong dev, just an artist having to dip their toes into other areas because they want something made, so I'm not really sure if there's any other option for a time of day system.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #657 on: May 17, 2016, 11:27:51 AM »

Almost made a new thread for this question oops lol.

Should I be relying on event ticks to progress the time of day?
My UE4 game (is going to) depend on a time-of-day system for events to trigger eg, a house is inaccessible between the times of 8pm and 6am. But the general vibe I've gotten for relying on event ticks is that it's a crime punishable by death and it's going to cause a bunch of problems later. I'm not really a strong dev, just an artist having to dip their toes into other areas because they want something made, so I'm not really sure if there's any other option for a time of day system.

Nothing wrong with using event ticks. That would be like saying you can't use an update loop. I don't see anything wrong with incrementing some counter in the tick event which then calls other events in your system like hourChanged, dayChanged etc etc
Logged

Dacke
Level 10
*****



View Profile
« Reply #658 on: May 18, 2016, 02:38:34 AM »

Depends on how the event ticks are implemented in that engine, right?

I found some random thread on the topic for UE4 here:
https://forums.unrealengine.com/showthread.php?3200-Why-people-use-Tick-event-as-ultimate-solution-for-looped-calling

The issues seem to be:
  • It works, but you need to make sure that you consider delta seconds properly
  • It works, but Timer or Delayed Loop can be much more preformant (potentially)
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #659 on: May 18, 2016, 11:06:37 AM »

Admittedly I spend about 90% of my time on the C++ side of the engine but unless I'm really mistaken then the event tick you see in blueprint is just the UFUNCTION binding.

That thread does seem to bring up a case where I wouldn't recommend using an update loop even if it was in C++. They want to spawn stuff at a set rate. A timer seems like a much better way to do that in general.

As for the point about the weapon fire rate. I think I would probably still do that in the tick function (probably a little contradictory of me to say that :D ). I'd have to think about that.
Logged

Pages: 1 ... 31 32 [33] 34 35 ... 69
Print
Jump to:  

Theme orange-lt created by panic